]>
git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - include/platform_defs.h.in
1 // SPDX-License-Identifier: LGPL-2.1
3 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
6 #ifndef __XFS_PLATFORM_DEFS_H__
7 #define __XFS_PLATFORM_DEFS_H__
21 #include <sys/types.h>
22 #include <sys/param.h>
28 /* long and pointer must be either 32 bit or 64 bit */
29 #define BITS_PER_LONG (sizeof(long) * CHAR_BIT)
31 typedef unsigned short umode_t
;
33 /* Define if you want gettext (I18N) support */
37 # define _(x) gettext(x)
42 # define textdomain(d) do { } while (0)
43 # define bindtextdomain(d,dir) do { } while (0)
47 #define IRIX_DEV_BITSMAJOR 14
48 #define IRIX_DEV_BITSMINOR 18
49 #define IRIX_DEV_MAXMAJ 0x1ff
50 #define IRIX_DEV_MAXMIN 0x3ffff
51 #define IRIX_DEV_MAJOR(dev) ((int)(((unsigned)(dev) >> IRIX_DEV_BITSMINOR) \
53 #define IRIX_DEV_MINOR(dev) ((int)((dev) & IRIX_DEV_MAXMIN))
54 #define IRIX_MKDEV(major,minor) ((xfs_dev_t)(((major) << IRIX_DEV_BITSMINOR) \
55 | (minor&IRIX_DEV_MAXMIN)))
56 #define IRIX_DEV_TO_KDEVT(dev) makedev(IRIX_DEV_MAJOR(dev),IRIX_DEV_MINOR(dev))
59 #define min(a,b) (((a)<(b))?(a):(b))
60 #define max(a,b) (((a)>(b))?(a):(b))
62 #define max3(a,b,c) max(max(a, b), c)
64 /* If param.h doesn't provide it, i.e. for Android */
70 # define ASSERT(EX) assert(EX)
72 # define ASSERT(EX) ((void) 0)
75 extern int platform_nproc(void);
77 #define NSEC_PER_SEC (1000000000ULL)
78 #define NSEC_PER_USEC (1000ULL)
80 /* Simplified from version in include/linux/overflow.h */
83 * Compute a*b+c, returning SIZE_MAX on overflow. Internal helper for
84 * struct_size() below.
86 static inline size_t __ab_c_size(size_t a
, size_t b
, size_t c
)
91 #define __must_be_array(a) (0)
94 * struct_size() - Calculate size of structure with trailing array.
95 * @p: Pointer to the structure.
96 * @member: Name of the array member.
97 * @count: Number of elements in the array.
99 * Calculates size of memory needed for structure @p followed by an
100 * array of @count number of @member elements.
102 * Return: number of bytes needed or SIZE_MAX on overflow.
104 #define struct_size(p, member, count) \
106 sizeof(*(p)->member) + __must_be_array((p)->member), \
110 * struct_size_t() - Calculate size of structure with trailing flexible array
111 * @type: structure type name.
112 * @member: Name of the array member.
113 * @count: Number of elements in the array.
115 * Calculates size of memory needed for structure @type followed by an
116 * array of @count number of @member elements. Prefer using struct_size()
117 * when possible instead, to keep calculations associated with a specific
118 * instance variable of type @type.
120 * Return: number of bytes needed or SIZE_MAX on overflow.
122 #define struct_size_t(type, member, count) \
123 struct_size((type *)NULL, member, count)
126 * Add the pseudo keyword 'fallthrough' so case statement blocks
127 * must end with any of these keywords:
132 * return [expression];
134 * gcc: https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html#Statement-Attributes
136 #if defined __has_attribute
137 # if __has_attribute(__fallthrough__)
138 # define fallthrough __attribute__((__fallthrough__))
140 # define fallthrough do {} while (0) /* fallthrough */
143 # define fallthrough do {} while (0) /* fallthrough */
146 /* Only needed for the kernel. */
150 #define __return_address __builtin_return_address(0)
153 * Return the address of a label. Use barrier() so that the optimizer
154 * won't reorder code to refactor the error jumpouts into a single
155 * return, which throws off the reported address.
157 #define __this_address ({ __label__ __here; __here: barrier(); &&__here; })
158 /* Optimization barrier */
160 /* The "volatile" is due to gcc bugs */
161 #define barrier() __asm__ __volatile__("": : :"memory")
164 /* Optimization barrier */
166 # define barrier() __memory_barrier()
169 #endif /* __XFS_PLATFORM_DEFS_H__ */