Created
December 12, 2012 21:43
-
-
Save krakjoe/4271903 to your computer and use it in GitHub Desktop.
jemalloc.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff -ur a/php-src-jemalloc-zendmm/Zend/zend_alloc.c b/php-src-jemalloc-zendmm/Zend/zend_alloc.c | |
| --- a/php-src-jemalloc-zendmm/Zend/zend_alloc.c 2012-12-12 06:59:10.000000000 +0100 | |
| +++ b/php-src-jemalloc-zendmm/Zend/zend_alloc.c 2012-12-12 22:35:24.000000000 +0100 | |
| @@ -38,17 +38,20 @@ | |
| #endif | |
| #ifdef HAVE_MEM_JEMALLOC | |
| -# ifndef JEMALLOC_NO_DEMANGLE | |
| -# define JEMALLOC_NO_DEMANGLE | |
| +# ifdef JEMALLOC_PREFIX | |
| +# define JEMALLOC_FUNCTION(entry) je_##entry | |
| +# else | |
| +# define JEMALLOC_FUNCTION(entry) entry | |
| # endif | |
| -#include <jemalloc/jemalloc.h> | |
| +# define JEMALLOC_CALL(entry) JEMALLOC_FUNCTION(entry) | |
| +# include <jemalloc/jemalloc.h> | |
| #endif | |
| #ifndef ZEND_MM_HEAP_PROTECTION | |
| # define ZEND_MM_HEAP_PROTECTION ZEND_DEBUG | |
| #endif | |
| -#ifndef ZEND_MM_SAFE_UNLINKING | |
| +#ifndef ZEND_MM_SAFE_UNLINKING | |
| # define ZEND_MM_SAFE_UNLINKING 1 | |
| #endif | |
| @@ -311,12 +314,12 @@ | |
| static zend_mm_storage* zend_mm_mem_jemalloc_init(void *params) | |
| { | |
| - return je_malloc(sizeof(zend_mm_storage)); | |
| + return JEMALLOC_CALL(malloc)(sizeof(zend_mm_storage)); | |
| } | |
| static void zend_mm_mem_jemalloc_dtor(zend_mm_storage *storage) | |
| { | |
| - je_free(storage); | |
| + JEMALLOC_CALL(free)(storage); | |
| } | |
| static void zend_mm_mem_jemalloc_compact(zend_mm_storage *storage) | |
| @@ -325,17 +328,17 @@ | |
| static zend_mm_segment* zend_mm_mem_jemalloc_alloc(zend_mm_storage *storage, size_t size) | |
| { | |
| - return (zend_mm_segment*)je_malloc(size); | |
| + return (zend_mm_segment*)JEMALLOC_CALL(malloc)(size); | |
| } | |
| static zend_mm_segment* zend_mm_mem_jemalloc_realloc(zend_mm_storage *storage, zend_mm_segment *ptr, size_t size) | |
| { | |
| - return (zend_mm_segment*)je_realloc(ptr, size); | |
| + return (zend_mm_segment*)JEMALLOC_CALL(realloc)(ptr, size); | |
| } | |
| static void zend_mm_mem_jemalloc_free(zend_mm_storage *storage, zend_mm_segment *ptr) | |
| { | |
| - je_free(ptr); | |
| + JEMALLOC_CALL(free)(ptr); | |
| } | |
| #define ZEND_MM_MEM_JEMALLOC_DSC {"jemalloc", zend_mm_mem_jemalloc_init, zend_mm_mem_jemalloc_dtor, zend_mm_mem_jemalloc_compact, zend_mm_mem_jemalloc_alloc, zend_mm_mem_jemalloc_realloc, zend_mm_mem_jemalloc_free} | |
| diff -ur a/php-src-jemalloc-zendmm/Zend/Zend.m4 b/php-src-jemalloc-zendmm/Zend/Zend.m4 | |
| --- a/php-src-jemalloc-zendmm/Zend/Zend.m4 2012-12-12 06:59:10.000000000 +0100 | |
| +++ b/php-src-jemalloc-zendmm/Zend/Zend.m4 2012-12-12 22:35:16.000000000 +0100 | |
| @@ -393,13 +393,11 @@ | |
| AC_CHECK_FUNCS(mremap) | |
| AC_MSG_CHECKING(if jemalloc handlers should be used) | |
| - | |
| AC_ARG_ENABLE(jemalloc, | |
| [ --enable-jemalloc Use jemalloc for malloc replacement],[ | |
| AC_TRY_RUN([ | |
| #include <stdlib.h> | |
| #include <jemalloc/jemalloc.h> | |
| - | |
| int main() { | |
| #ifdef JEMALLOC_VERSION | |
| return 0; | |
| @@ -409,10 +407,10 @@ | |
| } | |
| ], [ | |
| AC_DEFINE(HAVE_MEM_JEMALLOC, 1, [jemalloc malloc implementation is available]) | |
| - AC_MSG_RESULT([found]) | |
| - LIBS="$LIBS -ljemalloc" | |
| + AC_MSG_RESULT([yes]) | |
| + LIBS="$LIBS -ljemalloc" | |
| ], [ | |
| - AC_MSG_FAILURE([failed to find libjemalloc]) | |
| + AC_MSG_FAILURE([failed to find jemalloc]) | |
| ]) | |
| ],[ | |
| AC_MSG_RESULT([no]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment