From: Gurusamy Sarathy Date: Thu, 5 Jul 2001 00:52:57 +0000 (+0000) Subject: fix the binary compatibility issue when building with/without X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=cae6d0e5ad55f3d6c7902bf7cfc560481e827bb3;p=p5sagit%2Fp5-mst-13.2.git fix the binary compatibility issue when building with/without usemymalloc by exporting Perl_malloc() et al as simple wrappers around the system functions (this allows most extensions built using one mode to coexist with perls built in the other mode) XXX the Perl_mfree() wrapper might need to do return(free()) on platforms where Free_t isn't "void" p4raw-id: //depot/perl@11152 --- diff --git a/embed.h b/embed.h index 96a9dd7..21bde98 100644 --- a/embed.h +++ b/embed.h @@ -3084,11 +3084,11 @@ # if defined(PERL_IMPLICIT_SYS) # endif #endif -#if defined(MYMALLOC) #define malloc Perl_malloc #define calloc Perl_calloc #define realloc Perl_realloc #define mfree Perl_mfree +#if defined(MYMALLOC) #define malloced_size Perl_malloced_size #endif #define get_context Perl_get_context diff --git a/embed.pl b/embed.pl index ca061f4..e322ae2 100755 --- a/embed.pl +++ b/embed.pl @@ -1359,11 +1359,11 @@ Ajno |PerlInterpreter*|perl_clone_using|PerlInterpreter *interp|UV flags \ # endif #endif -#if defined(MYMALLOC) Ajnop |Malloc_t|malloc |MEM_SIZE nbytes Ajnop |Malloc_t|calloc |MEM_SIZE elements|MEM_SIZE size Ajnop |Malloc_t|realloc |Malloc_t where|MEM_SIZE nbytes Ajnop |Free_t |mfree |Malloc_t where +#if defined(MYMALLOC) jnp |MEM_SIZE|malloced_size |void *p #endif diff --git a/makedef.pl b/makedef.pl index 9c8a65e..12eab67 100644 --- a/makedef.pl +++ b/makedef.pl @@ -473,10 +473,6 @@ if ($define{'MYMALLOC'}) { emit_symbols [qw( Perl_dump_mstats Perl_get_mstats - Perl_malloc - Perl_mfree - Perl_realloc - Perl_calloc Perl_strdup Perl_putenv )]; @@ -496,10 +492,6 @@ else { PL_malloc_mutex Perl_dump_mstats Perl_get_mstats - Perl_malloc - Perl_mfree - Perl_realloc - Perl_calloc Perl_malloced_size )]; } diff --git a/proto.h b/proto.h index ae4157c..50d552a 100644 --- a/proto.h +++ b/proto.h @@ -24,11 +24,11 @@ PERL_CALLCONV PerlInterpreter* perl_clone_using(PerlInterpreter *interp, UV flag # endif #endif -#if defined(MYMALLOC) PERL_CALLCONV Malloc_t Perl_malloc(MEM_SIZE nbytes); PERL_CALLCONV Malloc_t Perl_calloc(MEM_SIZE elements, MEM_SIZE size); PERL_CALLCONV Malloc_t Perl_realloc(Malloc_t where, MEM_SIZE nbytes); PERL_CALLCONV Free_t Perl_mfree(Malloc_t where); +#if defined(MYMALLOC) PERL_CALLCONV MEM_SIZE Perl_malloced_size(void *p); #endif diff --git a/util.c b/util.c index ed70ea0..b72a8f2 100644 --- a/util.c +++ b/util.c @@ -336,6 +336,37 @@ S_xstat(pTHX_ int flag) #endif /* LEAKTEST */ +/* These must be defined when not using Perl's malloc for binary + * compatibility */ + +#ifndef MYMALLOC + +Malloc_t Perl_malloc (MEM_SIZE nbytes) +{ + dTHXs; + return PerlMem_malloc(nbytes); +} + +Malloc_t Perl_calloc (MEM_SIZE elements, MEM_SIZE size) +{ + dTHXs; + return PerlMem_calloc(elements, size); +} + +Malloc_t Perl_realloc (Malloc_t where, MEM_SIZE nbytes) +{ + dTHXs; + return PerlMem_realloc(where, nbytes); +} + +Free_t Perl_mfree (Malloc_t where) +{ + dTHXs; + PerlMem_free(where); +} + +#endif + /* copy a string up to some (non-backslashed) delimiter, if any */ char *