git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/2] increase portability of NORETURN declarations

From
Erik Faye-Lund <kusmabite@googlemail.com>
Date
Sep 30, 2009, 18:05 UTC
Message-ID
<1254333950-2440-1-git-send-email-kusmabite@gmail.com>

Some compilers (including at least MSVC) supports NORETURN on function declarations, but only before the function-name.

This patch makes it possible to define NORETURN to something meaningful for those compilers.

Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
---
 git-compat-util.h |    8 ++++----
 index-pack.c      |    4 ++--
 usage.c           |    6 +++---
 3 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/git-compat-util.h b/git-compat-util.h
index 9f941e4..33dd4f3 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -177,13 +177,13 @@ extern char *gitbasename(char *);
 #endif
 
 /* General helper functions */
-extern void usage(const char *err) NORETURN;
-extern void die(const char *err, ...) NORETURN __attribute__((format (printf, 1, 2)));
-extern void die_errno(const char *err, ...) NORETURN __attribute__((format (printf, 1, 2)));
+extern NORETURN void usage(const char *err);
+extern NORETURN void die(const char *err, ...) __attribute__((format (printf, 1, 2)));
+extern NORETURN void die_errno(const char *err, ...) __attribute__((format (printf, 1, 2)));
 extern int error(const char *err, ...) __attribute__((format (printf, 1, 2)));
 extern void warning(const char *err, ...) __attribute__((format (printf, 1, 2)));
 
-extern void set_die_routine(void (*routine)(const char *err, va_list params) NORETURN);
+extern void set_die_routine(NORETURN void (*routine)(const char *err, va_list params));
 
 extern int prefixcmp(const char *str, const char *prefix);
 extern time_t tm_to_time_t(const struct tm *tm);
diff --git a/index-pack.c b/index-pack.c
index 340074f..b4f8278 100644
--- a/index-pack.c
+++ b/index-pack.c
@@ -206,8 +206,8 @@ static void parse_pack_header(void)
 	use(sizeof(struct pack_header));
 }
 
-static void bad_object(unsigned long offset, const char *format,
-		       ...) NORETURN __attribute__((format (printf, 2, 3)));
+static NORETURN void bad_object(unsigned long offset, const char *format,
+		       ...) __attribute__((format (printf, 2, 3)));
 
 static void bad_object(unsigned long offset, const char *format, ...)
 {
diff --git a/usage.c b/usage.c
index b6aea45..0555ce6 100644
--- a/usage.c
+++ b/usage.c
@@ -36,12 +36,12 @@ static void warn_builtin(const char *warn, va_list params)
 
 /* If we are in a dlopen()ed .so write to a global variable would segfault
  * (ugh), so keep things static. */
-static void (*usage_routine)(const char *err) NORETURN = usage_builtin;
-static void (*die_routine)(const char *err, va_list params) NORETURN = die_builtin;
+static NORETURN void (*usage_routine)(const char *err) = usage_builtin;
+static NORETURN void (*die_routine)(const char *err, va_list params) = die_builtin;
 static void (*error_routine)(const char *err, va_list params) = error_builtin;
 static void (*warn_routine)(const char *err, va_list params) = warn_builtin;
 
-void set_die_routine(void (*routine)(const char *err, va_list params) NORETURN)
+void set_die_routine(NORETURN void (*routine)(const char *err, va_list params))
 {
 	die_routine = routine;
 }
-- 
1.6.4.msysgit.0.17.g82372.dirty
Next: Erik Faye-Lund
Message 1 of 5 in “increase portability of NORETURN declarations”
  1. 1/2 increase portability of NORETURN declarationsErik Faye-Lund, Sep 30, 2009
  2. 2/2 add NORETURN_PTR for function pointersErik Faye-Lund, Sep 30, 2009
  3. Jeff KingOct 1, 2009
  4. Erik Faye-LundOct 1, 2009
  5. Jeff KingOct 2, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.