Protect C language extensions with two leading and trailing underscores This should make their usage safer against user macros.
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 100 101 102 103 104 105 106 107 108 109 110
diff --git a/configure.ac b/configure.ac
index 7769182..6b2bb6c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -87,7 +87,7 @@ AC_CACHE_CHECK(
[[
static int rc = 1;
static void init(int argc) { if (argc == 1) rc = 0; }
-void (*init_func)(int argc) __attribute__((section(".init_array"))) = init;
+void (*init_func)(int argc) __attribute__((__section__(".init_array"))) = init;
int main() { return rc; }
]]
)],
diff --git a/include/bsd/sys/cdefs.h b/include/bsd/sys/cdefs.h
index b5c8dad..c574fc2 100644
--- a/include/bsd/sys/cdefs.h
+++ b/include/bsd/sys/cdefs.h
@@ -86,9 +86,9 @@
#endif
#if LIBBSD_GCC_VERSION >= 0x0405
-#define LIBBSD_DEPRECATED(x) __attribute__((deprecated(x)))
+#define LIBBSD_DEPRECATED(x) __attribute__((__deprecated__(x)))
#elif LIBBSD_GCC_VERSION >= 0x0301
-#define LIBBSD_DEPRECATED(x) __attribute__((deprecated))
+#define LIBBSD_DEPRECATED(x) __attribute__((__deprecated__))
#else
#define LIBBSD_DEPRECATED(x)
#endif
@@ -137,7 +137,7 @@
#if 0
#ifndef __unused
# if LIBBSD_GCC_VERSION >= 0x0300
-# define __unused __attribute__((unused))
+# define __unused __attribute__((__unused__))
# else
# define __unused
# endif
@@ -146,7 +146,7 @@
#ifndef __printflike
# if LIBBSD_GCC_VERSION >= 0x0300
-# define __printflike(x, y) __attribute((format(printf, (x), (y))))
+# define __printflike(x, y) __attribute((__format__(__printf__, (x), (y))))
# else
# define __printflike(x, y)
# endif
@@ -202,7 +202,7 @@
#ifndef __containerof
# if LIBBSD_GCC_VERSION >= 0x0301
# define __containerof(x, s, m) ({ \
- const volatile __typeof(((s *)0)->m) *__x = (x); \
+ const volatile __typeof__(((s *)0)->m) *__x = (x); \
__DEQUALIFY(s *, (const volatile char *)__x - __offsetof(s, m)); \
})
# else
diff --git a/src/explicit_bzero.c b/src/explicit_bzero.c
index 3e33ca8..52a7517 100644
--- a/src/explicit_bzero.c
+++ b/src/explicit_bzero.c
@@ -6,7 +6,7 @@
#include <string.h>
-__attribute__((weak)) void
+__attribute__((__weak__)) void
__explicit_bzero_hook(void *buf, size_t len)
{
}
diff --git a/src/local-link.h b/src/local-link.h
index d518dcf..5f3c0fd 100644
--- a/src/local-link.h
+++ b/src/local-link.h
@@ -29,5 +29,5 @@
#define libbsd_link_warning(symbol, msg) \
static const char libbsd_emit_link_warning_##symbol[] \
- __attribute__((used,section(".gnu.warning." #symbol))) = msg;
+ __attribute__((__used__,__section__(".gnu.warning." #symbol))) = msg;
#endif
diff --git a/src/setproctitle.c b/src/setproctitle.c
index 038ac7d..6329bf4 100644
--- a/src/setproctitle.c
+++ b/src/setproctitle.c
@@ -287,9 +287,12 @@ __asm__(".symver setproctitle_impl,setproctitle@@LIBBSD_0.5");
* for code linking against that version, and change the default to use the
* new version, so that new code depends on the implemented version. */
#ifdef HAVE_TYPEOF
-extern typeof(setproctitle_impl) setproctitle_stub __attribute__((alias("setproctitle_impl")));
+extern __typeof__(setproctitle_impl)
+setproctitle_stub
+ __attribute__((__alias__("setproctitle_impl")));
#else
-void setproctitle_stub(const char *fmt, ...)
- __attribute__((alias("setproctitle_impl")));
+void
+setproctitle_stub(const char *fmt, ...)
+ __attribute__((__alias__("setproctitle_impl")));
#endif
__asm__(".symver setproctitle_stub,setproctitle@LIBBSD_0.2");
diff --git a/src/setproctitle_ctor.c b/src/setproctitle_ctor.c
index 9360774..2c5b6d0 100644
--- a/src/setproctitle_ctor.c
+++ b/src/setproctitle_ctor.c
@@ -49,4 +49,4 @@
* move them from .ctors to .init_array.
*/
void (*libbsd_init_func)(int argc, char *argv[], char *envp[])
- __attribute__((section(".init_array"))) = setproctitle_init;
+ __attribute__((__section__(".init_array"))) = setproctitle_init;