Move some macros to cdefs.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
diff --git a/ChangeLog b/ChangeLog
index 7e04cd6..08c0fcd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2006-02-14 Guillem Jover <guillem@debian.org>
+ * include/bsd/bsd.h (setproctitle, __dead2, __unused, __printflike)
+ (__FBSDID): Moved to ...
+ * include/bsd/cdefs.h: ... here.
+ (__unused, __printflike) [__GNUC__]: Use proper __attribute__.
+ * Makefile (LIB_INCLUDES): Add 'cdefs.h'.
+
+2006-02-14 Guillem Jover <guillem@debian.org>
+
* arc4random.c: Move to ...
* src/arc4random.c: ... here.
* bsd_getopt.c: Move to ...
diff --git a/Makefile b/Makefile
index 3e6b2cc..eea93c2 100644
--- a/Makefile
+++ b/Makefile
@@ -9,7 +9,7 @@ LIB_SRCS := arc4random.c bsd_getopt.c err.c fgetln.c inet_net_pton.c \
LIB_SRCS := $(patsubst %,src/%,$(LIB_SRCS))
LIB_INCLUDES := err.h getopt.h ip_icmp.h random.h queue.h md5.h string.h \
- bsd.h stdlib.h
+ bsd.h cdefs.h stdlib.h
LIB_INCLUDES := $(patsubst %,include/bsd/%,$(LIB_INCLUDES))
LIB_MANS := arc4random.3 strlcpy.3 fgetln.3 fmtcheck.3
diff --git a/include/bsd/bsd.h b/include/bsd/bsd.h
index 6dabec4..57690a1 100644
--- a/include/bsd/bsd.h
+++ b/include/bsd/bsd.h
@@ -2,22 +2,10 @@
#define LIBBSD_H
/*
- * Generic definitions.
- */
-
-#define setproctitle(fmt, args...)
-
-#define __dead2
-#define __unused
-#define __printflike(x,y)
-#define __FBSDID(x)
-
-#include <sys/cdefs.h>
-
-/*
* Include all bsd compat headers.
*/
+#include <bsd/cdefs.h>
#include <bsd/random.h>
#include <bsd/string.h>
#include <bsd/queue.h>
diff --git a/include/bsd/cdefs.h b/include/bsd/cdefs.h
new file mode 100644
index 0000000..a23e15e
--- /dev/null
+++ b/include/bsd/cdefs.h
@@ -0,0 +1,34 @@
+#ifndef LIBBSD_CDEFS_H
+#define LIBBSD_CDEFS_H
+
+#include <sys/cdefs.h>
+
+#ifndef setproctitle
+# define setproctitle(fmt, args...)
+#endif
+
+#ifndef __dead2
+# define __dead2
+#endif
+
+#ifndef __unused
+# ifdef __GNUC__
+# define __unused __attribute__((unused))
+# else
+# define __unused
+# endif
+#endif
+
+#ifndef __printflike
+# ifdef __GNUC__
+# define __printflike(x, y) __attribute((format(printf, (x), (y))))
+# else
+# define __printflike(x, y)
+# endif
+#endif
+
+#ifndef __FBSDID
+# define __FBSDID(x)
+#endif
+
+#endif