aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2018-09-05 13:56:24 -0700
committerEric Biggers <ebiggers@google.com>2018-09-05 13:56:24 -0700
commitb3a3a23631398d65501d51ef249e967cca004b72 (patch)
tree7686e2bed4f3b0e6c26462895ae4a25bf5c7ae6d
parent8957d75e7f6c86fc44b0fba637908e2da88a46f0 (diff)
downloadfsverity-utils-b3a3a23631398d65501d51ef249e967cca004b72.tar.gz
util.h: skip defining attribute macros if already defined
Supposedly this fixes a compiler warning when building with Bionic as libc, since Bionic's headers define __noreturn already. Signed-off-by: Eric Biggers <ebiggers@google.com>
-rw-r--r--util.h23
1 files changed, 16 insertions, 7 deletions
diff --git a/util.h b/util.h
index 049d770..c4cbe48 100644
--- a/util.h
+++ b/util.h
@@ -17,17 +17,26 @@ typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
-#ifdef __CHECKER__
-# define __force __attribute__((force))
-#else
-# define __force
+#ifndef __force
+# ifdef __CHECKER__
+# define __force __attribute__((force))
+# else
+# define __force
+# endif
#endif
-#define __printf(fmt_idx, vargs_idx) \
+#ifndef __printf
+# define __printf(fmt_idx, vargs_idx) \
__attribute__((format(printf, fmt_idx, vargs_idx)))
+#endif
-#define __noreturn __attribute__((noreturn))
-#define __cold __attribute__((cold))
+#ifndef __noreturn
+# define __noreturn __attribute__((noreturn))
+#endif
+
+#ifndef __cold
+# define __cold __attribute__((cold))
+#endif
#define min(a, b) ({ \
__typeof__(a) _a = (a); \