git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Erik Faye-Lund <kusmabite@googlemail.com>
To: git@vger.kernel.org
Cc: Erik Faye-Lund <kusmabite@googlemail.com>,
	Erik Faye-Lund <kusmabite@gmail.com>
Subject: [PATCH 2/2] remove NORETURN from function pointers
Date: Mon, 14 Sep 2009 12:16:10 +0200	[thread overview]
Message-ID: <1252923370-5768-2-git-send-email-kusmabite@gmail.com> (raw)
In-Reply-To: <1252923370-5768-1-git-send-email-kusmabite@gmail.com>

From: Erik Faye-Lund <kusmabite@googlemail.com>

Some compilers (including at least MSVC and ARM RVDS) supports
NORETURN on function declarations, but not on function pointers.

This patch makes it possible to define NORETURN for these compilers.

Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
---

__attribute__((noreturn)) is, according to the GCC documentation, about
two things: code generation (performance, really) and warnings.

On the warnings-side, we need to keep the code warning-free for
compilers who doesn't support noreturn anyway, so hiding potential
warnings through this mechanism is probably not a good idea in the
first place.

We still want the performance-side of it, though. However, the only
place this really makes a difference is to die and it's variants, since
they can potentially be called many times (or so it seems from the
compiler's point of view without a noreturn declaration).

The function pointers are only called once we're already exiting, and
they have only one potential call-site.

I hope this all makes sense ;)

 git-compat-util.h |    2 +-
 usage.c           |    6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/git-compat-util.h b/git-compat-util.h
index 5876d91..15fe08e 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -183,7 +183,7 @@ extern NORETURN void die_errno(const char *err, ...) __attribute__((format (prin
 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(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/usage.c b/usage.c
index b6aea45..18d7f43 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 void (*usage_routine)(const char *err) = usage_builtin;
+static 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(void (*routine)(const char *err, va_list params))
 {
 	die_routine = routine;
 }
-- 
1.6.4.msysgit.0.16.gd92d4.dirty

       reply	other threads:[~2009-09-14 10:17 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1252923370-5768-1-git-send-email-kusmabite@gmail.com>
2009-09-14 10:16 ` Erik Faye-Lund [this message]
2009-09-14 10:57   ` [PATCH 2/2] remove NORETURN from function pointers Jeff King
2009-09-14 11:40     ` Erik Faye-Lund
2009-09-14 11:56       ` Erik Faye-Lund
2009-09-14 12:04         ` Jeff King
2009-09-14 12:03       ` Jeff King
2009-09-14 12:32         ` Erik Faye-Lund
2009-09-14 12:44           ` Jeff King
2009-09-14 12:56             ` Erik Faye-Lund
2009-09-14 13:09           ` Johannes Sixt
2009-09-14 13:12             ` Erik Faye-Lund
2009-09-14 13:19               ` Johannes Sixt
2009-09-14 13:26                 ` Erik Faye-Lund
2009-09-14 13:37                   ` Johannes Sixt
2009-09-22 19:46                     ` Junio C Hamano
2009-09-25 13:56                       ` Erik Faye-Lund
2009-09-30 18:10                         ` Erik Faye-Lund

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1252923370-5768-2-git-send-email-kusmabite@gmail.com \
    --to=kusmabite@googlemail.com \
    --cc=git@vger.kernel.org \
    --cc=kusmabite@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).