From 12ac819e4f559e545fe753502f63d400f89de252 Mon Sep 17 00:00:00 2001 From: cristy Date: Tue, 4 Nov 2014 13:59:13 +0000 Subject: [PATCH] --- MagickCore/magick-baseconfig.h | 11 +++ MagickCore/version.h | 4 +- Makefile.in | 3 +- aclocal.m4 | 1 + config/config.h.in | 9 ++ configure | 154 ++++++++++++++++++++++++++++++++- configure.ac | 10 ++- m4/jemalloc.m4 | 88 +++++++++++++++++++ 8 files changed, 271 insertions(+), 9 deletions(-) create mode 100644 m4/jemalloc.m4 diff --git a/MagickCore/magick-baseconfig.h b/MagickCore/magick-baseconfig.h index bbde8db36..00a7114f4 100644 --- a/MagickCore/magick-baseconfig.h +++ b/MagickCore/magick-baseconfig.h @@ -371,6 +371,9 @@ #define MAGICKCORE_HAVE_J1 1 #endif +/* Define to 1 if you have the header file. */ +/* #undef HAVE_JEMALLOC_JEMALLOC_H */ + /* Define if you have the header file. */ #ifndef MAGICKCORE_HAVE_LCMS2_H #define MAGICKCORE_HAVE_LCMS2_H 1 @@ -1549,6 +1552,9 @@ /* Define to `int' if doesn't define. */ /* #undef gid_t */ +/* Link/compile against jemalloc */ +/* #undef has_jemalloc */ + /* Define to `__inline__' or `__inline' if that's what the C compiler calls it, or to nothing if 'inline' is not supported under any name. */ #ifndef __cplusplus @@ -1591,6 +1597,11 @@ /* Define to `int' if does not define. */ /* #undef pid_t */ +/* jemalloc prefix */ +#ifndef _magickcore_prefix_jemalloc +#define _magickcore_prefix_jemalloc +#endif + /* Define to the equivalent of the C99 'restrict' keyword, or to nothing if this is not supported. Do not define if restrict is supported directly. */ diff --git a/MagickCore/version.h b/MagickCore/version.h index 01cf2e8d3..f5d8f93bf 100644 --- a/MagickCore/version.h +++ b/MagickCore/version.h @@ -27,7 +27,7 @@ extern "C" { */ #define MagickPackageName "ImageMagick" #define MagickCopyright "Copyright (C) 1999-2014 ImageMagick Studio LLC" -#define MagickSVNRevision "16900:16901" +#define MagickSVNRevision "16921:16931M" #define MagickLibVersion 0x700 #define MagickLibVersionText "7.0.0" #define MagickLibVersionNumber 1,0,0 @@ -48,7 +48,7 @@ extern "C" { #define MagickppLibAddendum "-0" #define MagickppLibInterface 1 #define MagickppLibMinInterface 1 -#define MagickReleaseDate "2014-11-03" +#define MagickReleaseDate "2014-11-04" #define MagickChangeDate "20120427" #define MagickAuthoritativeURL "http://www.imagemagick.org" #define MagickFeatures "DPC HDRI OpenMP" diff --git a/Makefile.in b/Makefile.in index 8066feea4..a2eacc1e9 100644 --- a/Makefile.in +++ b/Makefile.in @@ -327,7 +327,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ac_func_fseeko.m4 \ $(top_srcdir)/m4/ax_pthread.m4 \ $(top_srcdir)/m4/ax_require_defined.m4 \ $(top_srcdir)/m4/cxx_have_std_libs.m4 \ - $(top_srcdir)/m4/framework.m4 \ + $(top_srcdir)/m4/framework.m4 $(top_srcdir)/m4/jemalloc.m4 \ $(top_srcdir)/m4/ld-version-script.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ @@ -2884,6 +2884,7 @@ docdir = $(DOCUMENTATION_PATH) dvidir = @dvidir@ exec_prefix = @exec_prefix@ ghostscript_font_dir = @ghostscript_font_dir@ +has_jemalloc = @has_jemalloc@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ diff --git a/aclocal.m4 b/aclocal.m4 index 2511e3451..f63bbeee3 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1340,6 +1340,7 @@ m4_include([m4/ax_pthread.m4]) m4_include([m4/ax_require_defined.m4]) m4_include([m4/cxx_have_std_libs.m4]) m4_include([m4/framework.m4]) +m4_include([m4/jemalloc.m4]) m4_include([m4/ld-version-script.m4]) m4_include([m4/libtool.m4]) m4_include([m4/ltoptions.m4]) diff --git a/config/config.h.in b/config/config.h.in index 5da195387..0e1c15354 100644 --- a/config/config.h.in +++ b/config/config.h.in @@ -242,6 +242,9 @@ /* Define to 1 if you have the `j1' function. */ #undef HAVE_J1 +/* Define to 1 if you have the header file. */ +#undef HAVE_JEMALLOC_JEMALLOC_H + /* Define if you have the header file. */ #undef HAVE_LCMS2_H @@ -1050,6 +1053,9 @@ /* Define to `int' if doesn't define. */ #undef gid_t +/* Link/compile against jemalloc */ +#undef has_jemalloc + /* Define to `__inline__' or `__inline' if that's what the C compiler calls it, or to nothing if 'inline' is not supported under any name. */ #ifndef __cplusplus @@ -1092,6 +1098,9 @@ /* Define to `int' if does not define. */ #undef pid_t +/* jemalloc prefix */ +#undef prefix_jemalloc + /* Define to the equivalent of the C99 'restrict' keyword, or to nothing if this is not supported. Do not define if restrict is supported directly. */ diff --git a/configure b/configure index 86216f963..3692924eb 100755 --- a/configure +++ b/configure @@ -869,6 +869,7 @@ CCMALLOCDelegate UMEM_LIBS HasUMEM_FALSE HasUMEM_TRUE +has_jemalloc GOMP_LIBS WITH_MAGICK_PLUS_PLUS_FALSE WITH_MAGICK_PLUS_PLUS_TRUE @@ -1164,6 +1165,8 @@ with_perl with_perl_options with_umem with_libstdc +with_jemalloc_prefix +with_jemalloc with_bzlib with_x with_zlib @@ -1935,6 +1938,9 @@ Optional Packages: PerlMagick build file --with-umem enable umem memory allocation library support --with-libstdc=DIR use libstdc++ in DIR (for GNU C++) + --with-jemalloc-prefix=PREFIX + Specify the jemalloc prefix [default=""] + --with-jemalloc=DIR use a specific jemalloc library --without-bzlib disable BZLIB support --with-x use the X Window System --without-zlib disable ZLIB support @@ -3698,7 +3704,7 @@ MAGICK_PATCHLEVEL_VERSION=0 MAGICK_VERSION=7.0.0-0 -MAGICK_SVN_REVISION=16900:16901 +MAGICK_SVN_REVISION=16921:16931M # Substitute library versioning @@ -26595,7 +26601,149 @@ fi fi +# +# Check for jemalloc(). +# + + +# Check whether --with-jemalloc-prefix was given. +if test "${with_jemalloc_prefix+set}" = set; then : + withval=$with_jemalloc_prefix; + jemalloc_prefix="$withval" + +else + + if test "`uname -s`" = "Darwin"; then + jemalloc_prefix="je_" + else + jemalloc_prefix="" + fi + + +fi + + +cat >>confdefs.h <<_ACEOF +#define prefix_jemalloc ${jemalloc_prefix} +_ACEOF + + +enable_jemalloc=no + +# Check whether --with-jemalloc was given. +if test "${with_jemalloc+set}" = set; then : + withval=$with_jemalloc; + if test "$withval" != "no"; then + if test "x${enable_tcmalloc}" = "xyes"; then + as_fn_error $? "Cannot compile with both jemalloc and tcmalloc" "$LINENO" 5 + fi + enable_jemalloc=yes + jemalloc_base_dir="$withval" + case "$withval" in + yes) + jemalloc_base_dir="/usr" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking checking for jemalloc includes standard directories" >&5 +$as_echo_n "checking checking for jemalloc includes standard directories... " >&6; } + ;; + *":"*) + jemalloc_include="`echo $withval |sed -e 's/:.*$//'`" + jemalloc_ldflags="`echo $withval |sed -e 's/^.*://'`" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking checking for jemalloc includes in $jemalloc_include libs in $jemalloc_ldflags" >&5 +$as_echo_n "checking checking for jemalloc includes in $jemalloc_include libs in $jemalloc_ldflags... " >&6; } + ;; + *) + jemalloc_include="$withval/include" + jemalloc_ldflags="$withval/lib" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking checking for jemalloc includes in $withval" >&5 +$as_echo_n "checking checking for jemalloc includes in $withval... " >&6; } + ;; + esac + fi + +fi + + +has_jemalloc=0 +if test "$enable_jemalloc" != "no"; then + jemalloc_have_headers=0 + jemalloc_have_libs=0 + if test "$jemalloc_base_dir" != "/usr"; then + CFLAGS="${CFLAGS} -I${jemalloc_include}" + LDFLAGS="${LDFLAGS} -L${jemalloc_ldflags}" + LIBTOOL_LINK_FLAGS="${LIBTOOL_LINK_FLAGS} -R${jemalloc_ldflags}" + fi + func="${jemalloc_prefix}malloc_stats_print" + as_ac_Lib=`$as_echo "ac_cv_lib_jemalloc_${func}" | $as_tr_sh` +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${func} in -ljemalloc" >&5 +$as_echo_n "checking for ${func} in -ljemalloc... " >&6; } +if eval \${$as_ac_Lib+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ljemalloc $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char ${func} (); +int +main () +{ +return ${func} (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + eval "$as_ac_Lib=yes" +else + eval "$as_ac_Lib=no" +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +eval ac_res=\$$as_ac_Lib + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : + jemalloc_have_libs=1 +fi + + if test "$jemalloc_have_libs" != "0"; then + for ac_header in jemalloc/jemalloc.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "jemalloc/jemalloc.h" "ac_cv_header_jemalloc_jemalloc_h" "$ac_includes_default" +if test "x$ac_cv_header_jemalloc_jemalloc_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_JEMALLOC_JEMALLOC_H 1 +_ACEOF + jemalloc_have_headers=1 +fi + +done + fi + if test "$jemalloc_have_headers" != "0"; then + has_jemalloc=1 + LIBS="${LIBS} -ljemalloc" + +$as_echo "#define has_jemalloc 1" >>confdefs.h + + else + as_fn_error $? "Couldn't find a jemalloc installation" "$LINENO" 5 + fi +fi + + +if test "x$jemalloc_have_libs" != "x0"; then : + JE_LIBS="-ljemalloc" +fi # # Check for umem. @@ -35924,9 +36072,9 @@ fi # if test "$build_modules" != 'no'; then - MAGICK_DEP_LIBS="$USER_LIBS $LCMS_LIBS $FREETYPE_LIBS $LQR_LIBS $FFTW_LIBS $FONTCONFIG_LIBS $XEXT_LIBS $IPC_LIBS $X11_LIBS $XT_LIBS $LZMA_LIBS $BZLIB_LIBS $ZLIB_LIBS $LTDL_LIBS $GDI32_LIBS $MATH_LIBS $GOMP_LIBS $CL_LIBS $UMEM_LIBS $THREAD_LIBS" + MAGICK_DEP_LIBS="$USER_LIBS $LCMS_LIBS $FREETYPE_LIBS $LQR_LIBS $FFTW_LIBS $FONTCONFIG_LIBS $XEXT_LIBS $IPC_LIBS $X11_LIBS $XT_LIBS $LZMA_LIBS $BZLIB_LIBS $ZLIB_LIBS $LTDL_LIBS $GDI32_LIBS $MATH_LIBS $GOMP_LIBS $CL_LIBS $UMEM_LIBS $JE_LIBS $THREAD_LIBS" else - MAGICK_DEP_LIBS="$USER_LIBS $JBIG_LIBS $LCMS_LIBS $TIFF_LIBS $FREETYPE_LIBS $JPEG_LIBS $GS_LIBS $LQR_LIBS $PNG_LIBS $AUTOTRACE_LIBS $DJVU_LIBS $FFTW_LIBS $FPX_LIBS $FONTCONFIG_LIBS $WEBP_LIBS $WMF_LIBS $DPS_LIBS $XEXT_LIBS $XT_LIBS $IPC_LIBS $X11_LIBS $LZMA_LIBS $BZLIB_LIBS $OPENEXR_LIBS $OPENJPEG_LIBS $PANGO_LIBS $RSVG_LIBS $XML_LIBS $GVC_LIBS $ZLIB_LIBS $GDI32_LIBS $MATH_LIBS $GOMP_LIBS $CL_LIBS $UMEM_LIBS $THREAD_LIBS" + MAGICK_DEP_LIBS="$USER_LIBS $JBIG_LIBS $LCMS_LIBS $TIFF_LIBS $FREETYPE_LIBS $JPEG_LIBS $GS_LIBS $LQR_LIBS $PNG_LIBS $AUTOTRACE_LIBS $DJVU_LIBS $FFTW_LIBS $FPX_LIBS $FONTCONFIG_LIBS $WEBP_LIBS $WMF_LIBS $DPS_LIBS $XEXT_LIBS $XT_LIBS $IPC_LIBS $X11_LIBS $LZMA_LIBS $BZLIB_LIBS $OPENEXR_LIBS $OPENJPEG_LIBS $PANGO_LIBS $RSVG_LIBS $XML_LIBS $GVC_LIBS $ZLIB_LIBS $GDI32_LIBS $MATH_LIBS $GOMP_LIBS $CL_LIBS $UMEM_LIBS $JE_LIBS $THREAD_LIBS" fi diff --git a/configure.ac b/configure.ac index cf3f98b57..282f0b95c 100755 --- a/configure.ac +++ b/configure.ac @@ -1426,7 +1426,11 @@ if test "$enable_openmp" != 'no'; then fi AC_SUBST(GOMP_LIBS) - +# +# Check for jemalloc(). +# +TS_CHECK_JEMALLOC +AS_IF([test "x$jemalloc_have_libs" != "x0"],[JE_LIBS="-ljemalloc"]) # # Check for umem. @@ -3934,9 +3938,9 @@ fi # if test "$build_modules" != 'no'; then - MAGICK_DEP_LIBS="$USER_LIBS $LCMS_LIBS $FREETYPE_LIBS $LQR_LIBS $FFTW_LIBS $FONTCONFIG_LIBS $XEXT_LIBS $IPC_LIBS $X11_LIBS $XT_LIBS $LZMA_LIBS $BZLIB_LIBS $ZLIB_LIBS $LTDL_LIBS $GDI32_LIBS $MATH_LIBS $GOMP_LIBS $CL_LIBS $UMEM_LIBS $THREAD_LIBS" + MAGICK_DEP_LIBS="$USER_LIBS $LCMS_LIBS $FREETYPE_LIBS $LQR_LIBS $FFTW_LIBS $FONTCONFIG_LIBS $XEXT_LIBS $IPC_LIBS $X11_LIBS $XT_LIBS $LZMA_LIBS $BZLIB_LIBS $ZLIB_LIBS $LTDL_LIBS $GDI32_LIBS $MATH_LIBS $GOMP_LIBS $CL_LIBS $UMEM_LIBS $JE_LIBS $THREAD_LIBS" else - MAGICK_DEP_LIBS="$USER_LIBS $JBIG_LIBS $LCMS_LIBS $TIFF_LIBS $FREETYPE_LIBS $JPEG_LIBS $GS_LIBS $LQR_LIBS $PNG_LIBS $AUTOTRACE_LIBS $DJVU_LIBS $FFTW_LIBS $FPX_LIBS $FONTCONFIG_LIBS $WEBP_LIBS $WMF_LIBS $DPS_LIBS $XEXT_LIBS $XT_LIBS $IPC_LIBS $X11_LIBS $LZMA_LIBS $BZLIB_LIBS $OPENEXR_LIBS $OPENJPEG_LIBS $PANGO_LIBS $RSVG_LIBS $XML_LIBS $GVC_LIBS $ZLIB_LIBS $GDI32_LIBS $MATH_LIBS $GOMP_LIBS $CL_LIBS $UMEM_LIBS $THREAD_LIBS" + MAGICK_DEP_LIBS="$USER_LIBS $JBIG_LIBS $LCMS_LIBS $TIFF_LIBS $FREETYPE_LIBS $JPEG_LIBS $GS_LIBS $LQR_LIBS $PNG_LIBS $AUTOTRACE_LIBS $DJVU_LIBS $FFTW_LIBS $FPX_LIBS $FONTCONFIG_LIBS $WEBP_LIBS $WMF_LIBS $DPS_LIBS $XEXT_LIBS $XT_LIBS $IPC_LIBS $X11_LIBS $LZMA_LIBS $BZLIB_LIBS $OPENEXR_LIBS $OPENJPEG_LIBS $PANGO_LIBS $RSVG_LIBS $XML_LIBS $GVC_LIBS $ZLIB_LIBS $GDI32_LIBS $MATH_LIBS $GOMP_LIBS $CL_LIBS $UMEM_LIBS $JE_LIBS $THREAD_LIBS" fi AC_SUBST(MAGICK_DEP_LIBS) diff --git a/m4/jemalloc.m4 b/m4/jemalloc.m4 new file mode 100644 index 000000000..bb5dceb81 --- /dev/null +++ b/m4/jemalloc.m4 @@ -0,0 +1,88 @@ +dnl -------------------------------------------------------- -*- autoconf -*- +dnl Licensed to the Apache Software Foundation (ASF) under one or more +dnl contributor license agreements. See the NOTICE file distributed with +dnl this work for additional information regarding copyright ownership. +dnl The ASF licenses this file to You under the Apache License, Version 2.0 +dnl (the "License"); you may not use this file except in compliance with +dnl the License. You may obtain a copy of the License at +dnl +dnl http://www.apache.org/licenses/LICENSE-2.0 +dnl +dnl Unless required by applicable law or agreed to in writing, software +dnl distributed under the License is distributed on an "AS IS" BASIS, +dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +dnl See the License for the specific language governing permissions and +dnl limitations under the License. + +dnl +dnl jemalloc.m4: Trafficserver's jemalloc autoconf macros +dnl modified to skip other TS_ helpers +dnl + +AC_DEFUN([TS_CHECK_JEMALLOC], [ +AC_ARG_WITH([jemalloc-prefix], + [AS_HELP_STRING([--with-jemalloc-prefix=PREFIX],[Specify the jemalloc prefix [default=""]])], + [ + jemalloc_prefix="$withval" + ],[ + if test "`uname -s`" = "Darwin"; then + jemalloc_prefix="je_" + else + jemalloc_prefix="" + fi + ] +) +AC_DEFINE_UNQUOTED([prefix_jemalloc], [${jemalloc_prefix}], [jemalloc prefix]) + +enable_jemalloc=no +AC_ARG_WITH([jemalloc], [AS_HELP_STRING([--with-jemalloc=DIR], [use a specific jemalloc library])], +[ + if test "$withval" != "no"; then + if test "x${enable_tcmalloc}" = "xyes"; then + AC_MSG_ERROR([Cannot compile with both jemalloc and tcmalloc]) + fi + enable_jemalloc=yes + jemalloc_base_dir="$withval" + case "$withval" in + yes) + jemalloc_base_dir="/usr" + AC_MSG_CHECKING(checking for jemalloc includes standard directories) + ;; + *":"*) + jemalloc_include="`echo $withval |sed -e 's/:.*$//'`" + jemalloc_ldflags="`echo $withval |sed -e 's/^.*://'`" + AC_MSG_CHECKING(checking for jemalloc includes in $jemalloc_include libs in $jemalloc_ldflags) + ;; + *) + jemalloc_include="$withval/include" + jemalloc_ldflags="$withval/lib" + AC_MSG_CHECKING(checking for jemalloc includes in $withval) + ;; + esac + fi +]) + +has_jemalloc=0 +if test "$enable_jemalloc" != "no"; then + jemalloc_have_headers=0 + jemalloc_have_libs=0 + if test "$jemalloc_base_dir" != "/usr"; then + CFLAGS="${CFLAGS} -I${jemalloc_include}" + LDFLAGS="${LDFLAGS} -L${jemalloc_ldflags}" + LIBTOOL_LINK_FLAGS="${LIBTOOL_LINK_FLAGS} -R${jemalloc_ldflags}" + fi + func="${jemalloc_prefix}malloc_stats_print" + AC_CHECK_LIB(jemalloc, ${func}, [jemalloc_have_libs=1]) + if test "$jemalloc_have_libs" != "0"; then + AC_CHECK_HEADERS([jemalloc/jemalloc.h], [jemalloc_have_headers=1]) + fi + if test "$jemalloc_have_headers" != "0"; then + has_jemalloc=1 + LIBS="${LIBS} -ljemalloc" + AC_DEFINE(has_jemalloc, [1], [Link/compile against jemalloc]) + else + AC_MSG_ERROR([Couldn't find a jemalloc installation]) + fi +fi +AC_SUBST(has_jemalloc) +]) -- 2.50.1