summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Dougherty <doughera@lafayette.edu>2013-03-27 15:54:05 -0400
committerAndy Dougherty <doughera@lafayette.edu>2013-03-28 16:49:37 -0400
commit43387ee1abcd83c3c7586b7f7aa86e838d239aac (patch)
tree89766800af3f0f19490b84e6f9bb305ac8cc578b
parentcbe4d57f99858fe05f2e924ad9125b9b9e50504e (diff)
downloadperl-43387ee1abcd83c3c7586b7f7aa86e838d239aac.tar.gz
Remove the non-inline function S_croak_memory_wrap from inline.h.
This appears to resolve these three related tickets: [perl #116989] S_croak_memory_wrap breaks gcc warning flags detection [perl #117319] Can't include perl.h without linking to libperl [perl #117331] Time::HiRes::clock_gettime not implemented on Linux (regression?) This patch changes S_croak_memory_wrap from a static (but not inline) function into an ordinary exported function Perl_croak_memory_wrap. This has the advantage of allowing programs (particuarly probes, such as in cflags.SH and Time::HiRes) to include perl.h without linking against libperl. Since it is not a static function defined within each compilation unit, the optimizer can no longer remove it when it's not needed or inline it as needed. This likely negates some of the savings that motivated the original commit 380f764c1ead36fe3602184804292711. However, calling the simpler function Perl_croak_memory_wrap() still does take less set-up than the previous version, so it may still be a slight win. Specific cross-platform measurements are welcome.
-rw-r--r--embed.fnc2
-rw-r--r--embed.h1
-rw-r--r--handy.h4
-rw-r--r--inline.h16
-rw-r--r--proto.h6
-rw-r--r--sv.c4
-rw-r--r--util.c14
7 files changed, 19 insertions, 28 deletions
diff --git a/embed.fnc b/embed.fnc
index 6f3adc6148..ecdde732c1 100644
--- a/embed.fnc
+++ b/embed.fnc
@@ -265,6 +265,7 @@ Anprd |void |croak_no_modify
Anprd |void |croak_xs_usage |NN const CV *const cv \
|NN const char *const params
npr |void |croak_no_mem
+nroX |void |Perl_croak_memory_wrap
nprX |void |croak_popstack
#if defined(WIN32)
norx |void |win32_croak_not_implemented|NN const char * fname
@@ -1608,7 +1609,6 @@ Anpa |Malloc_t|safesysmalloc |MEM_SIZE nbytes
Anpa |Malloc_t|safesyscalloc |MEM_SIZE elements|MEM_SIZE size
Anpa |Malloc_t|safesysrealloc|Malloc_t where|MEM_SIZE nbytes
Anp |Free_t |safesysfree |Malloc_t where
-Asrnx |void |croak_memory_wrap
#if defined(PERL_GLOBAL_STRUCT)
Ap |struct perl_vars *|GetVars
Ap |struct perl_vars*|init_global_struct
diff --git a/embed.h b/embed.h
index f32f446b4b..96309b264f 100644
--- a/embed.h
+++ b/embed.h
@@ -84,7 +84,6 @@
#ifndef PERL_IMPLICIT_CONTEXT
#define croak Perl_croak
#endif
-#define croak_memory_wrap S_croak_memory_wrap
#define croak_no_modify Perl_croak_no_modify
#define croak_sv(a) Perl_croak_sv(aTHX_ a)
#define croak_xs_usage Perl_croak_xs_usage
diff --git a/handy.h b/handy.h
index 3a241fda67..90b4b504f4 100644
--- a/handy.h
+++ b/handy.h
@@ -1497,12 +1497,12 @@ PoisonWith(0xEF) for catching access to freed memory.
* (U16)n > (size_t)~0/sizeof(U16) always being false. */
#ifdef PERL_MALLOC_WRAP
#define MEM_WRAP_CHECK(n,t) \
- (void)(sizeof(t) > 1 && ((MEM_SIZE)(n)+0.0) > MEM_SIZE_MAX/sizeof(t) && (croak_memory_wrap(),0))
+ (void)(sizeof(t) > 1 && ((MEM_SIZE)(n)+0.0) > MEM_SIZE_MAX/sizeof(t) && (Perl_croak_memory_wrap(),0))
#define MEM_WRAP_CHECK_1(n,t,a) \
(void)(sizeof(t) > 1 && ((MEM_SIZE)(n)+0.0) > MEM_SIZE_MAX/sizeof(t) && (Perl_croak_nocontext("%s",(a)),0))
#define MEM_WRAP_CHECK_(n,t) MEM_WRAP_CHECK(n,t),
-#define PERL_STRLEN_ROUNDUP(n) ((void)(((n) > MEM_SIZE_MAX - 2 * PERL_STRLEN_ROUNDUP_QUANTUM) ? (croak_memory_wrap(),0):0),((n-1+PERL_STRLEN_ROUNDUP_QUANTUM)&~((MEM_SIZE)PERL_STRLEN_ROUNDUP_QUANTUM-1)))
+#define PERL_STRLEN_ROUNDUP(n) ((void)(((n) > MEM_SIZE_MAX - 2 * PERL_STRLEN_ROUNDUP_QUANTUM) ? (Perl_croak_memory_wrap(),0):0),((n-1+PERL_STRLEN_ROUNDUP_QUANTUM)&~((MEM_SIZE)PERL_STRLEN_ROUNDUP_QUANTUM-1)))
#else
#define MEM_WRAP_CHECK(n,t)
diff --git a/inline.h b/inline.h
index 6cdfe9f178..953bb33cff 100644
--- a/inline.h
+++ b/inline.h
@@ -134,22 +134,6 @@ S_sv_or_pv_pos_u2b(pTHX_ SV *sv, const char *pv, STRLEN pos, STRLEN *lenp)
}
#endif
-/* ------------------------------- handy.h ------------------------------- */
-
-/* saves machine code for a common noreturn idiom typically used in Newx*() */
-#ifdef __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wunused-function"
-#endif
-static void
-S_croak_memory_wrap(void)
-{
- Perl_croak_nocontext("%s",PL_memory_wrap);
-}
-#ifdef __clang__
-#pragma clang diagnostic pop
-#endif
-
/* ------------------------------- utf8.h ------------------------------- */
/* These exist only to replace the macros they formerly were so that their use
diff --git a/proto.h b/proto.h
index 52f2098536..59ecbc648f 100644
--- a/proto.h
+++ b/proto.h
@@ -23,6 +23,9 @@ PERL_CALLCONV int Perl_Gv_AMupdate(pTHX_ HV* stash, bool destructing)
assert(stash)
PERL_CALLCONV const char * Perl_PerlIO_context_layers(pTHX_ const char *mode);
+PERL_CALLCONV_NO_RET void Perl_croak_memory_wrap(void)
+ __attribute__noreturn__;
+
PERL_CALLCONV void* Perl_Slab_Alloc(pTHX_ size_t sz)
__attribute__malloc__
__attribute__warn_unused_result__;
@@ -677,9 +680,6 @@ PERL_CALLCONV_NO_RET void Perl_croak(pTHX_ const char* pat, ...)
__attribute__noreturn__
__attribute__format__null_ok__(__printf__,pTHX_1,pTHX_2);
-PERL_STATIC_NO_RET void S_croak_memory_wrap(void)
- __attribute__noreturn__;
-
PERL_CALLCONV_NO_RET void Perl_croak_no_mem(void)
__attribute__noreturn__;
diff --git a/sv.c b/sv.c
index 3f68d9c1fa..3736ba83e1 100644
--- a/sv.c
+++ b/sv.c
@@ -11325,13 +11325,13 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p
have = esignlen + zeros + elen;
if (have < zeros)
- croak_memory_wrap();
+ Perl_croak_memory_wrap();
need = (have > width ? have : width);
gap = need - have;
if (need >= (((STRLEN)~0) - SvCUR(sv) - dotstrlen - 1))
- croak_memory_wrap();
+ Perl_croak_memory_wrap();
SvGROW(sv, SvCUR(sv) + need + dotstrlen + 1);
p = SvEND(sv);
if (esignlen && fill == '0') {
diff --git a/util.c b/util.c
index 75381f1227..1fd1e006e9 100644
--- a/util.c
+++ b/util.c
@@ -297,12 +297,12 @@ Perl_safesyscalloc(MEM_SIZE count, MEM_SIZE size)
#endif
}
else
- croak_memory_wrap();
+ Perl_croak_memory_wrap();
#ifdef PERL_TRACK_MEMPOOL
if (sTHX <= MEM_SIZE_MAX - (MEM_SIZE)total_size)
total_size += sTHX;
else
- croak_memory_wrap();
+ Perl_croak_memory_wrap();
#endif
#ifdef HAS_64K_LIMIT
if (total_size > 0xffff) {
@@ -1614,6 +1614,14 @@ Perl_croak_no_mem()
my_exit(1);
}
+/* saves machine code for a common noreturn idiom typically used in Newx*() */
+void
+Perl_croak_memory_wrap(void)
+{
+ Perl_croak_nocontext("%s",PL_memory_wrap);
+}
+
+
/* does not return, used only in POPSTACK */
void
Perl_croak_popstack(void)
@@ -3259,7 +3267,7 @@ Perl_repeatcpy(char *to, const char *from, I32 len, IV count)
assert(len >= 0);
if (count < 0)
- croak_memory_wrap();
+ Perl_croak_memory_wrap();
if (len == 1)
memset(to, *from, count);