> [nicholas - Wed Jun 01 08:09:31 2005]: > > This is a bug report for perl from [EMAIL PROTECTED], > generated with the help of perlbug 1.35 running under perl v5.9.3. > > > ----------------------------------------------------------------- > [Please enter your report here] > > Darwin provides 2 extra malloc() functions: > > The malloc_size() function returns the size of the memory block > that > backs the allocation pointed to by ptr. The memory block size is > always > at least as large as the allocation it backs, and may be larger. > > The malloc_good_size() function rounds size up to a value that > the allo- > cator implementation can allocate without adding any padding and > returns > that rounded up value. > > It's not clear if any other malloc implementations provide these > functions, or > the same functionality with another name, apart from Perl's own > malloc's > malloced_size > > It would be useful to probe for them, because if they either are found > it would > allow efficiency savings in various places. Specifically when buffers > allocated > for SvPVX() we could set SvLEN() to the true maximum length, and AV > storage > extension could be tuned to use all the memory malloc() actually gave > us. >
Adding the detection for these function is pretty simple, and Configure doesn't need to do anything more that standard libc scanning. I'm guessing it would be easy to add to Metaconfig to check. The following patches can do it for playing with, but don't apply to p4. Merijn, do you need any more information for the Metaconfig changes? --- Configure.old Tue Sep 6 09:38:43 2005 +++ Configure Sat Sep 10 19:44:50 2005 @@ -550,6 +550,8 @@ d_lseekproto='' d_lstat='' d_madvise='' +d_malloc_size='' +d_malloc_good_size='' d_mblen='' d_mbstowcs='' d_mbtowc='' @@ -14247,6 +14249,14 @@ set madvise d_madvise eval $inlibc +: see if malloc_size exists +set malloc_size d_malloc_size +eval $inlibc + +: see if malloc_size_good exists +set malloc_good_size d_malloc_good_size +eval $inlibc + : see if mblen exists set mblen d_mblen eval $inlibc @@ -21112,6 +21122,8 @@ d_lseekproto='$d_lseekproto' d_lstat='$d_lstat' d_madvise='$d_madvise' +d_malloc_size='$d_malloc_size' +d_malloc_size_good='$d_malloc_size_good' d_mblen='$d_mblen' d_mbstowcs='$d_mbstowcs' d_mbtowc='$d_mbtowc' --- config_h.SH.old Tue Jun 21 14:56:18 2005 +++ config_h.SH Sat Sep 10 19:22:05 2005 @@ -3889,6 +3889,18 @@ */ #$d_libm_lib_version LIBM_LIB_VERSION /**/ +/* HAS_MALLOC_SIZE + * This symbol, if defined, indicates that the malloc_size + * routine is available for use. + */ +#$d_malloc_size HAS_MALLOC_SIZE /**/ + +/* HAS_MALLOC_GOOD_SIZE + * This symbol, if defined, indicates that the malloc_good_size + * routine is available for use. + */ +#$d_malloc_good_size HAS_MALLOC_GOOD_SIZE /**/ + /* HAS_NL_LANGINFO: * This symbol, if defined, indicates that the nl_langinfo routine is * available to return local data. You will also need <langinfo.h>