]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - include/platform_defs.h.in
xfsprogs: define umode_t for build if not defined already
[thirdparty/xfsprogs-dev.git] / include / platform_defs.h.in
1 /*
2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public License
7 * as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 *
18 * @configure_input@
19 */
20 #ifndef __XFS_PLATFORM_DEFS_H__
21 #define __XFS_PLATFORM_DEFS_H__
22
23 #include <stdio.h>
24 #include <errno.h>
25 #include <fcntl.h>
26 #include <stdarg.h>
27 #include <assert.h>
28 #include <stddef.h>
29 #include <stdlib.h>
30 #include <string.h>
31 #include <stdint.h>
32 #include <unistd.h>
33 #include <pthread.h>
34 #include <ctype.h>
35 #include <sys/types.h>
36 #include <limits.h>
37 #include <stdbool.h>
38
39 #undef HAVE___U32
40 #ifdef HAVE___U32
41 #include <asm/types.h>
42 #else
43 typedef unsigned char __u8;
44 typedef signed char __s8;
45 typedef unsigned short __u16;
46 typedef signed short __s16;
47 typedef unsigned int __u32;
48 typedef signed int __s32;
49 typedef unsigned long long int __u64;
50 typedef signed long long int __s64;
51 #endif
52
53 #ifdef __CHECKER__
54 #define __bitwise __attribute__((bitwise))
55 #define __force __attribute__((force))
56 #else
57 #define __bitwise
58 #define __force
59 #endif
60
61 typedef __u16 __bitwise __le16;
62 typedef __u32 __bitwise __le32;
63 typedef __u64 __bitwise __le64;
64
65 typedef __u16 __bitwise __be16;
66 typedef __u32 __bitwise __be32;
67 typedef __u64 __bitwise __be64;
68
69 typedef struct filldir filldir_t;
70
71 #if defined(__linux__)
72 #include <xfs/linux.h>
73 #elif defined(__FreeBSD__)
74 #include <xfs/freebsd.h>
75 #elif defined(__FreeBSD_kernel__)
76 #include <xfs/gnukfreebsd.h>
77 #elif defined(__APPLE__)
78 #include <xfs/darwin.h>
79 #elif defined(__sgi__) || defined(__sgi)
80 #include <xfs/irix.h>
81 #else
82 # error unknown platform... have fun porting!
83 #endif
84
85 /* long and pointer must be either 32 bit or 64 bit */
86 #undef SIZEOF_LONG
87 #undef SIZEOF_CHAR_P
88 #define BITS_PER_LONG (SIZEOF_LONG * CHAR_BIT)
89
90 /* Check if __psint_t is set to something meaningful */
91 #undef HAVE___PSINT_T
92 #ifndef HAVE___PSINT_T
93 # if (SIZEOF_CHAR_P * CHAR_BIT) == 32
94 typedef int __psint_t;
95 # elif (SIZEOF_CHAR_P * CHAR_BIT) == 64
96 # if BITS_PER_LONG == 64
97 typedef long __psint_t;
98 # else
99 /* This is a very strange architecture, which has 64 bit pointers but */
100 /* not 64 bit longs. So, just punt here and assume long long is OK. */
101 typedef long long __psint_t;
102 # endif
103 # else
104 # error Unknown pointer size
105 # endif
106 #endif
107
108 /* Check if __psunsigned_t is set to something meaningful */
109 #undef HAVE___PSUNSIGNED_T
110 #ifndef HAVE___PSUNSIGNED_T
111 # if (SIZEOF_CHAR_P * CHAR_BIT) == 32
112 typedef unsigned int __psunsigned_t;
113 # elif (SIZEOF_CHAR_P * CHAR_BIT) == 64
114 # if BITS_PER_LONG == 64
115 typedef long __psunsigned_t;
116 # else
117 /* This is a very strange architecture, which has 64 bit pointers but */
118 /* not 64 bit longs. So, just punt here and assume long long is OK. */
119 typedef unsigned long long __psunsigned_t;
120 # endif
121 # else
122 # error Unknown pointer size
123 # endif
124 #endif
125
126 /* Check whether to define umode_t ourselves. */
127 #ifndef HAVE_UMODE_T
128 typedef unsigned short umode_t;
129 #endif
130
131 /* Define if you want gettext (I18N) support */
132 #undef ENABLE_GETTEXT
133 #ifdef ENABLE_GETTEXT
134 # include <libintl.h>
135 # define _(x) gettext(x)
136 # define N_(x) x
137 #else
138 # define _(x) (x)
139 # define N_(x) x
140 # define textdomain(d) do { } while (0)
141 # define bindtextdomain(d,dir) do { } while (0)
142 #endif
143 #include <locale.h>
144
145 #ifdef DEBUG
146 # define ASSERT(EX) assert(EX)
147 #else
148 # define ASSERT(EX) ((void) 0)
149 #endif
150
151 /*
152 * sparse kernel source annotations
153 */
154 #ifndef __user
155 #define __user
156 #endif
157
158 #define IRIX_DEV_BITSMAJOR 14
159 #define IRIX_DEV_BITSMINOR 18
160 #define IRIX_DEV_MAXMAJ 0x1ff
161 #define IRIX_DEV_MAXMIN 0x3ffff
162 #define IRIX_DEV_MAJOR(dev) ((int)(((unsigned)(dev) >> IRIX_DEV_BITSMINOR) \
163 & IRIX_DEV_MAXMAJ))
164 #define IRIX_DEV_MINOR(dev) ((int)((dev) & IRIX_DEV_MAXMIN))
165 #define IRIX_MKDEV(major,minor) ((xfs_dev_t)(((major) << IRIX_DEV_BITSMINOR) \
166 | (minor&IRIX_DEV_MAXMIN)))
167 #define IRIX_DEV_TO_KDEVT(dev) makedev(IRIX_DEV_MAJOR(dev),IRIX_DEV_MINOR(dev))
168
169 /* ARM old ABI has some weird alignment/padding */
170 #if defined(__arm__) && !defined(__ARM_EABI__)
171 #define __arch_pack __attribute__((packed))
172 #else
173 #define __arch_pack
174 #endif
175
176 #endif /* __XFS_PLATFORM_DEFS_H__ */