Fix __must_check compile on older compilers
authorJens Axboe <jens.axboe@oracle.com>
Thu, 29 Mar 2007 07:33:03 +0000 (09:33 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Thu, 29 Mar 2007 07:33:03 +0000 (09:33 +0200)
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
compiler-gcc3.h [new file with mode: 0644]
compiler-gcc4.h [new file with mode: 0644]
compiler.h [new file with mode: 0644]
fio.h
os.h

diff --git a/compiler-gcc3.h b/compiler-gcc3.h
new file mode 100644 (file)
index 0000000..ab8ccc4
--- /dev/null
@@ -0,0 +1,8 @@
+#ifndef FIO_COMPILER_GCC3_H
+#define FIO_COMPILER_GCC3_H
+
+#if __GNUC_MINOR__ >= 4
+#define __must_check           __attribute__((warn_unused_result))
+#endif
+
+#endif
diff --git a/compiler-gcc4.h b/compiler-gcc4.h
new file mode 100644 (file)
index 0000000..bb9cc7c
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef FIO_COMPILER_GCC4_H
+#define FIO_COMPILER_GCC4_H
+
+#define __must_check           __attribute__((warn_unused_result))
+
+#endif
diff --git a/compiler.h b/compiler.h
new file mode 100644 (file)
index 0000000..0d17ae1
--- /dev/null
@@ -0,0 +1,12 @@
+#ifndef FIO_COMPILER_H
+#define FIO_COMPILER_H
+
+#if __GNUC__ >= 4
+#include "compiler-gcc4.h"
+#elif __GNUC == 3
+#include "compiler-gcc3.h"
+#else
+#error Compiler too old, need gcc at least gcc 3.x
+#endif
+
+#endif
diff --git a/fio.h b/fio.h
index d8911ef5db8d19ef92804287a3f726cab0f82203..92e6a88d66881378eb4d6d407e158775fa11e097 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -13,6 +13,7 @@
 #include <string.h>
 #include <getopt.h>
 
 #include <string.h>
 #include <getopt.h>
 
+#include "compiler.h"
 #include "list.h"
 #include "rbtree.h"
 #include "md5.h"
 #include "list.h"
 #include "rbtree.h"
 #include "md5.h"
diff --git a/os.h b/os.h
index 3f83905d5b31f4adbf5a7f1c74db8b2a444049ef..823843a3043c680f55b1452c5a9416768f1dc9fc 100644 (file)
--- a/os.h
+++ b/os.h
 #endif
 #endif
 
 #endif
 #endif
 
-#if __GNUC__ < 3
-#define __must_check
-#else
-#define __must_check                   __attribute__((warn_unused_result))
-#endif
-
 #endif
 #endif