summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Dragan <bulk88@hotmail.com>2012-10-10 17:23:27 -0400
committerKarl Williamson <public@khwilliamson.com>2012-10-10 17:09:05 -0600
commit98c015b7a9b5140b2750b25518eb68b5024d7652 (patch)
tree8024448b612f5a6ed32e14adc9d2fd6916668b54
parent451f421fe4742646fa2efbed0f45a19f0713d00f (diff)
downloadperl-98c015b7a9b5140b2750b25518eb68b5024d7652.tar.gz
fix C++ builds broken by cdc4a174060
In commit cdc4a174060 static noreturn function, on a C++ build, (specific example, GCC ) got a post preprocessor prototype of "extern "C" static void S_fn_doesnt_return(". GCC generates a compile error if "extern "C"" and static used together. Plain C build were not affected. This commit fixed the problem by creating 2 new static exclusive macros, so extern "C" does not wind up on statics in a C++ build. The macros allow enough flexibility so any compiler/platform that needs a noreturn declaration specifier instead of a noreturn function attribute can have one.
-rw-r--r--perl.h14
-rw-r--r--proto.h16
-rwxr-xr-xregen/embed.pl11
-rw-r--r--win32/win32.h5
4 files changed, 34 insertions, 12 deletions
diff --git a/perl.h b/perl.h
index bf96a8ea04..dfa0a4a426 100644
--- a/perl.h
+++ b/perl.h
@@ -5017,6 +5017,20 @@ struct tempsym; /* defined in pp_pack.c */
# define PERL_CALLCONV_NO_RET PERL_CALLCONV
#endif
+/* PERL_STATIC_NO_RET is supposed to be equivalent to STATIC on builds that
+ dont have a noreturn as a declaration specifier
+*/
+#ifndef PERL_STATIC_NO_RET
+# define PERL_STATIC_NO_RET STATIC
+#endif
+/* PERL_STATIC_NO_RET is supposed to be equivalent to PERL_STATIC_INLINE on
+ builds that dont have a noreturn as a declaration specifier
+*/
+#ifndef PERL_STATIC_INLINE_NO_RET
+# define PERL_STATIC_INLINE_NO_RET PERL_STATIC_INLINE
+#endif
+
+
#undef PERL_CKDEF
#undef PERL_PPDEF
#define PERL_CKDEF(s) PERL_CALLCONV OP *s (pTHX_ OP *o);
diff --git a/proto.h b/proto.h
index 01d1e1284a..e290c47502 100644
--- a/proto.h
+++ b/proto.h
@@ -5626,7 +5626,7 @@ STATIC void S_hv_magic_check(HV *hv, bool *needs_copy, bool *needs_store)
#define PERL_ARGS_ASSERT_HV_MAGIC_CHECK \
assert(hv); assert(needs_copy); assert(needs_store)
-PERL_CALLCONV_NO_RET STATIC void S_hv_notallowed(pTHX_ int flags, const char *key, I32 klen, const char *msg)
+PERL_STATIC_NO_RET void S_hv_notallowed(pTHX_ int flags, const char *key, I32 klen, const char *msg)
__attribute__noreturn__
__attribute__nonnull__(pTHX_2)
__attribute__nonnull__(pTHX_4);
@@ -5992,10 +5992,10 @@ STATIC SV* S_mayberelocate(pTHX_ const char *const dir, STRLEN len, U32 flags)
#define PERL_ARGS_ASSERT_MAYBERELOCATE \
assert(dir)
-PERL_CALLCONV_NO_RET STATIC void S_minus_v(pTHX)
+PERL_STATIC_NO_RET void S_minus_v(pTHX)
__attribute__noreturn__;
-PERL_CALLCONV_NO_RET STATIC void S_my_exit_jump(pTHX)
+PERL_STATIC_NO_RET void S_my_exit_jump(pTHX)
__attribute__noreturn__;
STATIC void S_nuke_stacks(pTHX);
@@ -6006,10 +6006,10 @@ STATIC PerlIO * S_open_script(pTHX_ const char *scriptname, bool dosearch, bool
assert(scriptname); assert(suidscript)
STATIC void* S_parse_body(pTHX_ char **env, XSINIT_t xsinit);
-PERL_CALLCONV_NO_RET STATIC void S_run_body(pTHX_ I32 oldscope)
+PERL_STATIC_NO_RET void S_run_body(pTHX_ I32 oldscope)
__attribute__noreturn__;
-PERL_CALLCONV_NO_RET STATIC void S_usage(pTHX)
+PERL_STATIC_NO_RET void S_usage(pTHX)
__attribute__noreturn__;
#endif
@@ -6522,7 +6522,7 @@ STATIC char * S_nextchar(pTHX_ struct RExC_state_t *pRExC_state)
#define PERL_ARGS_ASSERT_NEXTCHAR \
assert(pRExC_state)
-PERL_CALLCONV_NO_RET STATIC void S_re_croak2(pTHX_ const char* pat1, const char* pat2, ...)
+PERL_STATIC_NO_RET void S_re_croak2(pTHX_ const char* pat1, const char* pat2, ...)
__attribute__noreturn__
__attribute__nonnull__(pTHX_1)
__attribute__nonnull__(pTHX_2);
@@ -7090,7 +7090,7 @@ STATIC I32 S_lop(pTHX_ I32 f, int x, char *s)
#define PERL_ARGS_ASSERT_LOP \
assert(s)
-PERL_CALLCONV_NO_RET STATIC void S_missingterm(pTHX_ char *s)
+PERL_STATIC_NO_RET void S_missingterm(pTHX_ char *s)
__attribute__noreturn__;
STATIC SV* S_new_constant(pTHX_ const char *s, STRLEN len, const char *key, STRLEN keylen, SV *sv, SV *pv, const char *type, STRLEN typelen)
@@ -7297,7 +7297,7 @@ STATIC SV * S_with_queued_errors(pTHX_ SV *ex)
#define PERL_ARGS_ASSERT_WITH_QUEUED_ERRORS \
assert(ex)
-PERL_CALLCONV_NO_RET STATIC char * S_write_no_mem(pTHX)
+PERL_STATIC_NO_RET char * S_write_no_mem(pTHX)
__attribute__noreturn__;
# if defined(PERL_MEM_LOG) && !defined(PERL_MEM_LOG_NOIMPL)
diff --git a/regen/embed.pl b/regen/embed.pl
index a7419ba26d..1f5b7497ce 100755
--- a/regen/embed.pl
+++ b/regen/embed.pl
@@ -85,13 +85,16 @@ my ($embed, $core, $ext, $api) = setup_embed();
}
if ($flags =~ /([si])/) {
- my $type = ($1 eq 's') ? "STATIC" : "PERL_STATIC_INLINE";
+ my $type;
+ if ($never_returns) {
+ $type = $1 eq 's' ? "PERL_STATIC_NO_RET" : "PERL_STATIC_INLINE_NO_RET";
+ }
+ else {
+ $type = $1 eq 's' ? "STATIC" : "PERL_STATIC_INLINE";
+ }
warn "$func: i and s flags are mutually exclusive"
if $flags =~ /s/ && $flags =~ /i/;
$retval = "$type $splint_flags$retval";
- if ($never_returns) {
- $retval = "PERL_CALLCONV_NO_RET $retval";
- }
$func = "S_$plain_func";
}
else {
diff --git a/win32/win32.h b/win32/win32.h
index 489fbf4425..59a3052c26 100644
--- a/win32/win32.h
+++ b/win32/win32.h
@@ -80,6 +80,11 @@
# endif
#endif
+#ifdef _MSC_VER
+# define PERL_STATIC_NO_RET __declspec(noreturn) static
+# define PERL_STATIC_INLINE_NO_RET __declspec(noreturn) PERL_STATIC_INLINE
+#endif
+
#define WIN32_LEAN_AND_MEAN
#include <windows.h>