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