]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame - include/platform_defs.h.in
xfs: rename m_ag_maxlevels to m_allocbt_maxlevels
[thirdparty/xfsprogs-dev.git] / include / platform_defs.h.in
CommitLineData
959ef981 1// SPDX-License-Identifier: LGPL-2.1
2bd0ea18 2/*
f302e9e4
NS
3 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
4 * All Rights Reserved.
2bd0ea18
NS
5 */
6#ifndef __XFS_PLATFORM_DEFS_H__
7#define __XFS_PLATFORM_DEFS_H__
8
9#include <stdio.h>
6bef826c
NS
10#include <errno.h>
11#include <fcntl.h>
b26ade3f 12#include <stdarg.h>
2bd0ea18 13#include <assert.h>
2bd0ea18
NS
14#include <stddef.h>
15#include <stdlib.h>
16#include <string.h>
5e656dbb 17#include <stdint.h>
2bd0ea18 18#include <unistd.h>
5e656dbb
BN
19#include <pthread.h>
20#include <ctype.h>
2bd0ea18 21#include <sys/types.h>
2bba5a01 22#include <sys/param.h>
865f1075 23#include <limits.h>
a2ceac1f 24#include <stdbool.h>
b9bc59cb 25#include <libgen.h>
e4da1b16 26#include <urcu.h>
6bef826c 27
5e656dbb 28typedef struct filldir filldir_t;
1707056a 29
2bd0ea18 30/* long and pointer must be either 32 bit or 64 bit */
865f1075
JE
31#undef SIZEOF_LONG
32#undef SIZEOF_CHAR_P
33#define BITS_PER_LONG (SIZEOF_LONG * CHAR_BIT)
044fe078 34
cd960ece
MS
35/* Check whether to define umode_t ourselves. */
36#ifndef HAVE_UMODE_T
37typedef unsigned short umode_t;
38#endif
39
9440d84d
NS
40/* Define if you want gettext (I18N) support */
41#undef ENABLE_GETTEXT
42#ifdef ENABLE_GETTEXT
43# include <libintl.h>
44# define _(x) gettext(x)
97294b22 45# define N_(x) x
9440d84d
NS
46#else
47# define _(x) (x)
97294b22 48# define N_(x) x
9440d84d
NS
49# define textdomain(d) do { } while (0)
50# define bindtextdomain(d,dir) do { } while (0)
51#endif
6ef2febc 52#include <locale.h>
9440d84d 53
32181a02
NS
54#define IRIX_DEV_BITSMAJOR 14
55#define IRIX_DEV_BITSMINOR 18
56#define IRIX_DEV_MAXMAJ 0x1ff
57#define IRIX_DEV_MAXMIN 0x3ffff
58#define IRIX_DEV_MAJOR(dev) ((int)(((unsigned)(dev) >> IRIX_DEV_BITSMINOR) \
59 & IRIX_DEV_MAXMAJ))
60#define IRIX_DEV_MINOR(dev) ((int)((dev) & IRIX_DEV_MAXMIN))
63899e27 61#define IRIX_MKDEV(major,minor) ((xfs_dev_t)(((major) << IRIX_DEV_BITSMINOR) \
32181a02 62 | (minor&IRIX_DEV_MAXMIN)))
f97e76b0 63#define IRIX_DEV_TO_KDEVT(dev) makedev(IRIX_DEV_MAJOR(dev),IRIX_DEV_MINOR(dev))
32181a02 64
4a7c6ada
DC
65#ifndef min
66#define min(a,b) (((a)<(b))?(a):(b))
67#define max(a,b) (((a)>(b))?(a):(b))
68#endif
f8446e51 69#define max3(a,b,c) max(max(a, b), c)
4a7c6ada 70
2bba5a01 71/* If param.h doesn't provide it, i.e. for Android */
c9a90185
TT
72#ifndef NBBY
73#define NBBY 8
74#endif
75
5cfd2d5b
DC
76#ifdef DEBUG
77# define ASSERT(EX) assert(EX)
78#else
79# define ASSERT(EX) ((void) 0)
80#endif
81
d530e589
DW
82extern int platform_nproc(void);
83
c0e58015
DW
84#define NSEC_PER_SEC (1000000000ULL)
85#define NSEC_PER_USEC (1000ULL)
86
24b24fad
CM
87/* Simplified from version in include/linux/overflow.h */
88
89/*
05c716fb
DW
90 * Compute a*b+c, returning SIZE_MAX on overflow. Internal helper for
91 * struct_size() below.
92 */
24b24fad
CM
93static inline size_t __ab_c_size(size_t a, size_t b, size_t c)
94{
95 return (a * b) + c;
96}
97
98#define __must_be_array(a) (0)
99
100/**
101 * struct_size() - Calculate size of structure with trailing array.
102 * @p: Pointer to the structure.
103 * @member: Name of the array member.
104 * @count: Number of elements in the array.
105 *
106 * Calculates size of memory needed for structure @p followed by an
107 * array of @count number of @member elements.
108 *
109 * Return: number of bytes needed or SIZE_MAX on overflow.
110 */
111#define struct_size(p, member, count) \
112 __ab_c_size(count, \
113 sizeof(*(p)->member) + __must_be_array((p)->member), \
114 sizeof(*(p)))
115
135ce1ed
DW
116/*
117 * Add the pseudo keyword 'fallthrough' so case statement blocks
118 * must end with any of these keywords:
119 * break;
120 * fallthrough;
121 * continue;
122 * goto <label>;
123 * return [expression];
124 *
125 * gcc: https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html#Statement-Attributes
126 */
127#if defined __has_attribute
128# if __has_attribute(__fallthrough__)
129# define fallthrough __attribute__((__fallthrough__))
130# else
131# define fallthrough do {} while (0) /* fallthrough */
132# endif
133#else
134# define fallthrough do {} while (0) /* fallthrough */
135#endif
136
2bd0ea18 137#endif /* __XFS_PLATFORM_DEFS_H__ */