diff options
Diffstat (limited to 'libsimple.h')
| -rw-r--r-- | libsimple.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/libsimple.h b/libsimple.h index 6d1867e..6e5f170 100644 --- a/libsimple.h +++ b/libsimple.h @@ -125,6 +125,40 @@ #endif +/* TODO doc, man, since 1.8, check which are supported by clang */ +#if defined(__GNUC__) && !defined(__clang__) +# define LIBSIMPLE_PURE __attribute__((pure)) +# define LIBSIMPLE_CONST __attribute__((const)) +# define LIBSIMPLE_NONNULL_RETURN __attribute__((returns_nonnull)) +# define LIBSIMPLE_USE_RETURN __attribute__((warn_unused_result)) +# define LIBSIMPLE_NONNULL_ARGS(...) __attribute__((nonnull__(__VA_ARGS__))) +# define LIBSIMPLE_NO_NULL_ARGS __attribute__((nonnull)) +# define LIBSIMPLE_RETURNS_TWICE __attribute__((returns_twice)) +# define LIBSIMPLE_UNREACHABLE __builtin_unreachable() +# define LIBSIMPLE_EXPECT(V, LIKELY) __builtin_expect((V), (LIKELY)) +# define LIBSIMPLE_ALIGNED(P) __builtin_assume_aligned((P), sizeof(*(P))) +# define LIBSIMPLE_ALIGNED_TO(P, A) __builtin_assume_aligned((P), (A)) +# define LIBSIMPLE_MISALIGNED(P, OFF) __builtin_assume_aligned((P), sizeof(*(P)), 0) +# define LIBSIMPLE_MISALIGNED_FROM(P, A, OFF) __builtin_assume_aligned((P), (A), 0) +#else +# define LIBSIMPLE_PURE +# define LIBSIMPLE_CONST +# define LIBSIMPLE_NONNULL_RETURN +# define LIBSIMPLE_USE_RETURN +# define LIBSIMPLE_NONNULL_ARGS(...) +# define LIBSIMPLE_NO_NULL_ARGS +# define LIBSIMPLE_RETURNS_TWICE +# define LIBSIMPLE_UNREACHABLE abort() +# define LIBSIMPLE_EXPECT(V, LIKELY) (V) +# define LIBSIMPLE_ALIGNED(P) (P) +# define LIBSIMPLE_ALIGNED_TO(P, A) (P) +# define LIBSIMPLE_MISALIGNED(P, OFF) (P) +# define LIBSIMPLE_MISALIGNED_FROM(P, A, OFF) (P) +#endif +#define LIBSIMPLE_LIKELY(V) LIBSIMPLE_EXPECT(!!(V), 1) +#define LIBSIMPLE_UNLIKELY(V) LIBSIMPLE_EXPECT(!!(V), 0) + + #include "libsimple/overflow.h" #include "libsimple/printf.h" #include "libsimple/definitions.h" |
