diff options
| author | Jason Evans <jasone@canonware.com> | 2016-11-02 19:18:33 -0700 |
|---|---|---|
| committer | Jason Evans <jasone@canonware.com> | 2016-11-02 19:18:33 -0700 |
| commit | d82f2b3473daef45d92d2a83d11487b22f9db4d3 (patch) | |
| tree | bbc90aba058c1c43ddc8e86372f46e890b076c1b | |
| parent | 795f6689dec28f161afbf5964ef1b17288dd384d (diff) | |
| download | platform_external_jemalloc_new-d82f2b3473daef45d92d2a83d11487b22f9db4d3.tar.gz platform_external_jemalloc_new-d82f2b3473daef45d92d2a83d11487b22f9db4d3.tar.bz2 platform_external_jemalloc_new-d82f2b3473daef45d92d2a83d11487b22f9db4d3.zip | |
Do not use syscall(2) on OS X 10.12 (deprecated).
| -rw-r--r-- | configure.ac | 17 | ||||
| -rw-r--r-- | include/jemalloc/internal/jemalloc_internal_defs.h.in | 3 | ||||
| -rw-r--r-- | src/pages.c | 6 | ||||
| -rw-r--r-- | src/util.c | 2 |
4 files changed, 24 insertions, 4 deletions
diff --git a/configure.ac b/configure.ac index 2713cbc2..6fc44c3e 100644 --- a/configure.ac +++ b/configure.ac @@ -1350,6 +1350,23 @@ if test "x${je_cv_mach_absolute_time}" = "xyes" ; then AC_DEFINE([JEMALLOC_HAVE_MACH_ABSOLUTE_TIME]) fi +dnl Check if syscall(2) is usable. Treat warnings as errors, so that e.g. OS X +dnl 10.12's deprecation warning prevents use. +SAVED_CFLAGS="${CFLAGS}" +JE_CFLAGS_APPEND([-Werror]) +JE_COMPILABLE([syscall(2)], [ +#define _GNU_SOURCE +#include <sys/syscall.h> +#include <unistd.h> +], [ + syscall(SYS_write, 2, "hello", 5); +], + [je_cv_syscall]) +CFLAGS="${SAVED_CFLAGS}" +if test "x$je_cv_syscall" = "xyes" ; then + AC_DEFINE([JEMALLOC_HAVE_SYSCALL], [ ]) +fi + dnl Check if the GNU-specific secure_getenv function exists. AC_CHECK_FUNC([secure_getenv], [have_secure_getenv="1"], diff --git a/include/jemalloc/internal/jemalloc_internal_defs.h.in b/include/jemalloc/internal/jemalloc_internal_defs.h.in index dcbad728..4d2daea8 100644 --- a/include/jemalloc/internal/jemalloc_internal_defs.h.in +++ b/include/jemalloc/internal/jemalloc_internal_defs.h.in @@ -71,6 +71,9 @@ */ #undef JEMALLOC_OSSPIN +/* Defined if syscall(2) is available. */ +#undef JEMALLOC_HAVE_SYSCALL + /* * Defined if secure_getenv(3) is available. */ diff --git a/src/pages.c b/src/pages.c index 84e22160..647952ac 100644 --- a/src/pages.c +++ b/src/pages.c @@ -219,7 +219,7 @@ os_overcommits_proc(void) char buf[1]; ssize_t nread; -#ifdef SYS_open +#if defined(JEMALLOC_HAVE_SYSCALL) && defined(SYS_open) fd = (int)syscall(SYS_open, "/proc/sys/vm/overcommit_memory", O_RDONLY); #else fd = open("/proc/sys/vm/overcommit_memory", O_RDONLY); @@ -227,13 +227,13 @@ os_overcommits_proc(void) if (fd == -1) return (false); /* Error. */ -#ifdef SYS_read +#if defined(JEMALLOC_HAVE_SYSCALL) && defined(SYS_read) nread = (ssize_t)syscall(SYS_read, fd, &buf, sizeof(buf)); #else nread = read(fd, &buf, sizeof(buf)); #endif -#ifdef SYS_close +#if defined(JEMALLOC_HAVE_SYSCALL) && defined(SYS_close) syscall(SYS_close, fd); #else close(fd); @@ -49,7 +49,7 @@ static void wrtmessage(void *cbopaque, const char *s) { -#ifdef SYS_write +#if defined(JEMALLOC_HAVE_SYSCALL) && defined(SYS_write) /* * Use syscall(2) rather than write(2) when possible in order to avoid * the possibility of memory allocation within libc. This is necessary |
