Whamcloud - gitweb
ede6dce0150d52168d852d87486b196657bcbebd
[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 /*
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 "%Lu"
119 # define LPD64 "%Ld"
120 # define LPX64 "%#Lx"
121 # define LPX64i "%Lx"
122 # define LPF64 "L"
123 #elif (BITS_PER_LONG == 32)
124 # define LPU64 "%Lu"
125 # define LPD64 "%Ld"
126 # define LPX64 "%#Lx"
127 # define LPX64i "%Lx"
128 # define LPF64 "L"
129 #elif (BITS_PER_LONG == 64)
130 # define LPU64 "%lu"
131 # define LPD64 "%ld"
132 # define LPX64 "%#lx"
133 # define LPX64i "%lx"
134 # define LPF64 "l"
135 #endif
136
137 #ifndef LPU64
138 # error "No word size defined"
139 #endif
140
141 /*
142  * long_ptr_t & ulong_ptr_t, same to "long" for gcc
143  */
144 # define LPLU "%lu"
145 # define LPLD "%ld"
146 # define LPLX "%#lx"
147
148 /*
149  * pid_t
150  */
151 # define LPPID "%d"
152
153 #endif