This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
add adjust_size_and_find_bucket to embed.fnc
authorLukas Mai <l.mai@web.de>
Sat, 10 Aug 2013 22:44:09 +0000 (00:44 +0200)
committerJames E Keenan <jkeenan@cpan.org>
Sat, 10 Aug 2013 23:27:52 +0000 (01:27 +0200)
embed.fnc
embed.h
malloc.c
proto.h

index 5fede44..624b2aa 100644 (file)
--- a/embed.fnc
+++ b/embed.fnc
@@ -185,6 +185,9 @@ Anop        |Free_t |mfree          |Malloc_t where
 npR    |MEM_SIZE|malloced_size |NN void *p
 npR    |MEM_SIZE|malloc_good_size      |size_t nbytes
 #endif
+#if defined(PERL_IN_MALLOC_C)
+sn     |int    |adjust_size_and_find_bucket    |NN size_t *nbytes_p
+#endif
 
 AnpR   |void*  |get_context
 Anp    |void   |set_context    |NN void *t
diff --git a/embed.h b/embed.h
index 9b5125a..605ecd4 100644 (file)
--- a/embed.h
+++ b/embed.h
 #define stdize_locale(a)       S_stdize_locale(aTHX_ a)
 #    endif
 #  endif
+#  if defined(PERL_IN_MALLOC_C)
+#define adjust_size_and_find_bucket    S_adjust_size_and_find_bucket
+#  endif
 #  if defined(PERL_IN_MG_C)
 #define magic_methcall1(a,b,c,d,e,f)   S_magic_methcall1(aTHX_ a,b,c,d,e,f)
 #define magic_methpack(a,b,c)  S_magic_methpack(aTHX_ a,b,c)
index 41d75da..a0a762e 100644 (file)
--- a/malloc.c
+++ b/malloc.c
@@ -1212,12 +1212,16 @@ cmp_pat_4bytes(unsigned char *s, size_t nbytes, const unsigned char *fill)
 #  define FILLCHECK_DEADBEEF(s, n)     ((void)0)
 #endif
 
-int
+STATIC int
 S_adjust_size_and_find_bucket(size_t *nbytes_p)
 {
-       MEM_SIZE shiftr;
+       MEM_SIZE shiftr;
        int bucket;
-       size_t nbytes = *nbytes_p;
+       size_t nbytes;
+
+       PERL_ARGS_ASSERT_ADJUST_SIZE_AND_FIND_BUCKET;
+
+       nbytes = *nbytes_p;
 
        /*
         * Convert amount of memory requested into
@@ -1273,7 +1277,7 @@ Perl_malloc(size_t nbytes)
            croak("%s", "panic: malloc");
 #endif
 
-       bucket = S_adjust_size_and_find_bucket(&nbytes);
+       bucket = adjust_size_and_find_bucket(&nbytes);
        MALLOC_LOCK;
        /*
         * If nothing in hash bucket right now,
@@ -2173,7 +2177,7 @@ Perl_malloced_size(void *p)
 MEM_SIZE
 Perl_malloc_good_size(size_t wanted)
 {
-    return BUCKET_SIZE_REAL(S_adjust_size_and_find_bucket(&wanted));
+    return BUCKET_SIZE_REAL(adjust_size_and_find_bucket(&wanted));
 }
 
 #  ifdef BUCKETS_ROOT2
diff --git a/proto.h b/proto.h
index 76ec13d..a8c0b6d 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -5807,6 +5807,13 @@ STATIC char*     S_stdize_locale(pTHX_ char* locs)
 
 #  endif
 #endif
+#if defined(PERL_IN_MALLOC_C)
+STATIC int     S_adjust_size_and_find_bucket(size_t *nbytes_p)
+                       __attribute__nonnull__(1);
+#define PERL_ARGS_ASSERT_ADJUST_SIZE_AND_FIND_BUCKET   \
+       assert(nbytes_p)
+
+#endif
 #if defined(PERL_IN_MG_C)
 STATIC SV*     S_magic_methcall1(pTHX_ SV *sv, const MAGIC *mg, SV *meth, U32 flags, int n, SV *val)
                        __attribute__nonnull__(pTHX_1)