The macOS libc headers use `__attribute__((noreturn))` rather than
`__attribute__((__noreturn__))`, so toybox's `noreturn` macro trips them
up. Since we already have a variety of uses of `__attribute__` that
aren't guarded in this way, let's do the same here.
---
 lib/lib.h         | 10 +++++-----
 lib/portability.h |  2 --
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/lib/lib.h b/lib/lib.h
index e630bbc..8a45e08 100644
--- a/lib/lib.h
+++ b/lib/lib.h
@@ -114,8 +114,8 @@ void show_help(FILE *out);
 // xwrap.c
 void xstrncpy(char *dest, char *src, size_t size);
 void xstrncat(char *dest, char *src, size_t size);
-void _xexit(void) noreturn;
-void xexit(void) noreturn;
+void _xexit(void) __attribute__((__noreturn__));
+void xexit(void) __attribute__((__noreturn__));
 void *xmmap(void *addr, size_t length, int prot, int flags, int fd, off_t off);
 void *xmalloc(size_t size);
 void *xzalloc(size_t size);
@@ -183,9 +183,9 @@ void xsignal(int signal, void *handler);
 void verror_msg(char *msg, int err, va_list va);
 void error_msg(char *msg, ...) printf_format;
 void perror_msg(char *msg, ...) printf_format;
-void error_exit(char *msg, ...) printf_format noreturn;
-void perror_exit(char *msg, ...) printf_format noreturn;
-void help_exit(char *msg, ...) printf_format noreturn;
+void error_exit(char *msg, ...) printf_format __attribute__((__noreturn__));
+void perror_exit(char *msg, ...) printf_format __attribute__((__noreturn__));
+void help_exit(char *msg, ...) printf_format __attribute__((__noreturn__));
 void error_msg_raw(char *msg);
 void perror_msg_raw(char *msg);
 void error_exit_raw(char *msg);
diff --git a/lib/portability.h b/lib/portability.h
index c2b29b6..c76beef 100644
--- a/lib/portability.h
+++ b/lib/portability.h
@@ -10,10 +10,8 @@
 // Test for gcc (using compiler builtin #define)

 #ifdef __GNUC__
-#define noreturn __attribute__((noreturn))
 #define printf_format __attribute__((format(printf, 1, 2)))
 #else
-#define noreturn
 #define printf_format
 #endif

-- 
2.20.0.rc0.387.gc7a69e6b6c-goog
From 7c32bea6934a7007d53f76e18b14b6c901f1b99e Mon Sep 17 00:00:00 2001
From: Elliott Hughes <e...@google.com>
Date: Wed, 28 Nov 2018 15:38:40 -0800
Subject: [PATCH] macOS: noreturn.

The macOS libc headers use `__attribute__((noreturn))` rather than
`__attribute__((__noreturn__))`, so toybox's `noreturn` macro trips them
up. Since we already have a variety of uses of `__attribute__` that
aren't guarded in this way, let's do the same here.
---
 lib/lib.h         | 10 +++++-----
 lib/portability.h |  2 --
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/lib/lib.h b/lib/lib.h
index e630bbc..8a45e08 100644
--- a/lib/lib.h
+++ b/lib/lib.h
@@ -114,8 +114,8 @@ void show_help(FILE *out);
 // xwrap.c
 void xstrncpy(char *dest, char *src, size_t size);
 void xstrncat(char *dest, char *src, size_t size);
-void _xexit(void) noreturn;
-void xexit(void) noreturn;
+void _xexit(void) __attribute__((__noreturn__));
+void xexit(void) __attribute__((__noreturn__));
 void *xmmap(void *addr, size_t length, int prot, int flags, int fd, off_t off);
 void *xmalloc(size_t size);
 void *xzalloc(size_t size);
@@ -183,9 +183,9 @@ void xsignal(int signal, void *handler);
 void verror_msg(char *msg, int err, va_list va);
 void error_msg(char *msg, ...) printf_format;
 void perror_msg(char *msg, ...) printf_format;
-void error_exit(char *msg, ...) printf_format noreturn;
-void perror_exit(char *msg, ...) printf_format noreturn;
-void help_exit(char *msg, ...) printf_format noreturn;
+void error_exit(char *msg, ...) printf_format __attribute__((__noreturn__));
+void perror_exit(char *msg, ...) printf_format __attribute__((__noreturn__));
+void help_exit(char *msg, ...) printf_format __attribute__((__noreturn__));
 void error_msg_raw(char *msg);
 void perror_msg_raw(char *msg);
 void error_exit_raw(char *msg);
diff --git a/lib/portability.h b/lib/portability.h
index c2b29b6..c76beef 100644
--- a/lib/portability.h
+++ b/lib/portability.h
@@ -10,10 +10,8 @@
 // Test for gcc (using compiler builtin #define)
 
 #ifdef __GNUC__
-#define noreturn	__attribute__((noreturn))
 #define printf_format	__attribute__((format(printf, 1, 2)))
 #else
-#define noreturn
 #define printf_format
 #endif
 
-- 
2.20.0.rc0.387.gc7a69e6b6c-goog

_______________________________________________
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to