In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/43387ee1abcd83c3c7586b7f7aa86e838d239aac?hp=b5de49e55f04e3a6c36012d250a46eb301a2be38>
- Log ----------------------------------------------------------------- commit 43387ee1abcd83c3c7586b7f7aa86e838d239aac Author: Andy Dougherty <[email protected]> Date: Wed Mar 27 15:54:05 2013 -0400 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. M embed.fnc M embed.h M handy.h M inline.h M proto.h M sv.c M util.c commit cbe4d57f99858fe05f2e924ad9125b9b9e50504e Author: Andy Dougherty <[email protected]> Date: Wed Mar 27 20:11:34 2013 -0400 makedef.pl shouldn't prepend Perl_ to symbols already starting with Perl_. In the next patch, I have Perl_croak_memory_wrap defined in embed.fnc with the 'nroX' flags, since this is a private function used by public macros. I used the long form of the name Perl_croak_memory_wrap everywhere, and used the 'o' flag so that embed.h wouldn't contain a useless #define croak_memory_wrap Perl_croak_memory_wrap. Unfortunately, makedef.pl (used by the Win32 build process) didn't know what to do with that entry and created an entry Perl_Perl_croak_memory_wrap. Changing makedef.pl to use the 'o' flag to decide whether to add the Perl_ prefix resulted in over 50 other symbols changing in the output of makedef.pl. I don't know if the changes are correct or if the 'o' flag is in error on those entries in embed.fnc, but I don't have time to check them all out. This patch just stops makedef.pl from adding a Perl_ prefix if there is already one there. M makedef.pl ----------------------------------------------------------------------- Summary of changes: embed.fnc | 2 +- embed.h | 1 - handy.h | 4 ++-- inline.h | 16 ---------------- makedef.pl | 3 ++- proto.h | 6 +++--- sv.c | 4 ++-- util.c | 14 +++++++++++--- 8 files changed, 21 insertions(+), 29 deletions(-) diff --git a/embed.fnc b/embed.fnc index 6f3adc6..ecdde73 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 f32f446..96309b2 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 3a241fd..90b4b50 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 ... [3 chars truncated] +#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_QUA ... [9 chars truncated] #else #define MEM_WRAP_CHECK(n,t) diff --git a/inline.h b/inline.h index 6cdfe9f..953bb33 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/makedef.pl b/makedef.pl index 950af85..d2c5f5e 100644 --- a/makedef.pl +++ b/makedef.pl @@ -755,7 +755,8 @@ if ($define{'USE_PERLIO'}) { # within the block, as the *first* definition may have flags which # mean "don't export" next if $seen{$func}++; - $func = "Perl_$func" if $flags =~ /[pbX]/; + # Should we also skip adding the Perl_ prefix if $flags =~ /o/ ? + $func = "Perl_$func" if ($flags =~ /[pbX]/ && $func !~ /^Perl_/); ++$export{$func} unless exists $skip{$func}; } } diff --git a/proto.h b/proto.h index 52f2098..59ecbc6 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 3f68d9c..3736ba8 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 75381f1..1fd1e00 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); -- Perl5 Master Repository
