* [PATCH 1/2] increase portability of NORETURN declarations
@ 2009-09-30 18:05 Erik Faye-Lund
2009-09-30 18:05 ` [PATCH 2/2] add NORETURN_PTR for function pointers Erik Faye-Lund
0 siblings, 1 reply; 6+ messages in thread
From: Erik Faye-Lund @ 2009-09-30 18:05 UTC (permalink / raw)
To: git; +Cc: msysgit, gitster, Erik Faye-Lund
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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] add NORETURN_PTR for function pointers
2009-09-30 18:05 [PATCH 1/2] increase portability of NORETURN declarations Erik Faye-Lund
@ 2009-09-30 18:05 ` Erik Faye-Lund
2009-10-01 8:17 ` Jeff King
0 siblings, 1 reply; 6+ messages in thread
From: Erik Faye-Lund @ 2009-09-30 18:05 UTC (permalink / raw)
To: git; +Cc: msysgit, gitster, Erik Faye-Lund
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,
by splitting the NORETURN macro into two - one for function
declarations and one for function pointers.
Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
---
git-compat-util.h | 4 +++-
usage.c | 6 +++---
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/git-compat-util.h b/git-compat-util.h
index 33dd4f3..ac7cc66 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -169,8 +169,10 @@ extern char *gitbasename(char *);
#ifdef __GNUC__
#define NORETURN __attribute__((__noreturn__))
+#define NORETURN_PTR __attribute__((__noreturn__))
#else
#define NORETURN
+#define NORETURN_PTR
#ifndef __attribute__
#define __attribute__(x)
#endif
@@ -183,7 +185,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(NORETURN void (*routine)(const char *err, va_list params));
+extern void set_die_routine(NORETURN_PTR 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 0555ce6..c488f3a 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 NORETURN void (*usage_routine)(const char *err) = usage_builtin;
-static NORETURN void (*die_routine)(const char *err, va_list params) = die_builtin;
+static NORETURN_PTR void (*usage_routine)(const char *err) = usage_builtin;
+static NORETURN_PTR 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(NORETURN void (*routine)(const char *err, va_list params))
+void set_die_routine(NORETURN_PTR void (*routine)(const char *err, va_list params))
{
die_routine = routine;
}
--
1.6.4.msysgit.0.17.g82372.dirty
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] add NORETURN_PTR for function pointers
2009-09-30 18:05 ` [PATCH 2/2] add NORETURN_PTR for function pointers Erik Faye-Lund
@ 2009-10-01 8:17 ` Jeff King
2009-10-01 16:57 ` Erik Faye-Lund
0 siblings, 1 reply; 6+ messages in thread
From: Jeff King @ 2009-10-01 8:17 UTC (permalink / raw)
To: Erik Faye-Lund; +Cc: Shawn O. Pearce, git, msysgit, gitster, Erik Faye-Lund
On Wed, Sep 30, 2009 at 06:05:50PM +0000, Erik Faye-Lund wrote:
> 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,
> by splitting the NORETURN macro into two - one for function
> declarations and one for function pointers.
Thanks, this version and (your 1/2) both look sane to me. The only thing
missing are some Makefile knobs to tweak this, but I will assume that
will come as part of a later MSVC-compatibility series.
Shawn, this can go straight to 'next', if not 'master'. The changes
should be a no-op for most platforms. The only danger would be if there
is some platform that doesn't like their NORETURN magic at the front of
the function declaration. But we only define it by default for __GNUC__,
so I suspect we're safe.
In my tree as ef/msvc-noreturn.
-Peff
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] add NORETURN_PTR for function pointers
2009-10-01 8:17 ` Jeff King
@ 2009-10-01 16:57 ` Erik Faye-Lund
2009-10-02 0:43 ` Jeff King
0 siblings, 1 reply; 6+ messages in thread
From: Erik Faye-Lund @ 2009-10-01 16:57 UTC (permalink / raw)
To: Jeff King; +Cc: Shawn O. Pearce, git, msysgit, gitster, Erik Faye-Lund
On Thu, Oct 1, 2009 at 1:17 AM, Jeff King <peff@peff.net> wrote:
> Thanks, this version and (your 1/2) both look sane to me. The only thing
> missing are some Makefile knobs to tweak this, but I will assume that
> will come as part of a later MSVC-compatibility series.
Thanks for reviewing :)
I sent an additional patch to the msysgit mailing-list that defines
NORETURN for MSVC, but I think it's better to keep it out of git.git
for a little while. There's no Makefile-knobs, it checks for _MSC_VER
(similar to what's done for GCC).
--
Erik "kusma" Faye-Lund
kusmabite@gmail.com
(+47) 986 59 656
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] add NORETURN_PTR for function pointers
2009-10-01 16:57 ` Erik Faye-Lund
@ 2009-10-02 0:43 ` Jeff King
0 siblings, 0 replies; 6+ messages in thread
From: Jeff King @ 2009-10-02 0:43 UTC (permalink / raw)
To: Erik Faye-Lund; +Cc: Shawn O. Pearce, git, msysgit, gitster, Erik Faye-Lund
On Thu, Oct 01, 2009 at 09:57:12AM -0700, Erik Faye-Lund wrote:
> On Thu, Oct 1, 2009 at 1:17 AM, Jeff King <peff@peff.net> wrote:
> > Thanks, this version and (your 1/2) both look sane to me. The only thing
> > missing are some Makefile knobs to tweak this, but I will assume that
> > will come as part of a later MSVC-compatibility series.
>
> Thanks for reviewing :)
>
> I sent an additional patch to the msysgit mailing-list that defines
> NORETURN for MSVC, but I think it's better to keep it out of git.git
> for a little while. There's no Makefile-knobs, it checks for _MSC_VER
> (similar to what's done for GCC).
That sounds good. Thanks.
-Peff
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] increase portability of NORETURN declarations
@ 2009-09-14 11:49 Erik Faye-Lund
0 siblings, 0 replies; 6+ messages in thread
From: Erik Faye-Lund @ 2009-09-14 11:49 UTC (permalink / raw)
To: git; +Cc: Erik Faye-Lund
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 for those compilers.
Signed-off-by: Erik Faye-Lund <kusmab...@gmail.com>
---
This patch requires specifying "-C 2" to "git am" to apply to the
current maint(7fb6bcf), but I suspect that it's not really needed
there. Supporting new compilers is going to require additional
patching anyway.
git-compat-util.h | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/git-compat-util.h b/git-compat-util.h
index e5e9f39..5876d91 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -177,9 +177,9 @@ extern char *gitbasename(char *);
#include "compat/bswap.h"
/* 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)));
--
1.6.4.msysgit.0.16.gd92d4.dirty
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-10-02 0:43 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-30 18:05 [PATCH 1/2] increase portability of NORETURN declarations Erik Faye-Lund
2009-09-30 18:05 ` [PATCH 2/2] add NORETURN_PTR for function pointers Erik Faye-Lund
2009-10-01 8:17 ` Jeff King
2009-10-01 16:57 ` Erik Faye-Lund
2009-10-02 0:43 ` Jeff King
-- strict thread matches above, loose matches on Subject: below --
2009-09-14 11:49 [PATCH 1/2] increase portability of NORETURN declarations Erik Faye-Lund
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).