1 #ifndef INCLUDE_compat_h__
2 #define INCLUDE_compat_h__
5 * CHAR_BIT really should be 8 on all systems we care about
12 # define COMPAT_WORDSIZE __WORDSIZE
14 # define COMPAT_WORDSIZE (sizeof(void *) * CHAR_BIT)
17 /* runtime detection of endianness with GNU style macros */
18 #define COMPAT_LITTLE_ENDIAN 1234
19 #define COMPAT_BIG_ENDIAN 4321
21 static inline unsigned int endianness(void)
26 if (__BYTE_ORDER
== COMPAT_LITTLE_ENDIAN
|| __BYTE_ORDER
== COMPAT_BIG_ENDIAN
)
28 #elif defined(_BYTE_ORDER)
29 if (_BYTE_ORDER
== COMPAT_LITTLE_ENDIAN
|| _BYTE_ORDER
== COMPAT_BIG_ENDIAN
)
31 #endif /* __BYTE_ORDER */
33 if (((char *)&i
)[0] == 1)
34 return COMPAT_LITTLE_ENDIAN
;
36 return COMPAT_BIG_ENDIAN
;
40 extern void *memrchr(const void *s
, int c
, size_t n
);
45 extern int asprintf(char **strp
, const char *fmt
, ...);
46 extern int vasprintf(char **strp
, const char *fmt
, va_list ap
);
49 #ifndef NEBATTR_CHECK_ALERT
50 # define NEBATTR_CHECK_ALERT 1
53 #endif /* INCLUDE_compat_h__ */