git » libfiu » commit 4d8d9cd

preload/posix: clang supports constructor priorities

author Alberto Bertogli
2010-03-16 19:41:16 UTC
committer Alberto Bertogli
2010-03-16 19:43:28 UTC
parent de20a9c7c3a0513d16236bf4e5626b55843eb50d

preload/posix: clang supports constructor priorities

The clang compiler supports constructor priorities. This patch adds a check
for it, so we build with constructor priorities when it is being used.

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>

preload/posix/codegen.h +11 -5

diff --git a/preload/posix/codegen.h b/preload/posix/codegen.h
index 6a3444e..5384e2e 100644
--- a/preload/posix/codegen.h
+++ b/preload/posix/codegen.h
@@ -13,11 +13,17 @@ void _fiu_init(void);
 /* Recursion counter, per-thread */
 extern int __thread _fiu_called;
 
-/* GCC >= 4.3 supports constructor priorities only on some platforms. Since we
- * don't rely on them, but use them for clarity purposes, use a macro so
- * libfiu builds on systems where they're not supported. */
-#if (defined __linux__) && (defined __GNUC__) \
-	&& __GNUC__ >= 4 && __GNUC_MINOR__ >= 3
+/* Some compilers support constructor priorities. Since we don't rely on them,
+ * but use them for clarity purposes, use a macro so libfiu builds on systems
+ * where they're not supported.
+ * Compilers that are known to support constructor priorities:
+ *  - GCC >= 4.3 on Linux
+ *  - clang as of 2010-03-14
+ */
+#if \
+	( (defined __linux__) && (defined __GNUC__) \
+		&& __GNUC__ >= 4 && __GNUC_MINOR__ >= 3 ) \
+	|| (defined __clang__)
   #define constructor_attr(prio) __attribute__((constructor(prio)))
 #else
   #define NO_CONSTRUCTOR_PRIORITIES 1