diff options
author | Federico Ceratto <federico.ceratto@gmail.com> | 2016-11-23 15:49:14 +0000 |
---|---|---|
committer | Federico Ceratto <federico.ceratto@gmail.com> | 2016-11-23 15:49:14 +0000 |
commit | 68141d9dac0c08e51d257feef16a79086dd8a2df (patch) | |
tree | f4a0f5d31ed2194b5991130754b297b9c8c076e6 /m4 | |
parent | Release v. 1.3.0+dfsg-1 to Unstable (diff) | |
parent | New upstream version 1.4.0+dfsg (diff) | |
download | netdata-68141d9dac0c08e51d257feef16a79086dd8a2df.tar.xz netdata-68141d9dac0c08e51d257feef16a79086dd8a2df.zip |
Merge tag 'upstream/1.4.0+dfsg'
Upstream version 1.4.0+dfsg
Diffstat (limited to 'm4')
-rw-r--r-- | m4/ax_c___atomic.m4 | 30 | ||||
-rw-r--r-- | m4/ax_c__generic.m4 | 28 | ||||
-rwxr-xr-x | m4/ax_c_mallinfo.m4 | 24 | ||||
-rwxr-xr-x | m4/ax_c_mallopt.m4 | 20 | ||||
-rw-r--r-- | m4/ax_check_compile_flag.m4 | 74 | ||||
-rw-r--r-- | m4/jemalloc.m4 | 88 | ||||
-rw-r--r-- | m4/tcmalloc.m4 | 58 |
7 files changed, 322 insertions, 0 deletions
diff --git a/m4/ax_c___atomic.m4 b/m4/ax_c___atomic.m4 new file mode 100644 index 00000000..131929ae --- /dev/null +++ b/m4/ax_c___atomic.m4 @@ -0,0 +1,30 @@ +# AC_C___ATOMIC +# ------------- +# Define HAVE_C___ATOMIC if __atomic works. +AN_IDENTIFIER([__atomic], [AC_C___ATOMIC]) +AC_DEFUN([AC_C___ATOMIC], +[AC_CACHE_CHECK([for __atomic], ac_cv_c___atomic, +[AC_LINK_IFELSE( + [AC_LANG_SOURCE( + [[int + main (int argc, char **argv) + { + volatile unsigned long ul1 = 1, ul2 = 0, ul3 = 2; + __atomic_compare_exchange(&ul1, &ul2, &ul3, 1, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); + __atomic_fetch_add(&ul1, 1, __ATOMIC_SEQ_CST); + __atomic_fetch_sub(&ul3, 1, __ATOMIC_SEQ_CST); + volatile unsigned long long ull1 = 1, ull2 = 0, ull3 = 2; + __atomic_compare_exchange(&ull1, &ull2, &ull3, 1, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); + __atomic_fetch_add(&ull1, 1, __ATOMIC_SEQ_CST); + __atomic_fetch_sub(&ull3, 1, __ATOMIC_SEQ_CST); + return 0; + } + ]])], + [ac_cv_c___atomic=yes], + [ac_cv_c___atomic=no])]) +if test $ac_cv_c___atomic = yes; then + AC_DEFINE([HAVE_C___ATOMIC], 1, + [Define to 1 if __atomic operations work.]) +fi +])# AC_C___ATOMIC + diff --git a/m4/ax_c__generic.m4 b/m4/ax_c__generic.m4 new file mode 100644 index 00000000..0c4dd52c --- /dev/null +++ b/m4/ax_c__generic.m4 @@ -0,0 +1,28 @@ +# https://lists.gnu.org/archive/html/autoconf-commit/2012-12/msg00004.html +# AC_C__GENERIC +# ------------- +# Define HAVE_C__GENERIC if _Generic works, a la C11. +AN_IDENTIFIER([_Generic], [AC_C__GENERIC]) +AC_DEFUN([AC_C__GENERIC], +[AC_CACHE_CHECK([for _Generic], ac_cv_c__Generic, +[AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[int + main (int argc, char **argv) + { + int a = _Generic (argc, int: argc = 1); + int *b = &_Generic (argc, default: argc); + char ***c = _Generic (argv, int: argc, default: argv ? &argv : 0); + _Generic (1 ? 0 : b, int: a, default: b) = &argc; + _Generic (a = 1, default: a) = 3; + return a + !b + !c; + } + ]])], + [ac_cv_c__Generic=yes], + [ac_cv_c__Generic=no])]) +if test $ac_cv_c__Generic = yes; then + AC_DEFINE([HAVE_C__GENERIC], 1, + [Define to 1 if C11-style _Generic works.]) +fi +])# AC_C__GENERIC + diff --git a/m4/ax_c_mallinfo.m4 b/m4/ax_c_mallinfo.m4 new file mode 100755 index 00000000..af8d0481 --- /dev/null +++ b/m4/ax_c_mallinfo.m4 @@ -0,0 +1,24 @@ +# AC_C_MALLINFO +# ------------- +# Define HAVE_C_MALLINFO if mallinfo() works. +AN_IDENTIFIER([mallinfo], [AC_C_MALLINFO]) +AC_DEFUN([AC_C_MALLINFO], +[AC_CACHE_CHECK([for mallinfo], ac_cv_c_mallinfo, +[AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include <malloc.h>]], + [[ + struct mallinfo mi = mallinfo(); + /* make sure that fields exists */ + mi.uordblks = 0; + mi.hblkhd = 0; + mi.arena = 0; + ]] + )], + [ac_cv_c_mallinfo=yes], + [ac_cv_c_mallinfo=no])]) +if test $ac_cv_c_mallinfo = yes; then + AC_DEFINE([HAVE_C_MALLINFO], 1, + [Define to 1 if glibc mallinfo exists.]) +fi +])# AC_C_MALLINFO diff --git a/m4/ax_c_mallopt.m4 b/m4/ax_c_mallopt.m4 new file mode 100755 index 00000000..31c4fdc3 --- /dev/null +++ b/m4/ax_c_mallopt.m4 @@ -0,0 +1,20 @@ +# AC_C_MALLOPT +# ------------- +# Define HAVE_C_MALLOPT if mallopt() works. +AN_IDENTIFIER([mallopt], [AC_C_MALLOPT]) +AC_DEFUN([AC_C_MALLOPT], +[AC_CACHE_CHECK([for mallopt], ac_cv_c_mallopt, +[AC_LINK_IFELSE( + [AC_LANG_SOURCE( + [[#include <malloc.h> + int main(int argc, char **argv) { + mallopt(M_ARENA_MAX, 1); + } + ]])], + [ac_cv_c_mallopt=yes], + [ac_cv_c_mallopt=no])]) +if test $ac_cv_c_mallopt = yes; then + AC_DEFINE([HAVE_C_MALLOPT], 1, + [Define to 1 if glibc mallopt exists.]) +fi +])# AC_C_MALLOPT diff --git a/m4/ax_check_compile_flag.m4 b/m4/ax_check_compile_flag.m4 new file mode 100644 index 00000000..51df0c09 --- /dev/null +++ b/m4/ax_check_compile_flag.m4 @@ -0,0 +1,74 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT]) +# +# DESCRIPTION +# +# Check whether the given FLAG works with the current language's compiler +# or gives an error. (Warnings, however, are ignored) +# +# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on +# success/failure. +# +# If EXTRA-FLAGS is defined, it is added to the current language's default +# flags (e.g. CFLAGS) when the check is done. The check is thus made with +# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to +# force the compiler to issue an error when a bad flag is given. +# +# INPUT gives an alternative input source to AC_COMPILE_IFELSE. +# +# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this +# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG. +# +# LICENSE +# +# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de> +# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com> +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation, either version 3 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see <http://www.gnu.org/licenses/>. +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 3 + +AC_DEFUN([AX_CHECK_COMPILE_FLAG], +[AC_PREREQ(2.59)dnl for _AC_LANG_PREFIX +AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl +AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [ + ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS + _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1" + AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])], + [AS_VAR_SET(CACHEVAR,[yes])], + [AS_VAR_SET(CACHEVAR,[no])]) + _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags]) +AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes], + [m4_default([$2], :)], + [m4_default([$3], :)]) +AS_VAR_POPDEF([CACHEVAR])dnl +])dnl AX_CHECK_COMPILE_FLAGS diff --git a/m4/jemalloc.m4 b/m4/jemalloc.m4 new file mode 100644 index 00000000..bb5dceb8 --- /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) +]) diff --git a/m4/tcmalloc.m4 b/m4/tcmalloc.m4 new file mode 100644 index 00000000..e84697dc --- /dev/null +++ b/m4/tcmalloc.m4 @@ -0,0 +1,58 @@ +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 tcmalloc.m4: Trafficserver's tcmalloc autoconf macros +dnl modified to skip other TS_ helpers +dnl + +dnl This is kinda fugly, but need a way to both specify a directory and which +dnl of the many tcmalloc libraries to use ... +AC_DEFUN([TS_CHECK_TCMALLOC], [ +AC_ARG_WITH([tcmalloc-lib], + [AS_HELP_STRING([--with-tcmalloc-lib],[specify the tcmalloc library to use [default=tcmalloc]])], + [ + with_tcmalloc_lib="$withval" + ],[ + with_tcmalloc_lib="tcmalloc" + ] +) + +has_tcmalloc=0 +AC_ARG_WITH([tcmalloc], [AS_HELP_STRING([--with-tcmalloc=DIR], [use the tcmalloc library])], +[ + if test "$withval" != "no"; then + if test "x${enable_jemalloc}" = "xyes"; then + AC_MSG_ERROR([Cannot compile with both tcmalloc and jemalloc]) + fi + tcmalloc_have_lib=0 + if test "x$withval" != "xyes" && test "x$withval" != "x"; then + tcmalloc_ldflags="$withval/lib" + LDFLAGS="${LDFLAGS} -L${tcmalloc_ldflags}" + LIBTOOL_LINK_FLAGS="${LIBTOOL_LINK_FLAGS} -rpath ${tcmalloc_ldflags}" + fi + AC_CHECK_LIB(${with_tcmalloc_lib}, tc_cfree, [tcmalloc_have_lib=1]) + if test "$tcmalloc_have_lib" != "0"; then + LIBS="${LIBS} -l${with_tcmalloc_lib}" + has_tcmalloc=1 + AC_DEFINE(has_tcmalloc, [1], [Link/compile against tcmalloc]) + else + AC_MSG_ERROR([Couldn't find a tcmalloc installation]) + fi + fi +]) +AC_SUBST(has_tcmalloc) +]) |