X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/94eba9d3c32077aa8548f2132cc43d6a0679272a..63621a81d16ab743de6b57d47578a9a2c670ad22:/h/mh.h diff --git a/h/mh.h b/h/mh.h index 6d6bc40c..069d9cbe 100644 --- a/h/mh.h +++ b/h/mh.h @@ -22,31 +22,15 @@ */ #define NMH_BUFSIZ max(BUFSIZ, 8192) -#ifndef FALSE -#define FALSE false -#endif -#ifndef TRUE -#define TRUE true -#endif -typedef unsigned char boolean; /* not int so we can pack in a structure */ - /* If we're using gcc then tell it extra information so it can do more * compile-time checks. */ #if __GNUC__ > 2 -#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) -#define ALLOC_SIZE(...) __attribute__((alloc_size(__VA_ARGS__))) -#define CHECK_PRINTF(fmt, arg) __attribute__((format(printf, fmt, arg))) -#else /* gcc < 4.3.0 */ -#define ALLOC_SIZE(...) -#define CHECK_PRINTF(fmt, arg) -#endif /* gcc < 4.3.0 */ #define NORETURN __attribute__((__noreturn__)) #define CONST __attribute__((const)) #define MALLOC __attribute__((malloc)) #define NONNULL(...) __attribute__((nonnull(__VA_ARGS__))) #define PURE __attribute__((pure)) #define ENDNULL __attribute__((sentinel)) -#define NMH_UNUSED(i) (void) i #else #define NORETURN #define CHECK_PRINTF(fmt, arg) @@ -56,9 +40,19 @@ typedef unsigned char boolean; /* not int so we can pack in a structure */ #define NONNULL(...) #define PURE #define ENDNULL -#define NMH_UNUSED(i) i #endif +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) +#define ALLOC_SIZE(...) __attribute__((alloc_size(__VA_ARGS__))) +#define CHECK_PRINTF(fmt, arg) __attribute__((format(printf, fmt, arg))) +#else +#define ALLOC_SIZE(...) +#define CHECK_PRINTF(fmt, arg) +#endif + +/* Silence the compiler's "unused variable" warning. */ +#define NMH_UNUSED(i) (void)i + /* DIM gives the number of elements in the one-dimensional array a. */ #define DIM(a) (sizeof (a) / sizeof (*(a)))