Whamcloud - gitweb
67a495fc0da202d006d7e2d8b48d52ead219923d
[fs/lustre-release.git] / libcfs / include / libcfs / posix / posix-wordsize.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * GPL HEADER START
5  *
6  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 only,
10  * as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * General Public License version 2 for more details (a copy is included
16  * in the LICENSE file that accompanied this code).
17  *
18  * You should have received a copy of the GNU General Public License
19  * version 2 along with this program; If not, see
20  * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
21  *
22  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23  * CA 95054 USA or visit www.sun.com if you need additional information or
24  * have any questions.
25  *
26  * GPL HEADER END
27  */
28 /*
29  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
30  * Use is subject to license terms.
31  *
32  * Copyright (c) 2011, Whamcloud, Inc.
33  */
34 /*
35  * This file is part of Lustre, http://www.lustre.org/
36  * Lustre is a trademark of Sun Microsystems, Inc.
37  *
38  * libcfs/include/libcfs/posix/posix-wordsize.h
39  *
40  * Wordsize related  defines for posix userspace.
41  *
42  * Author: Robert Read <rread@sun.com>
43  */
44
45 #ifndef __LIBCFS_LINUX_KP30_H__
46 #define __LIBCFS_LINUX_KP30_H__
47
48
49
50 #if defined(__CYGWIN__)
51 # include <cygwin-ioctl.h>
52 #endif
53 #ifdef HAVE_SYS_IOCTL_H
54 # include <sys/ioctl.h>
55 #endif
56 #ifndef _IOWR
57 # include "ioctl.h"
58 #endif
59
60 # define CFS_MODULE_PARM(name, t, type, perm, desc)
61 #define PORTAL_SYMBOL_GET(x) inter_module_get(#x)
62 #define PORTAL_SYMBOL_PUT(x) inter_module_put(#x)
63
64
65 #ifdef __CYGWIN__
66 # ifndef BITS_PER_LONG
67 #  if (~0UL) == 0xffffffffUL
68 #   define BITS_PER_LONG 32
69 #  else
70 #   define BITS_PER_LONG 64
71 #  endif
72 # endif
73 #else 
74 #  define BITS_PER_LONG __WORDSIZE
75 #endif
76
77
78 /******************************************************************************/
79 /* Light-weight trace
80  * Support for temporary event tracing with minimal Heisenberg effect. */
81 #define LWT_SUPPORT  0
82
83 #define LWT_MEMORY   (16<<20)
84
85 typedef struct {
86         long long   lwte_when;
87         char       *lwte_where;
88         void       *lwte_task;
89         long        lwte_p1;
90         long        lwte_p2;
91         long        lwte_p3;
92         long        lwte_p4;
93 # if BITS_PER_LONG > 32
94         long        lwte_pad;
95 # endif
96 } lwt_event_t;
97
98 #if LWT_SUPPORT
99 #define LWT_EVENT(p1,p2,p3,p4)     /* no userland implementation yet */
100 #endif /* LWT_SUPPORT */
101
102 /* ------------------------------------------------------------------ */
103
104 #define IOCTL_LIBCFS_TYPE long
105
106
107 #if BITS_PER_LONG > 32
108 # define LI_POISON ((int)0x5a5a5a5a5a5a5a5a)
109 # define LL_POISON ((long)0x5a5a5a5a5a5a5a5a)
110 # define LP_POISON ((void *)(long)0x5a5a5a5a5a5a5a5a)
111 #else
112 # define LI_POISON ((int)0x5a5a5a5a)
113 # define LL_POISON ((long)0x5a5a5a5a)
114 # define LP_POISON ((void *)(long)0x5a5a5a5a)
115 #endif
116
117 #if (defined(__KERNEL__) && defined(HAVE_KERN__U64_LONG_LONG)) || \
118     (!defined(__KERNEL__) && defined(HAVE_USER__U64_LONG_LONG))
119 /* x86_64 defines __u64 as "long" in userspace, but "long long" in the kernel */
120 # define LPU64 "%llu"
121 # define LPD64 "%lld"
122 # define LPX64 "%#llx"
123 # define LPX64i "%llx"
124 # define LPO64 "%#llo"
125 # define LPF64 "ll"
126 #elif (BITS_PER_LONG == 32)
127 # define LPU64 "%llu"
128 # define LPD64 "%lld"
129 # define LPX64 "%#llx"
130 # define LPX64i "%llx"
131 # define LPO64 "%#llo"
132 # define LPF64 "L"
133 #elif (BITS_PER_LONG == 64)
134 # define LPU64 "%lu"
135 # define LPD64 "%ld"
136 # define LPX64i "%lx"
137 # define LPX64 "%#lx"
138 # define LPO64 "%#lo"
139 # define LPF64 "l"
140 #endif
141
142 #ifndef LPU64
143 # error "No word size defined"
144 #endif
145
146 /*
147  * long_ptr_t & ulong_ptr_t, same to "long" for gcc
148  */
149 # define LPLU "%lu"
150 # define LPLD "%ld"
151 # define LPLX "%#lx"
152
153 /*
154  * pid_t
155  */
156 # define LPPID "%d"
157
158 #endif