From ab0676d77e81268cd09b059260c75b38dbef2d51 Mon Sep 17 00:00:00 2001 From: Jay Date: Sat, 14 May 2022 05:19:25 +0800 Subject: [PATCH] update jemalloc to 5.3.0 (#23) Signed-off-by: Jay Lee --- .gitmodules | 3 +- Cargo.toml | 59 +- README.md | 2 +- ci/run.sh | 4 - jemalloc-ctl/Cargo.toml | 4 +- jemalloc-ctl/src/lib.rs | 4 +- jemalloc-ctl/src/macros.rs | 2 +- jemalloc-ctl/src/opt.rs | 8 +- jemalloc-ctl/src/stats.rs | 14 +- jemalloc-ctl/src/thread.rs | 2 +- jemalloc-sys/Cargo.toml | 7 +- jemalloc-sys/build.rs | 39 +- jemalloc-sys/configure/VERSION | 2 +- jemalloc-sys/configure/configure | 2266 +++++++++++++++-- jemalloc-sys/jemalloc | 2 +- jemalloc-sys/src/env.rs | 25 + jemalloc-sys/src/lib.rs | 18 +- jemallocator-global/Cargo.toml | 8 +- jemallocator/Cargo.toml | 56 + .../benches}/roundtrip.rs | 0 {src => jemallocator/src}/lib.rs | 0 .../tests}/background_thread_defaults.rs | 0 .../tests}/background_thread_enabled.rs | 0 {tests => jemallocator/tests}/ffi.rs | 0 .../tests}/grow_in_place.rs | 0 {tests => jemallocator/tests}/malloctl.rs | 0 .../tests}/shrink_in_place.rs | 0 {tests => jemallocator/tests}/smoke.rs | 0 {tests => jemallocator/tests}/smoke_ffi.rs | 0 {tests => jemallocator/tests}/usable_size.rs | 0 systest/Cargo.toml | 13 - systest/build.rs | 32 - systest/src/main.rs | 13 - 33 files changed, 2121 insertions(+), 462 deletions(-) create mode 100644 jemalloc-sys/src/env.rs create mode 100644 jemallocator/Cargo.toml rename {benches => jemallocator/benches}/roundtrip.rs (100%) rename {src => jemallocator/src}/lib.rs (100%) rename {tests => jemallocator/tests}/background_thread_defaults.rs (100%) rename {tests => jemallocator/tests}/background_thread_enabled.rs (100%) rename {tests => jemallocator/tests}/ffi.rs (100%) rename {tests => jemallocator/tests}/grow_in_place.rs (100%) rename {tests => jemallocator/tests}/malloctl.rs (100%) rename {tests => jemallocator/tests}/shrink_in_place.rs (100%) rename {tests => jemallocator/tests}/smoke.rs (100%) rename {tests => jemallocator/tests}/smoke_ffi.rs (100%) rename {tests => jemallocator/tests}/usable_size.rs (100%) delete mode 100644 systest/Cargo.toml delete mode 100644 systest/build.rs delete mode 100644 systest/src/main.rs diff --git a/.gitmodules b/.gitmodules index 4f142342ac..04dd40a572 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,3 @@ [submodule "jemalloc-sys/jemalloc"] path = jemalloc-sys/jemalloc - url = https://github.com/tikv/jemalloc - branch = v5.2.x + url = https://github.com/jemalloc/jemalloc diff --git a/Cargo.toml b/Cargo.toml index 84767a4ad4..e3912a8490 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,59 +1,2 @@ -[package] -name = "tikv-jemallocator" -# Make sure to update the version in the README as well: -version = "0.4.3" -authors = [ - "Alex Crichton ", - "Gonzalo Brito Gadeschi ", - "Simon Sapin ", - "Steven Fackler ", - "The TiKV Project Developers", -] -license = "MIT/Apache-2.0" -readme = "README.md" -keywords = ["allocator", "jemalloc"] -categories = ["memory-management", "api-bindings"] -repository = "https://github.com/tikv/jemallocator" -homepage = "https://github.com/tikv/jemallocator" -documentation = "https://docs.rs/tikv-jemallocator" -description = """ -A Rust allocator backed by jemalloc -""" -edition = "2018" - -[badges] -travis-ci = { repository = "tikv/jemallocator" } -codecov = { repository = "tikv/jemallocator" } -is-it-maintained-issue-resolution = { repository = "tikv/jemallocator" } -is-it-maintained-open-issues = { repository = "tikv/jemallocator" } -maintenance = { status = "actively-developed" } - -[lib] -test = false -bench = false - [workspace] -members = ["systest", "jemallocator-global", "jemalloc-ctl", "jemalloc-sys" ] - -[dependencies] -tikv-jemalloc-sys = { path = "jemalloc-sys", version = "0.4.0", default-features = false } -libc = { version = "^0.2.8", default-features = false } - -[dev-dependencies] -paste = "1" -tikv-jemalloc-ctl = { path = "jemalloc-ctl", version = "0.4" } - -[features] -default = ["background_threads_runtime_support"] -alloc_trait = [] -profiling = ["tikv-jemalloc-sys/profiling"] -debug = ["tikv-jemalloc-sys/debug"] -stats = ["tikv-jemalloc-sys/stats"] -background_threads_runtime_support = ["tikv-jemalloc-sys/background_threads_runtime_support"] -background_threads = ["tikv-jemalloc-sys/background_threads"] -unprefixed_malloc_on_supported_platforms = ["tikv-jemalloc-sys/unprefixed_malloc_on_supported_platforms"] -disable_initial_exec_tls = ["tikv-jemalloc-sys/disable_initial_exec_tls"] - -[package.metadata.docs.rs] -features = [] -rustdoc-args = [ "--cfg", "jemallocator_docs" ] +members = ["jemallocator", "jemallocator-global", "jemalloc-ctl", "jemalloc-sys"] diff --git a/README.md b/README.md index 35a8723994..ed06ec7102 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ To use `tikv-jemallocator` add it as a dependency: [dependencies] [target.'cfg(not(target_env = "msvc"))'.dependencies] -tikv-jemallocator = "0.4.0" +tikv-jemallocator = "0.4.3" ``` To set `tikv_jemallocator::Jemalloc` as the global allocator add this to your project: diff --git a/ci/run.sh b/ci/run.sh index de212ecc88..61182f318e 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -66,10 +66,6 @@ case "${TARGET}" in ;; esac -if rustc --version | grep -v nightly >/dev/null; then - # systest can't be built on nightly - cargo test --target "${TARGET}" -p systest -fi cargo test --target "${TARGET}" --manifest-path jemallocator-global/Cargo.toml cargo test --target "${TARGET}" \ --manifest-path jemallocator-global/Cargo.toml \ diff --git a/jemalloc-ctl/Cargo.toml b/jemalloc-ctl/Cargo.toml index 4f13a4e48b..7123cb37f6 100644 --- a/jemalloc-ctl/Cargo.toml +++ b/jemalloc-ctl/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tikv-jemalloc-ctl" -version = "0.4.2" +version = "0.4.3" authors = [ "Steven Fackler ", "Gonzalo Brito Gadeschi ", @@ -31,7 +31,7 @@ libc = { version = "0.2", default-features = false } paste = "1" [dev-dependencies] -tikv-jemallocator = { path = "..", version = "0.4.0" } +tikv-jemallocator = { path = "../jemallocator", version = "0.4.0" } [features] default = [] diff --git a/jemalloc-ctl/src/lib.rs b/jemalloc-ctl/src/lib.rs index 6911f0752a..a5aef998ad 100644 --- a/jemalloc-ctl/src/lib.rs +++ b/jemalloc-ctl/src/lib.rs @@ -169,8 +169,8 @@ option! { /// use tikv_jemalloc_ctl::max_background_threads; /// let m = max_background_threads::mib().unwrap(); /// println!("max_background_threads: {}", m.read().unwrap()); - /// m.write(0).unwrap(); - /// assert_eq!(m.read().unwrap(), 0); + /// m.write(2).unwrap(); + /// assert_eq!(m.read().unwrap(), 2); /// # /// # } // #[cfg(..)] /// # } diff --git a/jemalloc-ctl/src/macros.rs b/jemalloc-ctl/src/macros.rs index dc9a3d823e..ee4bd5ff01 100644 --- a/jemalloc-ctl/src/macros.rs +++ b/jemalloc-ctl/src/macros.rs @@ -26,7 +26,7 @@ macro_rules! types { Ok([<$id _mib>](Self::NAME.$name_to_mib()?)) } - /// Key [`::keys::Name`]. + /// Key [`crate::keys::Name`]. pub fn name() -> &'static crate::keys::Name { Self::NAME } diff --git a/jemalloc-ctl/src/opt.rs b/jemalloc-ctl/src/opt.rs index 40ec06b64d..dc7c17ac6e 100644 --- a/jemalloc-ctl/src/opt.rs +++ b/jemalloc-ctl/src/opt.rs @@ -166,7 +166,7 @@ option! { } option! { - lg_tcache_max[ str: b"opt.lg_tcache_max\0", non_str: 2 ] => libc::size_t | + tcache_max[ str: b"opt.tcache_max\0", non_str: 2 ] => libc::size_t | ops: r | docs: /// Maximum size class (log base 2) to cache in the thread-specific cache @@ -183,11 +183,11 @@ option! { /// # /// # fn main() { /// use tikv_jemalloc_ctl::opt; - /// let lg_tcache_max = opt::lg_tcache_max::read().unwrap(); - /// println!("max cached allocation size: {}", 1 << lg_tcache_max); + /// let tcache_max = opt::tcache_max::read().unwrap(); + /// println!("max cached allocation size: {}", tcache_max); /// # } /// ``` - mib_docs: /// See [`lg_tcache_max`]. + mib_docs: /// See [`tcache_max`]. } option! { diff --git a/jemalloc-ctl/src/stats.rs b/jemalloc-ctl/src/stats.rs index 66cbfb33b0..8c8d6704e6 100644 --- a/jemalloc-ctl/src/stats.rs +++ b/jemalloc-ctl/src/stats.rs @@ -1,7 +1,7 @@ //! Global allocator statistics. //! //! `jemalloc` tracks a wide variety of statistics. Many of them are cached, and -//! only refreshed when the `jemalloc` "epoch" is advanced. See the [`::epoch`] type +//! only refreshed when the `jemalloc` "epoch" is advanced. See the [`crate::epoch`] type //! for more information. option! { @@ -11,7 +11,7 @@ option! { /// Total number of bytes allocated by the application. /// /// This statistic is cached, and is only refreshed when the epoch is - /// advanced. See the [`::epoch`] type for more information. + /// advanced. See the [`crate::epoch`] type for more information. /// /// This corresponds to `stats.allocated` in jemalloc's API. /// @@ -46,7 +46,7 @@ option! { /// value returned by [`allocated`]. /// /// This statistic is cached, and is only refreshed when the epoch is - /// advanced. See the [`::epoch`] type for more information. + /// advanced. See the [`crate::epoch`] type for more information. /// /// This corresponds to `stats.active` in jemalloc's API. /// @@ -78,7 +78,7 @@ option! { /// Total number of bytes dedicated to `jemalloc` metadata. /// /// This statistic is cached, and is only refreshed when the epoch is - /// advanced. See the [`::epoch`] type for more information. + /// advanced. See the [`crate::epoch`] type for more information. /// /// This corresponds to `stats.metadata` in jemalloc's API. /// @@ -116,7 +116,7 @@ option! { /// value returned by [`active`]. /// /// This statistic is cached, and is only refreshed when the epoch is - /// advanced. See the [`::epoch`] type for more information. + /// advanced. See the [`crate::epoch`] type for more information. /// /// This corresponds to `stats.resident` in jemalloc's API. /// @@ -151,7 +151,7 @@ option! { /// larger than the value returned by [`active`]. /// /// This statistic is cached, and is only refreshed when the epoch is - /// advanced. See the [`::epoch`] type for more information. + /// advanced. See the [`crate::epoch`] type for more information. /// /// This corresponds to `stats.mapped` in jemalloc's API. /// @@ -186,7 +186,7 @@ option! { /// excluded from mapped memory statistics, e.g. [`mapped`]. /// /// This statistic is cached, and is only refreshed when the epoch is - /// advanced. See the [`::epoch`] type for more information. + /// advanced. See the [`crate::epoch`] type for more information. /// /// This corresponds to `stats.retained` in jemalloc's API. /// diff --git a/jemalloc-ctl/src/thread.rs b/jemalloc-ctl/src/thread.rs index 6ef030aac1..5980bea971 100644 --- a/jemalloc-ctl/src/thread.rs +++ b/jemalloc-ctl/src/thread.rs @@ -9,7 +9,7 @@ option! { docs: /// Access to the total number of bytes allocated by the current thread. /// - /// Unlike [`::stats::allocated`], the value returned by this type is not the + /// Unlike [`crate::stats::allocated`], the value returned by this type is not the /// number of bytes *currently* allocated, but rather the number of bytes /// that have *ever* been allocated by this thread. /// diff --git a/jemalloc-sys/Cargo.toml b/jemalloc-sys/Cargo.toml index a07b19c3c1..050e8832f4 100644 --- a/jemalloc-sys/Cargo.toml +++ b/jemalloc-sys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tikv-jemalloc-sys" -version = "0.4.3+5.2.1-patched.2" +version = "0.4.3+5.3.0" authors = [ "Alex Crichton ", "Gonzalo Brito Gadeschi ", @@ -20,16 +20,11 @@ Rust FFI bindings to jemalloc edition = "2018" [badges] -travis-ci = { repository = "tikv/jemallocator" } codecov = { repository = "tikv/jemallocator" } is-it-maintained-issue-resolution = { repository = "tikv/jemallocator" } is-it-maintained-open-issues = { repository = "tikv/jemallocator" } maintenance = { status = "actively-developed" } -[lib] -test = false -bench = false - [dependencies] libc = { version = "^0.2.8", default-features = false } diff --git a/jemalloc-sys/build.rs b/jemalloc-sys/build.rs index f1828c4239..00ce683699 100644 --- a/jemalloc-sys/build.rs +++ b/jemalloc-sys/build.rs @@ -13,32 +13,7 @@ use std::fs; use std::path::{Path, PathBuf}; use std::process::Command; -// `jemalloc` is known not to work on these targets: -const UNSUPPORTED_TARGETS: &[&str] = &[ - "rumprun", - "bitrig", - "emscripten", - "fuchsia", - "redox", - "wasm32", -]; - -// `jemalloc-sys` is not tested on these targets in CI: -const UNTESTED_TARGETS: &[&str] = &["openbsd", "msvc"]; - -// `jemalloc`'s background_thread support is known not to work on these targets: -const NO_BG_THREAD_TARGETS: &[&str] = &["musl"]; - -// targets that don't support unprefixed `malloc` -// -// “it was found that the `realpath` function in libc would allocate with libc malloc -// (not jemalloc malloc), and then the standard library would free with jemalloc free, -// causing a segfault.” -// https://github.com/rust-lang/rust/commit/e3b414d8612314e74e2b0ebde1ed5c6997d28e8d -// https://github.com/rust-lang/rust/commit/536011d929ecbd1170baf34e09580e567c971f95 -// https://github.com/rust-lang/rust/commit/9f3de647326fbe50e0e283b9018ab7c41abccde3 -// https://github.com/rust-lang/rust/commit/ed015456a114ae907a36af80c06f81ea93182a24 -const NO_UNPREFIXED_MALLOC: &[&str] = &["android", "dragonfly", "musl", "darwin"]; +include!("src/env.rs"); macro_rules! info { ($($args:tt)*) => { println!($($args)*) } @@ -78,7 +53,11 @@ fn main() { let mut use_prefix = env::var("CARGO_FEATURE_UNPREFIXED_MALLOC_ON_SUPPORTED_PLATFORMS").is_err(); - if !use_prefix && NO_UNPREFIXED_MALLOC.iter().any(|i| target.contains(i)) { + if !use_prefix + && NO_UNPREFIXED_MALLOC_TARGETS + .iter() + .any(|i| target.contains(i)) + { warning!( "Unprefixed `malloc` requested on unsupported platform `{}` => using prefixed `malloc`", target @@ -164,7 +143,9 @@ fn main() { .env("CFLAGS", cflags.clone()) .env("LDFLAGS", cflags.clone()) .env("CPPFLAGS", cflags) - .arg("--disable-cxx"); + .arg("--disable-cxx") + .arg("--enable-doc=no") + .arg("--enable-shared=no"); if target.contains("ios") { // newer iOS deviced have 16kb page sizes: @@ -307,7 +288,7 @@ fn main() { if target.contains("android") { println!("cargo:rustc-link-lib=gcc"); } else if !target.contains("windows") { - println!("cargo:rustc-link-lib=pthread"); + println!("cargo:rustc-link-arg=-pthread"); } // GCC may generate a __atomic_exchange_1 library call which requires -latomic // during the final linking. https://github.com/riscv-collab/riscv-gcc/issues/12 diff --git a/jemalloc-sys/configure/VERSION b/jemalloc-sys/configure/VERSION index 63adf1c2af..1dcfea03fc 100644 --- a/jemalloc-sys/configure/VERSION +++ b/jemalloc-sys/configure/VERSION @@ -1 +1 @@ -5.2.1-2-g172143a2979d9d948035423ce347e35cd1388fc3 +5.3.0-0-g54eaed1d8b56b1aa528be3bdd1877e59c56fa90c diff --git a/jemalloc-sys/configure/configure b/jemalloc-sys/configure/configure index 403f5ba450..7c4e6e266c 100755 --- a/jemalloc-sys/configure/configure +++ b/jemalloc-sys/configure/configure @@ -630,6 +630,8 @@ enable_zone_allocator enable_tls enable_lazy_lock libdl +enable_uaf_detection +enable_opt_size_checks enable_opt_safety_checks enable_readlinkat enable_log @@ -704,6 +706,7 @@ SPECIFIED_CXXFLAGS CONFIGURE_CXXFLAGS enable_cxx HAVE_CXX14 +HAVE_CXX17 ac_ct_CXX CXXFLAGS CXX @@ -803,7 +806,10 @@ enable_cache_oblivious enable_log enable_readlinkat enable_opt_safety_checks +enable_opt_size_checks +enable_uaf_detection with_lg_quantum +with_lg_slab_maxregs with_lg_page with_lg_hugepage enable_libdl @@ -1437,7 +1443,7 @@ Optional Features: --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --disable-cxx Disable C++ integration --enable-autogen Automatically regenerate configure output - --enable-documentation Build documentation + --enable-doc Build documentation --enable-shared Build shared libaries --enable-static Build static libaries --enable-debug Build debugging code @@ -1459,6 +1465,11 @@ Optional Features: --enable-opt-safety-checks Perform certain low-overhead checks, even in opt mode + --enable-opt-size-checks + Perform sized-deallocation argument checks, even in + opt mode + --enable-uaf-detection Allow sampled junk-filling on deallocation to detect + use-after-free --disable-libdl Do not use libdl --disable-syscall Disable use of syscall(2) --enable-lazy-lock Enable lazy locking (only lock when multi-threaded) @@ -1491,6 +1502,9 @@ Optional Packages: dynamically linking --with-lg-quantum= Base 2 log of minimum allocation alignment + --with-lg-slab-maxregs= + Base 2 log of maximum number of regions in a slab + (used with malloc_conf slab_sizes) --with-lg-page= Base 2 log of system page size --with-lg-hugepage= @@ -2633,12 +2647,14 @@ objroot="" abs_objroot="`pwd`/" -if test "x$prefix" = "xNONE" ; then - prefix="/usr/local" -fi -if test "x$exec_prefix" = "xNONE" ; then - exec_prefix=$prefix -fi +case "$prefix" in + *\ * ) as_fn_error $? "Prefix should not contain spaces" "$LINENO" 5 ;; + "NONE" ) prefix="/usr/local" ;; +esac +case "$exec_prefix" in + *\ * ) as_fn_error $? "Exec prefix should not contain spaces" "$LINENO" 5 ;; + "NONE" ) exec_prefix=$prefix ;; +esac PREFIX=$prefix BINDIR=`eval echo $bindir` @@ -3675,8 +3691,9 @@ fi if test "x$je_cv_cflags_added" = "x-std=gnu11" ; then - cat >>confdefs.h <<_ACEOF -#define JEMALLOC_HAS_RESTRICT 1 + +cat >>confdefs.h <<_ACEOF +#define JEMALLOC_HAS_RESTRICT _ACEOF else @@ -3732,13 +3749,65 @@ fi if test "x$je_cv_cflags_added" = "x-std=gnu99" ; then - cat >>confdefs.h <<_ACEOF -#define JEMALLOC_HAS_RESTRICT 1 + +cat >>confdefs.h <<_ACEOF +#define JEMALLOC_HAS_RESTRICT _ACEOF fi fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiler supports -Werror=unknown-warning-option" >&5 +$as_echo_n "checking whether compiler supports -Werror=unknown-warning-option... " >&6; } +T_CONFIGURE_CFLAGS="${CONFIGURE_CFLAGS}" +T_APPEND_V=-Werror=unknown-warning-option + if test "x${CONFIGURE_CFLAGS}" = "x" -o "x${T_APPEND_V}" = "x" ; then + CONFIGURE_CFLAGS="${CONFIGURE_CFLAGS}${T_APPEND_V}" +else + CONFIGURE_CFLAGS="${CONFIGURE_CFLAGS} ${T_APPEND_V}" +fi + + +if test "x${CONFIGURE_CFLAGS}" = "x" -o "x${SPECIFIED_CFLAGS}" = "x" ; then + CFLAGS="${CONFIGURE_CFLAGS}${SPECIFIED_CFLAGS}" +else + CFLAGS="${CONFIGURE_CFLAGS} ${SPECIFIED_CFLAGS}" +fi + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + +int +main () +{ + + return 0; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + je_cv_cflags_added=-Werror=unknown-warning-option + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + je_cv_cflags_added= + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + CONFIGURE_CFLAGS="${T_CONFIGURE_CFLAGS}" + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +if test "x${CONFIGURE_CFLAGS}" = "x" -o "x${SPECIFIED_CFLAGS}" = "x" ; then + CFLAGS="${CONFIGURE_CFLAGS}${SPECIFIED_CFLAGS}" +else + CFLAGS="${CONFIGURE_CFLAGS} ${SPECIFIED_CFLAGS}" +fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiler supports -Wall" >&5 $as_echo_n "checking whether compiler supports -Wall... " >&6; } T_CONFIGURE_CFLAGS="${CONFIGURE_CFLAGS}" @@ -4045,6 +4114,210 @@ fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiler supports -Wpointer-arith" >&5 +$as_echo_n "checking whether compiler supports -Wpointer-arith... " >&6; } +T_CONFIGURE_CFLAGS="${CONFIGURE_CFLAGS}" +T_APPEND_V=-Wpointer-arith + if test "x${CONFIGURE_CFLAGS}" = "x" -o "x${T_APPEND_V}" = "x" ; then + CONFIGURE_CFLAGS="${CONFIGURE_CFLAGS}${T_APPEND_V}" +else + CONFIGURE_CFLAGS="${CONFIGURE_CFLAGS} ${T_APPEND_V}" +fi + + +if test "x${CONFIGURE_CFLAGS}" = "x" -o "x${SPECIFIED_CFLAGS}" = "x" ; then + CFLAGS="${CONFIGURE_CFLAGS}${SPECIFIED_CFLAGS}" +else + CFLAGS="${CONFIGURE_CFLAGS} ${SPECIFIED_CFLAGS}" +fi + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + +int +main () +{ + + return 0; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + je_cv_cflags_added=-Wpointer-arith + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + je_cv_cflags_added= + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + CONFIGURE_CFLAGS="${T_CONFIGURE_CFLAGS}" + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +if test "x${CONFIGURE_CFLAGS}" = "x" -o "x${SPECIFIED_CFLAGS}" = "x" ; then + CFLAGS="${CONFIGURE_CFLAGS}${SPECIFIED_CFLAGS}" +else + CFLAGS="${CONFIGURE_CFLAGS} ${SPECIFIED_CFLAGS}" +fi + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiler supports -Wno-missing-braces" >&5 +$as_echo_n "checking whether compiler supports -Wno-missing-braces... " >&6; } +T_CONFIGURE_CFLAGS="${CONFIGURE_CFLAGS}" +T_APPEND_V=-Wno-missing-braces + if test "x${CONFIGURE_CFLAGS}" = "x" -o "x${T_APPEND_V}" = "x" ; then + CONFIGURE_CFLAGS="${CONFIGURE_CFLAGS}${T_APPEND_V}" +else + CONFIGURE_CFLAGS="${CONFIGURE_CFLAGS} ${T_APPEND_V}" +fi + + +if test "x${CONFIGURE_CFLAGS}" = "x" -o "x${SPECIFIED_CFLAGS}" = "x" ; then + CFLAGS="${CONFIGURE_CFLAGS}${SPECIFIED_CFLAGS}" +else + CFLAGS="${CONFIGURE_CFLAGS} ${SPECIFIED_CFLAGS}" +fi + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + +int +main () +{ + + return 0; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + je_cv_cflags_added=-Wno-missing-braces + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + je_cv_cflags_added= + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + CONFIGURE_CFLAGS="${T_CONFIGURE_CFLAGS}" + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +if test "x${CONFIGURE_CFLAGS}" = "x" -o "x${SPECIFIED_CFLAGS}" = "x" ; then + CFLAGS="${CONFIGURE_CFLAGS}${SPECIFIED_CFLAGS}" +else + CFLAGS="${CONFIGURE_CFLAGS} ${SPECIFIED_CFLAGS}" +fi + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiler supports -Wno-missing-field-initializers" >&5 +$as_echo_n "checking whether compiler supports -Wno-missing-field-initializers... " >&6; } +T_CONFIGURE_CFLAGS="${CONFIGURE_CFLAGS}" +T_APPEND_V=-Wno-missing-field-initializers + if test "x${CONFIGURE_CFLAGS}" = "x" -o "x${T_APPEND_V}" = "x" ; then + CONFIGURE_CFLAGS="${CONFIGURE_CFLAGS}${T_APPEND_V}" +else + CONFIGURE_CFLAGS="${CONFIGURE_CFLAGS} ${T_APPEND_V}" +fi + + +if test "x${CONFIGURE_CFLAGS}" = "x" -o "x${SPECIFIED_CFLAGS}" = "x" ; then + CFLAGS="${CONFIGURE_CFLAGS}${SPECIFIED_CFLAGS}" +else + CFLAGS="${CONFIGURE_CFLAGS} ${SPECIFIED_CFLAGS}" +fi + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + +int +main () +{ + + return 0; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + je_cv_cflags_added=-Wno-missing-field-initializers + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + je_cv_cflags_added= + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + CONFIGURE_CFLAGS="${T_CONFIGURE_CFLAGS}" + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +if test "x${CONFIGURE_CFLAGS}" = "x" -o "x${SPECIFIED_CFLAGS}" = "x" ; then + CFLAGS="${CONFIGURE_CFLAGS}${SPECIFIED_CFLAGS}" +else + CFLAGS="${CONFIGURE_CFLAGS} ${SPECIFIED_CFLAGS}" +fi + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiler supports -Wno-missing-attributes" >&5 +$as_echo_n "checking whether compiler supports -Wno-missing-attributes... " >&6; } +T_CONFIGURE_CFLAGS="${CONFIGURE_CFLAGS}" +T_APPEND_V=-Wno-missing-attributes + if test "x${CONFIGURE_CFLAGS}" = "x" -o "x${T_APPEND_V}" = "x" ; then + CONFIGURE_CFLAGS="${CONFIGURE_CFLAGS}${T_APPEND_V}" +else + CONFIGURE_CFLAGS="${CONFIGURE_CFLAGS} ${T_APPEND_V}" +fi + + +if test "x${CONFIGURE_CFLAGS}" = "x" -o "x${SPECIFIED_CFLAGS}" = "x" ; then + CFLAGS="${CONFIGURE_CFLAGS}${SPECIFIED_CFLAGS}" +else + CFLAGS="${CONFIGURE_CFLAGS} ${SPECIFIED_CFLAGS}" +fi + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + +int +main () +{ + + return 0; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + je_cv_cflags_added=-Wno-missing-attributes + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + je_cv_cflags_added= + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + CONFIGURE_CFLAGS="${T_CONFIGURE_CFLAGS}" + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +if test "x${CONFIGURE_CFLAGS}" = "x" -o "x${SPECIFIED_CFLAGS}" = "x" ; then + CFLAGS="${CONFIGURE_CFLAGS}${SPECIFIED_CFLAGS}" +else + CFLAGS="${CONFIGURE_CFLAGS} ${SPECIFIED_CFLAGS}" +fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiler supports -pipe" >&5 $as_echo_n "checking whether compiler supports -pipe... " >&6; } T_CONFIGURE_CFLAGS="${CONFIGURE_CFLAGS}" @@ -4725,7 +4998,7 @@ fi if test "x$enable_cxx" = "x1" ; then # =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html +# https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html # =========================================================================== # # SYNOPSIS @@ -4759,13 +5032,20 @@ if test "x$enable_cxx" = "x1" ; then # Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov # Copyright (c) 2015 Paul Norman # Copyright (c) 2015 Moritz Klammler +# Copyright (c) 2016, 2018 Krzesimir Nowak +# Copyright (c) 2019 Enji Cooper # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. -#serial 4 +#serial 11 + + + + + @@ -5044,19 +5324,28 @@ ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ex ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - ax_cxx_compile_cxx14_required=false + ax_cxx_compile_alternatives="17 1z" ax_cxx_compile_cxx17_required=false ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu ac_success=no - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++14 features by default" >&5 -$as_echo_n "checking whether $CXX supports C++14 features by default... " >&6; } -if ${ax_cv_cxx_compile_cxx14+:} false; then : + + + + if test x$ac_success = xno; then + for alternative in ${ax_cxx_compile_alternatives}; do + for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do + cachevar=`$as_echo "ax_cv_cxx_compile_cxx17_$switch" | $as_tr_sh` + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++17 features with $switch" >&5 +$as_echo_n "checking whether $CXX supports C++17 features with $switch... " >&6; } +if eval \${$cachevar+:} false; then : $as_echo_n "(cached) " >&6 else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + ac_save_CXX="$CXX" + CXX="$CXX $switch" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -5092,11 +5381,13 @@ namespace cxx11 struct Base { + virtual ~Base() {} virtual void f() {} }; struct Derived : public Base { + virtual ~Derived() override {} virtual void f() override {} }; @@ -5421,7 +5712,7 @@ namespace cxx14 } - namespace test_digit_seperators + namespace test_digit_separators { constexpr auto ten_million = 100'000'000; @@ -5464,33 +5755,456 @@ namespace cxx14 -_ACEOF + +// If the compiler admits that it is not ready for C++17, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 201703L + +#error "This is not a C++17 compiler" + +#else + +#include +#include +#include + +namespace cxx17 +{ + + namespace test_constexpr_lambdas + { + + constexpr int foo = [](){return 42;}(); + + } + + namespace test::nested_namespace::definitions + { + + } + + namespace test_fold_expression + { + + template + int multiply(Args... args) + { + return (args * ... * 1); + } + + template + bool all(Args... args) + { + return (args && ...); + } + + } + + namespace test_extended_static_assert + { + + static_assert (true); + + } + + namespace test_auto_brace_init_list + { + + auto foo = {5}; + auto bar {5}; + + static_assert(std::is_same, decltype(foo)>::value); + static_assert(std::is_same::value); + } + + namespace test_typename_in_template_template_parameter + { + + template typename X> struct D; + + } + + namespace test_fallthrough_nodiscard_maybe_unused_attributes + { + + int f1() + { + return 42; + } + + [[nodiscard]] int f2() + { + [[maybe_unused]] auto unused = f1(); + + switch (f1()) + { + case 17: + f1(); + [[fallthrough]]; + case 42: + f1(); + } + return f1(); + } + + } + + namespace test_extended_aggregate_initialization + { + + struct base1 + { + int b1, b2 = 42; + }; + + struct base2 + { + base2() { + b3 = 42; + } + int b3; + }; + + struct derived : base1, base2 + { + int d; + }; + + derived d1 {{1, 2}, {}, 4}; // full initialization + derived d2 {{}, {}, 4}; // value-initialized bases + + } + + namespace test_general_range_based_for_loop + { + + struct iter + { + int i; + + int& operator* () + { + return i; + } + + const int& operator* () const + { + return i; + } + + iter& operator++() + { + ++i; + return *this; + } + }; + + struct sentinel + { + int i; + }; + + bool operator== (const iter& i, const sentinel& s) + { + return i.i == s.i; + } + + bool operator!= (const iter& i, const sentinel& s) + { + return !(i == s); + } + + struct range + { + iter begin() const + { + return {0}; + } + + sentinel end() const + { + return {5}; + } + }; + + void f() + { + range r {}; + + for (auto i : r) + { + [[maybe_unused]] auto v = i; + } + } + + } + + namespace test_lambda_capture_asterisk_this_by_value + { + + struct t + { + int i; + int foo() + { + return [*this]() + { + return i; + }(); + } + }; + + } + + namespace test_enum_class_construction + { + + enum class byte : unsigned char + {}; + + byte foo {42}; + + } + + namespace test_constexpr_if + { + + template + int f () + { + if constexpr(cond) + { + return 13; + } + else + { + return 42; + } + } + + } + + namespace test_selection_statement_with_initializer + { + + int f() + { + return 13; + } + + int f2() + { + if (auto i = f(); i > 0) + { + return 3; + } + + switch (auto i = f(); i + 4) + { + case 17: + return 2; + + default: + return 1; + } + } + + } + + namespace test_template_argument_deduction_for_class_templates + { + + template + struct pair + { + pair (T1 p1, T2 p2) + : m1 {p1}, + m2 {p2} + {} + + T1 m1; + T2 m2; + }; + + void f() + { + [[maybe_unused]] auto p = pair{13, 42u}; + } + + } + + namespace test_non_type_auto_template_parameters + { + + template + struct B + {}; + + B<5> b1; + B<'a'> b2; + + } + + namespace test_structured_bindings + { + + int arr[2] = { 1, 2 }; + std::pair pr = { 1, 2 }; + + auto f1() -> int(&)[2] + { + return arr; + } + + auto f2() -> std::pair& + { + return pr; + } + + struct S + { + int x1 : 2; + volatile double y1; + }; + + S f3() + { + return {}; + } + + auto [ x1, y1 ] = f1(); + auto& [ xr1, yr1 ] = f1(); + auto [ x2, y2 ] = f2(); + auto& [ xr2, yr2 ] = f2(); + const auto [ x3, y3 ] = f3(); + + } + + namespace test_exception_spec_type_system + { + + struct Good {}; + struct Bad {}; + + void g1() noexcept; + void g2(); + + template + Bad + f(T*, T*); + + template + Good + f(T1*, T2*); + + static_assert (std::is_same_v); + + } + + namespace test_inline_variables + { + + template void f(T) + {} + + template inline T g(T) + { + return T{}; + } + + template<> inline void f<>(int) + {} + + template<> int g<>(int) + { + return 5; + } + + } + +} // namespace cxx17 + +#endif // __cplusplus < 201703L + + + +_ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : - ax_cv_cxx_compile_cxx14=yes + eval $cachevar=yes else - ax_cv_cxx_compile_cxx14=no + eval $cachevar=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CXX="$ac_save_CXX" fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx14" >&5 -$as_echo "$ax_cv_cxx_compile_cxx14" >&6; } - if test x$ax_cv_cxx_compile_cxx14 = xyes; then - ac_success=yes +eval ac_res=\$$cachevar + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + if eval test x\$$cachevar = xyes; then + CXX="$CXX $switch" + if test -n "$CXXCPP" ; then + CXXCPP="$CXXCPP $switch" + fi + ac_success=yes + break + fi + done + if test x$ac_success = xyes; then + break + fi + done + fi + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + if test x$ax_cxx_compile_cxx17_required = xtrue; then + if test x$ac_success = xno; then + as_fn_error $? "*** A compiler with support for C++17 language features is required." "$LINENO" 5 + fi fi + if test x$ac_success = xno; then + HAVE_CXX17=0 + { $as_echo "$as_me:${as_lineno-$LINENO}: No compiler with C++17 support was found" >&5 +$as_echo "$as_me: No compiler with C++17 support was found" >&6;} + else + HAVE_CXX17=1 + +$as_echo "#define HAVE_CXX17 1" >>confdefs.h + + fi + + + if test "x${HAVE_CXX17}" != "x1"; then + ax_cxx_compile_alternatives="14 1y" ax_cxx_compile_cxx14_required=false + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + ac_success=no if test x$ac_success = xno; then - for switch in -std=c++14 -std=c++0x +std=c++14 "-h std=c++14"; do - cachevar=`$as_echo "ax_cv_cxx_compile_cxx14_$switch" | $as_tr_sh` - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++14 features with $switch" >&5 + for alternative in ${ax_cxx_compile_alternatives}; do + for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do + cachevar=`$as_echo "ax_cv_cxx_compile_cxx14_$switch" | $as_tr_sh` + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++14 features with $switch" >&5 $as_echo_n "checking whether $CXX supports C++14 features with $switch... " >&6; } if eval \${$cachevar+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_CXX="$CXX" - CXX="$CXX $switch" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + CXX="$CXX $switch" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -5526,11 +6240,13 @@ namespace cxx11 struct Base { + virtual ~Base() {} virtual void f() {} }; struct Derived : public Base { + virtual ~Derived() override {} virtual void f() override {} }; @@ -5855,7 +6571,7 @@ namespace cxx14 } - namespace test_digit_seperators + namespace test_digit_separators { constexpr auto ten_million = 100'000'000; @@ -5905,17 +6621,21 @@ else eval $cachevar=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CXX="$ac_save_CXX" + CXX="$ac_save_CXX" fi eval ac_res=\$$cachevar { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } - if eval test x\$$cachevar = xyes; then - CXX="$CXX $switch" - if test -n "$CXXCPP" ; then - CXXCPP="$CXXCPP $switch" + if eval test x\$$cachevar = xyes; then + CXX="$CXX $switch" + if test -n "$CXXCPP" ; then + CXXCPP="$CXXCPP $switch" + fi + ac_success=yes + break fi - ac_success=yes + done + if test x$ac_success = xyes; then break fi done @@ -5943,7 +6663,8 @@ $as_echo "#define HAVE_CXX14 1" >>confdefs.h fi - if test "x${HAVE_CXX14}" = "x1" ; then + fi + if test "x${HAVE_CXX14}" = "x1" -o "x${HAVE_CXX17}" = "x1"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiler supports -Wall" >&5 $as_echo_n "checking whether compiler supports -Wall... " >&6; } @@ -6184,6 +6905,11 @@ $as_echo "$je_cv_libstdcxx" >&6; } enable_cxx="0" fi fi +if test "x$enable_cxx" = "x1"; then + +$as_echo "#define JEMALLOC_ENABLE_CXX " >>confdefs.h + +fi @@ -6673,7 +7399,8 @@ $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h esac if test "x${ac_cv_big_endian}" = "x1" ; then - cat >>confdefs.h <<_ACEOF + +cat >>confdefs.h <<_ACEOF #define JEMALLOC_BIG_ENDIAN _ACEOF @@ -6736,6 +7463,7 @@ _ACEOF as_fn_error $? "Unsupported pointer size: ${ac_cv_sizeof_void_p}" "$LINENO" 5 fi fi + cat >>confdefs.h <<_ACEOF #define LG_SIZEOF_PTR $LG_SIZEOF_PTR _ACEOF @@ -6781,6 +7509,7 @@ elif test "x${ac_cv_sizeof_int}" = "x4" ; then else as_fn_error $? "Unsupported int size: ${ac_cv_sizeof_int}" "$LINENO" 5 fi + cat >>confdefs.h <<_ACEOF #define LG_SIZEOF_INT $LG_SIZEOF_INT _ACEOF @@ -6826,6 +7555,7 @@ elif test "x${ac_cv_sizeof_long}" = "x4" ; then else as_fn_error $? "Unsupported long size: ${ac_cv_sizeof_long}" "$LINENO" 5 fi + cat >>confdefs.h <<_ACEOF #define LG_SIZEOF_LONG $LG_SIZEOF_LONG _ACEOF @@ -6871,6 +7601,7 @@ elif test "x${ac_cv_sizeof_long_long}" = "x4" ; then else as_fn_error $? "Unsupported long long size: ${ac_cv_sizeof_long_long}" "$LINENO" 5 fi + cat >>confdefs.h <<_ACEOF #define LG_SIZEOF_LONG_LONG $LG_SIZEOF_LONG_LONG _ACEOF @@ -6918,6 +7649,7 @@ elif test "x${ac_cv_sizeof_intmax_t}" = "x4" ; then else as_fn_error $? "Unsupported intmax_t size: ${ac_cv_sizeof_intmax_t}" "$LINENO" 5 fi + cat >>confdefs.h <<_ACEOF #define LG_SIZEOF_INTMAX_T $LG_SIZEOF_INTMAX_T _ACEOF @@ -7074,26 +7806,67 @@ fi fi fi ;; - *) - HAVE_CPU_SPINWAIT=0 - ;; -esac -cat >>confdefs.h <<_ACEOF -#define HAVE_CPU_SPINWAIT $HAVE_CPU_SPINWAIT -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define CPU_SPINWAIT $CPU_SPINWAIT -_ACEOF - - - -# Check whether --with-lg_vaddr was given. -if test "${with_lg_vaddr+set}" = set; then : - withval=$with_lg_vaddr; LG_VADDR="$with_lg_vaddr" + aarch64|arm*) + HAVE_CPU_SPINWAIT=1 + if ${je_cv_isb+:} false; then : + $as_echo_n "(cached) " >&6 else - LG_VADDR="detect" -fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether isb instruction is compilable" >&5 +$as_echo_n "checking whether isb instruction is compilable... " >&6; } +if ${je_cv_isb+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +__asm__ volatile("isb"); return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + je_cv_isb=yes +else + je_cv_isb=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $je_cv_isb" >&5 +$as_echo "$je_cv_isb" >&6; } + +fi + + if test "x${je_cv_isb}" = "xyes" ; then + CPU_SPINWAIT='__asm__ volatile("isb")' + fi + ;; + *) + HAVE_CPU_SPINWAIT=0 + ;; +esac + +cat >>confdefs.h <<_ACEOF +#define HAVE_CPU_SPINWAIT $HAVE_CPU_SPINWAIT +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define CPU_SPINWAIT $CPU_SPINWAIT +_ACEOF + + + +# Check whether --with-lg_vaddr was given. +if test "${with_lg_vaddr+set}" = set; then : + withval=$with_lg_vaddr; LG_VADDR="$with_lg_vaddr" +else + LG_VADDR="detect" +fi case "${host_cpu}" in @@ -7181,7 +7954,8 @@ $as_echo "$je_cv_lg_vaddr" >&6; } LG_VADDR="${je_cv_lg_vaddr}" fi if test "x${LG_VADDR}" != "xerror" ; then - cat >>confdefs.h <<_ACEOF + +cat >>confdefs.h <<_ACEOF #define LG_VADDR $LG_VADDR _ACEOF @@ -7208,6 +7982,7 @@ $as_echo "$LG_VADDR" >&6; } fi ;; esac + cat >>confdefs.h <<_ACEOF #define LG_VADDR $LG_VADDR _ACEOF @@ -7515,7 +8290,7 @@ if test ! -e "${objroot}VERSION" ; then if test ! -e "${srcroot}VERSION" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: Missing VERSION file, and unable to generate it; creating bogus VERSION" >&5 $as_echo "Missing VERSION file, and unable to generate it; creating bogus VERSION" >&6; } - echo "0.0.0-0-g0000000000000000000000000000000000000000" > "${objroot}VERSION" + echo "0.0.0-0-g000000missing_version_try_git_fetch_tags" > "${objroot}VERSION" else cp ${srcroot}VERSION ${objroot}VERSION fi @@ -7534,6 +8309,7 @@ jemalloc_version_gid=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print $5}' default_retain="0" +zero_realloc_default_free="0" maps_coalesce="1" DUMP_SYMS="${NM} -a" SYM_PREFIX="" @@ -7551,8 +8327,17 @@ case "${host}" in SYM_PREFIX="_" ;; *-*-freebsd*) + T_APPEND_V=-D_BSD_SOURCE + if test "x${CPPFLAGS}" = "x" -o "x${T_APPEND_V}" = "x" ; then + CPPFLAGS="${CPPFLAGS}${T_APPEND_V}" +else + CPPFLAGS="${CPPFLAGS} ${T_APPEND_V}" +fi + + abi="elf" - $as_echo "#define JEMALLOC_SYSCTL_VM_OVERCOMMIT " >>confdefs.h + +$as_echo "#define JEMALLOC_SYSCTL_VM_OVERCOMMIT " >>confdefs.h force_lazy_lock="1" ;; @@ -7566,7 +8351,7 @@ case "${host}" in *-*-bitrig*) abi="elf" ;; - *-*-linux-android) + *-*-linux-android*) T_APPEND_V=-D_GNU_SOURCE if test "x${CPPFLAGS}" = "x" -o "x${T_APPEND_V}" = "x" ; then CPPFLAGS="${CPPFLAGS}${T_APPEND_V}" @@ -7576,20 +8361,27 @@ fi abi="elf" - $as_echo "#define JEMALLOC_PURGE_MADVISE_DONTNEED_ZEROS " >>confdefs.h + glibc="0" - $as_echo "#define JEMALLOC_HAS_ALLOCA_H 1" >>confdefs.h +$as_echo "#define JEMALLOC_PURGE_MADVISE_DONTNEED_ZEROS " >>confdefs.h - $as_echo "#define JEMALLOC_PROC_SYS_VM_OVERCOMMIT_MEMORY " >>confdefs.h - $as_echo "#define JEMALLOC_THREADED_INIT " >>confdefs.h +$as_echo "#define JEMALLOC_HAS_ALLOCA_H " >>confdefs.h - $as_echo "#define JEMALLOC_C11_ATOMICS 1" >>confdefs.h + +$as_echo "#define JEMALLOC_PROC_SYS_VM_OVERCOMMIT_MEMORY " >>confdefs.h + + +$as_echo "#define JEMALLOC_THREADED_INIT " >>confdefs.h + + +$as_echo "#define JEMALLOC_C11_ATOMICS " >>confdefs.h force_tls="0" if test "${LG_SIZEOF_PTR}" = "3"; then default_retain="1" fi + zero_realloc_default_free="1" ;; *-*-linux*) T_APPEND_V=-D_GNU_SOURCE @@ -7601,19 +8393,26 @@ fi abi="elf" - $as_echo "#define JEMALLOC_PURGE_MADVISE_DONTNEED_ZEROS " >>confdefs.h + glibc="1" + +$as_echo "#define JEMALLOC_PURGE_MADVISE_DONTNEED_ZEROS " >>confdefs.h + + +$as_echo "#define JEMALLOC_HAS_ALLOCA_H " >>confdefs.h - $as_echo "#define JEMALLOC_HAS_ALLOCA_H 1" >>confdefs.h - $as_echo "#define JEMALLOC_PROC_SYS_VM_OVERCOMMIT_MEMORY " >>confdefs.h +$as_echo "#define JEMALLOC_PROC_SYS_VM_OVERCOMMIT_MEMORY " >>confdefs.h - $as_echo "#define JEMALLOC_THREADED_INIT " >>confdefs.h - $as_echo "#define JEMALLOC_USE_CXX_THROW " >>confdefs.h +$as_echo "#define JEMALLOC_THREADED_INIT " >>confdefs.h + + +$as_echo "#define JEMALLOC_USE_CXX_THROW " >>confdefs.h if test "${LG_SIZEOF_PTR}" = "3"; then default_retain="1" fi + zero_realloc_default_free="1" ;; *-*-kfreebsd*) T_APPEND_V=-D_GNU_SOURCE @@ -7625,13 +8424,17 @@ fi abi="elf" - $as_echo "#define JEMALLOC_HAS_ALLOCA_H 1" >>confdefs.h - $as_echo "#define JEMALLOC_SYSCTL_VM_OVERCOMMIT " >>confdefs.h +$as_echo "#define JEMALLOC_HAS_ALLOCA_H " >>confdefs.h + + +$as_echo "#define JEMALLOC_SYSCTL_VM_OVERCOMMIT " >>confdefs.h - $as_echo "#define JEMALLOC_THREADED_INIT " >>confdefs.h - $as_echo "#define JEMALLOC_USE_CXX_THROW " >>confdefs.h +$as_echo "#define JEMALLOC_THREADED_INIT " >>confdefs.h + + +$as_echo "#define JEMALLOC_USE_CXX_THROW " >>confdefs.h ;; *-*-netbsd*) @@ -7725,6 +8528,14 @@ fi if test "${LG_SIZEOF_PTR}" = "3"; then default_retain="1" fi + zero_realloc_default_free="1" + ;; + *-*-nto-qnx) + abi="elf" + force_tls="0" + +$as_echo "#define JEMALLOC_HAS_ALLOCA_H " >>confdefs.h + ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: Unsupported operating system: ${host}" >&5 @@ -7776,6 +8587,7 @@ fi done + cat >>confdefs.h <<_ACEOF #define JEMALLOC_USABLE_SIZE_CONST $JEMALLOC_USABLE_SIZE_CONST _ACEOF @@ -7897,7 +8709,8 @@ fi $as_echo "$je_cv_attribute" >&6; } if test "x${je_cv_attribute}" = "xyes" ; then - $as_echo "#define JEMALLOC_HAVE_ATTR " >>confdefs.h + +$as_echo "#define JEMALLOC_HAVE_ATTR " >>confdefs.h if test "x${GCC}" = "xyes" -a "x${abi}" = "xelf"; then @@ -8300,7 +9113,8 @@ fi if test "x${je_cv_alloc_size}" = "xyes" ; then - $as_echo "#define JEMALLOC_HAVE_ATTR_ALLOC_SIZE " >>confdefs.h + +$as_echo "#define JEMALLOC_HAVE_ATTR_ALLOC_SIZE " >>confdefs.h fi SAVED_CONFIGURE_CFLAGS="${CONFIGURE_CFLAGS}" @@ -8415,25 +9229,417 @@ if ${je_cv_format_gnu_printf+:} false; then : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include +#include +int +main () +{ +void *foo(const char *format, ...) __attribute__((format(gnu_printf, 1, 2))); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + je_cv_format_gnu_printf=yes +else + je_cv_format_gnu_printf=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $je_cv_format_gnu_printf" >&5 +$as_echo "$je_cv_format_gnu_printf" >&6; } + +CONFIGURE_CFLAGS="${SAVED_CONFIGURE_CFLAGS}" +if test "x${CONFIGURE_CFLAGS}" = "x" -o "x${SPECIFIED_CFLAGS}" = "x" ; then + CFLAGS="${CONFIGURE_CFLAGS}${SPECIFIED_CFLAGS}" +else + CFLAGS="${CONFIGURE_CFLAGS} ${SPECIFIED_CFLAGS}" +fi + + +if test "x${je_cv_format_gnu_printf}" = "xyes" ; then + +$as_echo "#define JEMALLOC_HAVE_ATTR_FORMAT_GNU_PRINTF " >>confdefs.h + +fi +SAVED_CONFIGURE_CFLAGS="${CONFIGURE_CFLAGS}" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiler supports -Werror" >&5 +$as_echo_n "checking whether compiler supports -Werror... " >&6; } +T_CONFIGURE_CFLAGS="${CONFIGURE_CFLAGS}" +T_APPEND_V=-Werror + if test "x${CONFIGURE_CFLAGS}" = "x" -o "x${T_APPEND_V}" = "x" ; then + CONFIGURE_CFLAGS="${CONFIGURE_CFLAGS}${T_APPEND_V}" +else + CONFIGURE_CFLAGS="${CONFIGURE_CFLAGS} ${T_APPEND_V}" +fi + + +if test "x${CONFIGURE_CFLAGS}" = "x" -o "x${SPECIFIED_CFLAGS}" = "x" ; then + CFLAGS="${CONFIGURE_CFLAGS}${SPECIFIED_CFLAGS}" +else + CFLAGS="${CONFIGURE_CFLAGS} ${SPECIFIED_CFLAGS}" +fi + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + +int +main () +{ + + return 0; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + je_cv_cflags_added=-Werror + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + je_cv_cflags_added= + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + CONFIGURE_CFLAGS="${T_CONFIGURE_CFLAGS}" + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +if test "x${CONFIGURE_CFLAGS}" = "x" -o "x${SPECIFIED_CFLAGS}" = "x" ; then + CFLAGS="${CONFIGURE_CFLAGS}${SPECIFIED_CFLAGS}" +else + CFLAGS="${CONFIGURE_CFLAGS} ${SPECIFIED_CFLAGS}" +fi + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiler supports -herror_on_warning" >&5 +$as_echo_n "checking whether compiler supports -herror_on_warning... " >&6; } +T_CONFIGURE_CFLAGS="${CONFIGURE_CFLAGS}" +T_APPEND_V=-herror_on_warning + if test "x${CONFIGURE_CFLAGS}" = "x" -o "x${T_APPEND_V}" = "x" ; then + CONFIGURE_CFLAGS="${CONFIGURE_CFLAGS}${T_APPEND_V}" +else + CONFIGURE_CFLAGS="${CONFIGURE_CFLAGS} ${T_APPEND_V}" +fi + + +if test "x${CONFIGURE_CFLAGS}" = "x" -o "x${SPECIFIED_CFLAGS}" = "x" ; then + CFLAGS="${CONFIGURE_CFLAGS}${SPECIFIED_CFLAGS}" +else + CFLAGS="${CONFIGURE_CFLAGS} ${SPECIFIED_CFLAGS}" +fi + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + +int +main () +{ + + return 0; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + je_cv_cflags_added=-herror_on_warning + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + je_cv_cflags_added= + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + CONFIGURE_CFLAGS="${T_CONFIGURE_CFLAGS}" + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +if test "x${CONFIGURE_CFLAGS}" = "x" -o "x${SPECIFIED_CFLAGS}" = "x" ; then + CFLAGS="${CONFIGURE_CFLAGS}${SPECIFIED_CFLAGS}" +else + CFLAGS="${CONFIGURE_CFLAGS} ${SPECIFIED_CFLAGS}" +fi + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether format(printf, ...) attribute is compilable" >&5 +$as_echo_n "checking whether format(printf, ...) attribute is compilable... " >&6; } +if ${je_cv_format_printf+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +void *foo(const char *format, ...) __attribute__((format(printf, 1, 2))); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + je_cv_format_printf=yes +else + je_cv_format_printf=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $je_cv_format_printf" >&5 +$as_echo "$je_cv_format_printf" >&6; } + +CONFIGURE_CFLAGS="${SAVED_CONFIGURE_CFLAGS}" +if test "x${CONFIGURE_CFLAGS}" = "x" -o "x${SPECIFIED_CFLAGS}" = "x" ; then + CFLAGS="${CONFIGURE_CFLAGS}${SPECIFIED_CFLAGS}" +else + CFLAGS="${CONFIGURE_CFLAGS} ${SPECIFIED_CFLAGS}" +fi + + +if test "x${je_cv_format_printf}" = "xyes" ; then + +$as_echo "#define JEMALLOC_HAVE_ATTR_FORMAT_PRINTF " >>confdefs.h + +fi + +SAVED_CONFIGURE_CFLAGS="${CONFIGURE_CFLAGS}" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiler supports -Werror" >&5 +$as_echo_n "checking whether compiler supports -Werror... " >&6; } +T_CONFIGURE_CFLAGS="${CONFIGURE_CFLAGS}" +T_APPEND_V=-Werror + if test "x${CONFIGURE_CFLAGS}" = "x" -o "x${T_APPEND_V}" = "x" ; then + CONFIGURE_CFLAGS="${CONFIGURE_CFLAGS}${T_APPEND_V}" +else + CONFIGURE_CFLAGS="${CONFIGURE_CFLAGS} ${T_APPEND_V}" +fi + + +if test "x${CONFIGURE_CFLAGS}" = "x" -o "x${SPECIFIED_CFLAGS}" = "x" ; then + CFLAGS="${CONFIGURE_CFLAGS}${SPECIFIED_CFLAGS}" +else + CFLAGS="${CONFIGURE_CFLAGS} ${SPECIFIED_CFLAGS}" +fi + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + +int +main () +{ + + return 0; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + je_cv_cflags_added=-Werror + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + je_cv_cflags_added= + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + CONFIGURE_CFLAGS="${T_CONFIGURE_CFLAGS}" + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +if test "x${CONFIGURE_CFLAGS}" = "x" -o "x${SPECIFIED_CFLAGS}" = "x" ; then + CFLAGS="${CONFIGURE_CFLAGS}${SPECIFIED_CFLAGS}" +else + CFLAGS="${CONFIGURE_CFLAGS} ${SPECIFIED_CFLAGS}" +fi + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiler supports -herror_on_warning" >&5 +$as_echo_n "checking whether compiler supports -herror_on_warning... " >&6; } +T_CONFIGURE_CFLAGS="${CONFIGURE_CFLAGS}" +T_APPEND_V=-herror_on_warning + if test "x${CONFIGURE_CFLAGS}" = "x" -o "x${T_APPEND_V}" = "x" ; then + CONFIGURE_CFLAGS="${CONFIGURE_CFLAGS}${T_APPEND_V}" +else + CONFIGURE_CFLAGS="${CONFIGURE_CFLAGS} ${T_APPEND_V}" +fi + + +if test "x${CONFIGURE_CFLAGS}" = "x" -o "x${SPECIFIED_CFLAGS}" = "x" ; then + CFLAGS="${CONFIGURE_CFLAGS}${SPECIFIED_CFLAGS}" +else + CFLAGS="${CONFIGURE_CFLAGS} ${SPECIFIED_CFLAGS}" +fi + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + +int +main () +{ + + return 0; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + je_cv_cflags_added=-herror_on_warning + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + je_cv_cflags_added= + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + CONFIGURE_CFLAGS="${T_CONFIGURE_CFLAGS}" + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +if test "x${CONFIGURE_CFLAGS}" = "x" -o "x${SPECIFIED_CFLAGS}" = "x" ; then + CFLAGS="${CONFIGURE_CFLAGS}${SPECIFIED_CFLAGS}" +else + CFLAGS="${CONFIGURE_CFLAGS} ${SPECIFIED_CFLAGS}" +fi + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether format(printf, ...) attribute is compilable" >&5 +$as_echo_n "checking whether format(printf, ...) attribute is compilable... " >&6; } +if ${je_cv_format_arg+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +const char * __attribute__((__format_arg__(1))) foo(const char *format); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + je_cv_format_arg=yes +else + je_cv_format_arg=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $je_cv_format_arg" >&5 +$as_echo "$je_cv_format_arg" >&6; } + +CONFIGURE_CFLAGS="${SAVED_CONFIGURE_CFLAGS}" +if test "x${CONFIGURE_CFLAGS}" = "x" -o "x${SPECIFIED_CFLAGS}" = "x" ; then + CFLAGS="${CONFIGURE_CFLAGS}${SPECIFIED_CFLAGS}" +else + CFLAGS="${CONFIGURE_CFLAGS} ${SPECIFIED_CFLAGS}" +fi + + +if test "x${je_cv_format_arg}" = "xyes" ; then + +$as_echo "#define JEMALLOC_HAVE_ATTR_FORMAT_ARG " >>confdefs.h + +fi + +SAVED_CONFIGURE_CFLAGS="${CONFIGURE_CFLAGS}" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiler supports -Wimplicit-fallthrough" >&5 +$as_echo_n "checking whether compiler supports -Wimplicit-fallthrough... " >&6; } +T_CONFIGURE_CFLAGS="${CONFIGURE_CFLAGS}" +T_APPEND_V=-Wimplicit-fallthrough + if test "x${CONFIGURE_CFLAGS}" = "x" -o "x${T_APPEND_V}" = "x" ; then + CONFIGURE_CFLAGS="${CONFIGURE_CFLAGS}${T_APPEND_V}" +else + CONFIGURE_CFLAGS="${CONFIGURE_CFLAGS} ${T_APPEND_V}" +fi + + +if test "x${CONFIGURE_CFLAGS}" = "x" -o "x${SPECIFIED_CFLAGS}" = "x" ; then + CFLAGS="${CONFIGURE_CFLAGS}${SPECIFIED_CFLAGS}" +else + CFLAGS="${CONFIGURE_CFLAGS} ${SPECIFIED_CFLAGS}" +fi + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + +int +main () +{ + + return 0; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + je_cv_cflags_added=-Wimplicit-fallthrough + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + je_cv_cflags_added= + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + CONFIGURE_CFLAGS="${T_CONFIGURE_CFLAGS}" + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +if test "x${CONFIGURE_CFLAGS}" = "x" -o "x${SPECIFIED_CFLAGS}" = "x" ; then + CFLAGS="${CONFIGURE_CFLAGS}${SPECIFIED_CFLAGS}" +else + CFLAGS="${CONFIGURE_CFLAGS} ${SPECIFIED_CFLAGS}" +fi + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether fallthrough attribute is compilable" >&5 +$as_echo_n "checking whether fallthrough attribute is compilable... " >&6; } +if ${je_cv_fallthrough+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#if !__has_attribute(fallthrough) + #error "foo" + #endif int main () { -void *foo(const char *format, ...) __attribute__((format(gnu_printf, 1, 2))); +int x = 0; + switch (x) { + case 0: __attribute__((__fallthrough__)); + case 1: return 1; + } ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : - je_cv_format_gnu_printf=yes + je_cv_fallthrough=yes else - je_cv_format_gnu_printf=no + je_cv_fallthrough=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $je_cv_format_gnu_printf" >&5 -$as_echo "$je_cv_format_gnu_printf" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $je_cv_fallthrough" >&5 +$as_echo "$je_cv_fallthrough" >&6; } CONFIGURE_CFLAGS="${SAVED_CONFIGURE_CFLAGS}" if test "x${CONFIGURE_CFLAGS}" = "x" -o "x${SPECIFIED_CFLAGS}" = "x" ; then @@ -8443,17 +9649,15 @@ else fi -if test "x${je_cv_format_gnu_printf}" = "xyes" ; then - $as_echo "#define JEMALLOC_HAVE_ATTR_FORMAT_GNU_PRINTF " >>confdefs.h +if test "x${je_cv_fallthrough}" = "xyes" ; then -fi -SAVED_CONFIGURE_CFLAGS="${CONFIGURE_CFLAGS}" +$as_echo "#define JEMALLOC_HAVE_ATTR_FALLTHROUGH " >>confdefs.h -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiler supports -Werror" >&5 -$as_echo_n "checking whether compiler supports -Werror... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiler supports -Wimplicit-fallthrough" >&5 +$as_echo_n "checking whether compiler supports -Wimplicit-fallthrough... " >&6; } T_CONFIGURE_CFLAGS="${CONFIGURE_CFLAGS}" -T_APPEND_V=-Werror +T_APPEND_V=-Wimplicit-fallthrough if test "x${CONFIGURE_CFLAGS}" = "x" -o "x${T_APPEND_V}" = "x" ; then CONFIGURE_CFLAGS="${CONFIGURE_CFLAGS}${T_APPEND_V}" else @@ -8482,7 +9686,7 @@ main () } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - je_cv_cflags_added=-Werror + je_cv_cflags_added=-Wimplicit-fallthrough { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else @@ -8501,23 +9705,29 @@ fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiler supports -herror_on_warning" >&5 -$as_echo_n "checking whether compiler supports -herror_on_warning... " >&6; } -T_CONFIGURE_CFLAGS="${CONFIGURE_CFLAGS}" -T_APPEND_V=-herror_on_warning - if test "x${CONFIGURE_CFLAGS}" = "x" -o "x${T_APPEND_V}" = "x" ; then - CONFIGURE_CFLAGS="${CONFIGURE_CFLAGS}${T_APPEND_V}" +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiler supports -Wimplicit-fallthrough" >&5 +$as_echo_n "checking whether compiler supports -Wimplicit-fallthrough... " >&6; } +T_CONFIGURE_CXXFLAGS="${CONFIGURE_CXXFLAGS}" +T_APPEND_V=-Wimplicit-fallthrough + if test "x${CONFIGURE_CXXFLAGS}" = "x" -o "x${T_APPEND_V}" = "x" ; then + CONFIGURE_CXXFLAGS="${CONFIGURE_CXXFLAGS}${T_APPEND_V}" else - CONFIGURE_CFLAGS="${CONFIGURE_CFLAGS} ${T_APPEND_V}" + CONFIGURE_CXXFLAGS="${CONFIGURE_CXXFLAGS} ${T_APPEND_V}" fi -if test "x${CONFIGURE_CFLAGS}" = "x" -o "x${SPECIFIED_CFLAGS}" = "x" ; then - CFLAGS="${CONFIGURE_CFLAGS}${SPECIFIED_CFLAGS}" +if test "x${CONFIGURE_CXXFLAGS}" = "x" -o "x${SPECIFIED_CXXFLAGS}" = "x" ; then + CXXFLAGS="${CONFIGURE_CXXFLAGS}${SPECIFIED_CXXFLAGS}" else - CFLAGS="${CONFIGURE_CFLAGS} ${SPECIFIED_CFLAGS}" + CXXFLAGS="${CONFIGURE_CXXFLAGS} ${SPECIFIED_CXXFLAGS}" fi +ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -8532,64 +9742,31 @@ main () return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - je_cv_cflags_added=-herror_on_warning +if ac_fn_cxx_try_compile "$LINENO"; then : + je_cv_cxxflags_added=-Wimplicit-fallthrough { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else - je_cv_cflags_added= + je_cv_cxxflags_added= { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } - CONFIGURE_CFLAGS="${T_CONFIGURE_CFLAGS}" + CONFIGURE_CXXFLAGS="${T_CONFIGURE_CXXFLAGS}" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -if test "x${CONFIGURE_CFLAGS}" = "x" -o "x${SPECIFIED_CFLAGS}" = "x" ; then - CFLAGS="${CONFIGURE_CFLAGS}${SPECIFIED_CFLAGS}" -else - CFLAGS="${CONFIGURE_CFLAGS} ${SPECIFIED_CFLAGS}" -fi - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether format(printf, ...) attribute is compilable" >&5 -$as_echo_n "checking whether format(printf, ...) attribute is compilable... " >&6; } -if ${je_cv_format_printf+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main () -{ -void *foo(const char *format, ...) __attribute__((format(printf, 1, 2))); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - je_cv_format_printf=yes -else - je_cv_format_printf=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $je_cv_format_printf" >&5 -$as_echo "$je_cv_format_printf" >&6; } +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu -CONFIGURE_CFLAGS="${SAVED_CONFIGURE_CFLAGS}" -if test "x${CONFIGURE_CFLAGS}" = "x" -o "x${SPECIFIED_CFLAGS}" = "x" ; then - CFLAGS="${CONFIGURE_CFLAGS}${SPECIFIED_CFLAGS}" +if test "x${CONFIGURE_CXXFLAGS}" = "x" -o "x${SPECIFIED_CXXFLAGS}" = "x" ; then + CXXFLAGS="${CONFIGURE_CXXFLAGS}${SPECIFIED_CXXFLAGS}" else - CFLAGS="${CONFIGURE_CFLAGS} ${SPECIFIED_CFLAGS}" + CXXFLAGS="${CONFIGURE_CXXFLAGS} ${SPECIFIED_CXXFLAGS}" fi -if test "x${je_cv_format_printf}" = "xyes" ; then - $as_echo "#define JEMALLOC_HAVE_ATTR_FORMAT_PRINTF " >>confdefs.h - fi SAVED_CONFIGURE_CFLAGS="${CONFIGURE_CFLAGS}" @@ -8697,32 +9874,32 @@ fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether format(printf, ...) attribute is compilable" >&5 -$as_echo_n "checking whether format(printf, ...) attribute is compilable... " >&6; } -if ${je_cv_format_arg+:} false; then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether cold attribute is compilable" >&5 +$as_echo_n "checking whether cold attribute is compilable... " >&6; } +if ${je_cv_cold+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include + int main () { -const char * __attribute__((__format_arg__(1))) foo(const char *format); +__attribute__((__cold__)) void foo(); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : - je_cv_format_arg=yes + je_cv_cold=yes else - je_cv_format_arg=no + je_cv_cold=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $je_cv_format_arg" >&5 -$as_echo "$je_cv_format_arg" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $je_cv_cold" >&5 +$as_echo "$je_cv_cold" >&6; } CONFIGURE_CFLAGS="${SAVED_CONFIGURE_CFLAGS}" if test "x${CONFIGURE_CFLAGS}" = "x" -o "x${SPECIFIED_CFLAGS}" = "x" ; then @@ -8732,8 +9909,46 @@ else fi -if test "x${je_cv_format_arg}" = "xyes" ; then - $as_echo "#define JEMALLOC_HAVE_ATTR_FORMAT_ARG " >>confdefs.h +if test "x${je_cv_cold}" = "xyes" ; then + +$as_echo "#define JEMALLOC_HAVE_ATTR_COLD " >>confdefs.h + +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether vm_make_tag is compilable" >&5 +$as_echo_n "checking whether vm_make_tag is compilable... " >&6; } +if ${je_cv_vm_make_tag+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + #include +int +main () +{ +void *p; + p = mmap(0, 16, PROT_READ, MAP_ANON|MAP_PRIVATE, VM_MAKE_TAG(1), 0); + munmap(p, 16); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + je_cv_vm_make_tag=yes +else + je_cv_vm_make_tag=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $je_cv_vm_make_tag" >&5 +$as_echo "$je_cv_vm_make_tag" >&6; } + +if test "x${je_cv_vm_make_tag}" = "xyes" ; then + +$as_echo "#define JEMALLOC_HAVE_VM_MAKE_TAG " >>confdefs.h fi @@ -9107,15 +10322,18 @@ fi fi if test "x$JEMALLOC_PREFIX" = "x" ; then - $as_echo "#define JEMALLOC_IS_MALLOC 1" >>confdefs.h + +$as_echo "#define JEMALLOC_IS_MALLOC " >>confdefs.h else JEMALLOC_CPREFIX=`echo ${JEMALLOC_PREFIX} | tr "a-z" "A-Z"` - cat >>confdefs.h <<_ACEOF + +cat >>confdefs.h <<_ACEOF #define JEMALLOC_PREFIX "$JEMALLOC_PREFIX" _ACEOF - cat >>confdefs.h <<_ACEOF + +cat >>confdefs.h <<_ACEOF #define JEMALLOC_CPREFIX "$JEMALLOC_CPREFIX" _ACEOF @@ -9127,76 +10345,94 @@ fi # Check whether --with-export was given. if test "${with_export+set}" = set; then : withval=$with_export; if test "x$with_export" = "xno"; then - $as_echo "#define JEMALLOC_EXPORT /**/" >>confdefs.h + +$as_echo "#define JEMALLOC_EXPORT /**/" >>confdefs.h fi fi -public_syms="aligned_alloc calloc dallocx free mallctl mallctlbymib mallctlnametomib malloc malloc_conf malloc_message malloc_stats_print malloc_usable_size mallocx smallocx_${jemalloc_version_gid} nallocx posix_memalign rallocx realloc sallocx sdallocx xallocx" +public_syms="aligned_alloc calloc dallocx free mallctl mallctlbymib mallctlnametomib malloc malloc_conf malloc_conf_2_conf_harder malloc_message malloc_stats_print malloc_usable_size mallocx smallocx_${jemalloc_version_gid} nallocx posix_memalign rallocx realloc sallocx sdallocx xallocx" ac_fn_c_check_func "$LINENO" "memalign" "ac_cv_func_memalign" if test "x$ac_cv_func_memalign" = xyes; then : - $as_echo "#define JEMALLOC_OVERRIDE_MEMALIGN " >>confdefs.h + +$as_echo "#define JEMALLOC_OVERRIDE_MEMALIGN " >>confdefs.h public_syms="${public_syms} memalign" fi ac_fn_c_check_func "$LINENO" "valloc" "ac_cv_func_valloc" if test "x$ac_cv_func_valloc" = xyes; then : - $as_echo "#define JEMALLOC_OVERRIDE_VALLOC " >>confdefs.h + +$as_echo "#define JEMALLOC_OVERRIDE_VALLOC " >>confdefs.h public_syms="${public_syms} valloc" fi +ac_fn_c_check_func "$LINENO" "malloc_size" "ac_cv_func_malloc_size" +if test "x$ac_cv_func_malloc_size" = xyes; then : + +$as_echo "#define JEMALLOC_HAVE_MALLOC_SIZE " >>confdefs.h + + public_syms="${public_syms} malloc_size" +fi + wrap_syms= if test "x${JEMALLOC_PREFIX}" = "x" ; then ac_fn_c_check_func "$LINENO" "__libc_calloc" "ac_cv_func___libc_calloc" if test "x$ac_cv_func___libc_calloc" = xyes; then : - $as_echo "#define JEMALLOC_OVERRIDE___LIBC_CALLOC " >>confdefs.h + +$as_echo "#define JEMALLOC_OVERRIDE___LIBC_CALLOC " >>confdefs.h wrap_syms="${wrap_syms} __libc_calloc" fi ac_fn_c_check_func "$LINENO" "__libc_free" "ac_cv_func___libc_free" if test "x$ac_cv_func___libc_free" = xyes; then : - $as_echo "#define JEMALLOC_OVERRIDE___LIBC_FREE " >>confdefs.h + +$as_echo "#define JEMALLOC_OVERRIDE___LIBC_FREE " >>confdefs.h wrap_syms="${wrap_syms} __libc_free" fi ac_fn_c_check_func "$LINENO" "__libc_malloc" "ac_cv_func___libc_malloc" if test "x$ac_cv_func___libc_malloc" = xyes; then : - $as_echo "#define JEMALLOC_OVERRIDE___LIBC_MALLOC " >>confdefs.h + +$as_echo "#define JEMALLOC_OVERRIDE___LIBC_MALLOC " >>confdefs.h wrap_syms="${wrap_syms} __libc_malloc" fi ac_fn_c_check_func "$LINENO" "__libc_memalign" "ac_cv_func___libc_memalign" if test "x$ac_cv_func___libc_memalign" = xyes; then : - $as_echo "#define JEMALLOC_OVERRIDE___LIBC_MEMALIGN " >>confdefs.h + +$as_echo "#define JEMALLOC_OVERRIDE___LIBC_MEMALIGN " >>confdefs.h wrap_syms="${wrap_syms} __libc_memalign" fi ac_fn_c_check_func "$LINENO" "__libc_realloc" "ac_cv_func___libc_realloc" if test "x$ac_cv_func___libc_realloc" = xyes; then : - $as_echo "#define JEMALLOC_OVERRIDE___LIBC_REALLOC " >>confdefs.h + +$as_echo "#define JEMALLOC_OVERRIDE___LIBC_REALLOC " >>confdefs.h wrap_syms="${wrap_syms} __libc_realloc" fi ac_fn_c_check_func "$LINENO" "__libc_valloc" "ac_cv_func___libc_valloc" if test "x$ac_cv_func___libc_valloc" = xyes; then : - $as_echo "#define JEMALLOC_OVERRIDE___LIBC_VALLOC " >>confdefs.h + +$as_echo "#define JEMALLOC_OVERRIDE___LIBC_VALLOC " >>confdefs.h wrap_syms="${wrap_syms} __libc_valloc" fi ac_fn_c_check_func "$LINENO" "__posix_memalign" "ac_cv_func___posix_memalign" if test "x$ac_cv_func___posix_memalign" = xyes; then : - $as_echo "#define JEMALLOC_OVERRIDE___POSIX_MEMALIGN " >>confdefs.h + +$as_echo "#define JEMALLOC_OVERRIDE___POSIX_MEMALIGN " >>confdefs.h wrap_syms="${wrap_syms} __posix_memalign" fi @@ -9220,6 +10456,7 @@ else fi + cat >>confdefs.h <<_ACEOF #define JEMALLOC_PRIVATE_NAMESPACE $JEMALLOC_PRIVATE_NAMESPACE _ACEOF @@ -9230,7 +10467,10 @@ private_namespace="$JEMALLOC_PRIVATE_NAMESPACE" # Check whether --with-install_suffix was given. if test "${with_install_suffix+set}" = set; then : - withval=$with_install_suffix; INSTALL_SUFFIX="$with_install_suffix" + withval=$with_install_suffix; case "$with_install_suffix" in + *\ * ) as_fn_error $? "Install suffix should not contain spaces" "$LINENO" 5 ;; + * ) INSTALL_SUFFIX="$with_install_suffix" ;; +esac else INSTALL_SUFFIX= @@ -9249,6 +10489,7 @@ else fi config_malloc_conf="$JEMALLOC_CONFIG_MALLOC_CONF" + cat >>confdefs.h <<_ACEOF #define JEMALLOC_CONFIG_MALLOC_CONF "$config_malloc_conf" _ACEOF @@ -9337,11 +10578,8 @@ else fi if test "x$enable_debug" = "x1" ; then - $as_echo "#define JEMALLOC_DEBUG " >>confdefs.h -fi -if test "x$enable_debug" = "x1" ; then - $as_echo "#define JEMALLOC_DEBUG " >>confdefs.h +$as_echo "#define JEMALLOC_DEBUG " >>confdefs.h fi @@ -9760,7 +10998,8 @@ else fi if test "x$enable_stats" = "x1" ; then - $as_echo "#define JEMALLOC_STATS " >>confdefs.h + +$as_echo "#define JEMALLOC_STATS " >>confdefs.h fi @@ -9779,7 +11018,8 @@ else fi if test "x$enable_experimental_smallocx" = "x1" ; then - $as_echo "#define JEMALLOC_EXPERIMENTAL_SMALLOCX_API 1" >>confdefs.h + +$as_echo "#define JEMALLOC_EXPERIMENTAL_SMALLOCX_API " >>confdefs.h fi @@ -9809,6 +11049,9 @@ if test "${enable_prof_libunwind+set}" = set; then : enable_prof_libunwind="0" else enable_prof_libunwind="1" + if test "x$enable_prof" = "x0" ; then + as_fn_error $? "--enable-prof-libunwind should only be used with --enable-prof" "$LINENO" 5 + fi fi else @@ -9909,7 +11152,8 @@ fi fi if test "x${enable_prof_libunwind}" = "x1" ; then backtrace_method="libunwind" - $as_echo "#define JEMALLOC_PROF_LIBUNWIND " >>confdefs.h + +$as_echo "#define JEMALLOC_PROF_LIBUNWIND " >>confdefs.h fi fi @@ -9996,7 +11240,8 @@ fi fi if test "x${enable_prof_libgcc}" = "x1" ; then backtrace_method="libgcc" - $as_echo "#define JEMALLOC_PROF_LIBGCC " >>confdefs.h + +$as_echo "#define JEMALLOC_PROF_LIBGCC " >>confdefs.h fi else @@ -10070,7 +11315,8 @@ fi backtrace_method="gcc intrinsics" - $as_echo "#define JEMALLOC_PROF_GCC " >>confdefs.h + +$as_echo "#define JEMALLOC_PROF_GCC " >>confdefs.h else enable_prof_gcc="0" @@ -10094,18 +11340,27 @@ fi - $as_echo "#define JEMALLOC_PROF " >>confdefs.h + +$as_echo "#define JEMALLOC_PROF " >>confdefs.h fi if test "x${maps_coalesce}" = "x1" ; then - $as_echo "#define JEMALLOC_MAPS_COALESCE " >>confdefs.h + +$as_echo "#define JEMALLOC_MAPS_COALESCE " >>confdefs.h fi if test "x$default_retain" = "x1" ; then - $as_echo "#define JEMALLOC_RETAIN " >>confdefs.h + +$as_echo "#define JEMALLOC_RETAIN " >>confdefs.h + +fi + +if test "x$zero_realloc_default_free" = "x1" ; then + +$as_echo "#define JEMALLOC_ZERO_REALLOC_DEFAULT_FREE " >>confdefs.h fi @@ -10128,7 +11383,8 @@ else fi if test "x$have_dss" = "x1" ; then - $as_echo "#define JEMALLOC_DSS " >>confdefs.h + +$as_echo "#define JEMALLOC_DSS " >>confdefs.h fi @@ -10146,7 +11402,8 @@ else fi if test "x$enable_fill" = "x1" ; then - $as_echo "#define JEMALLOC_FILL " >>confdefs.h + +$as_echo "#define JEMALLOC_FILL " >>confdefs.h fi @@ -10201,11 +11458,56 @@ fi $as_echo "$je_cv_utrace" >&6; } if test "x${je_cv_utrace}" = "xno" ; then - enable_utrace="0" + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether utrace(2) with label is compilable" >&5 +$as_echo_n "checking whether utrace(2) with label is compilable... " >&6; } +if ${je_cv_utrace_label+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #include + #include + #include + #include + #include + +int +main () +{ + + utrace((void *)0, (void *)0, 0); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + je_cv_utrace_label=yes +else + je_cv_utrace_label=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext fi -if test "x$enable_utrace" = "x1" ; then - $as_echo "#define JEMALLOC_UTRACE " >>confdefs.h +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $je_cv_utrace_label" >&5 +$as_echo "$je_cv_utrace_label" >&6; } + + if test "x${je_cv_utrace_label}" = "xno"; then + enable_utrace="0" + fi + if test "x$enable_utrace" = "x1" ; then +$as_echo "#define JEMALLOC_UTRACE_LABEL " >>confdefs.h + + fi +else + if test "x$enable_utrace" = "x1" ; then + +$as_echo "#define JEMALLOC_UTRACE " >>confdefs.h + + fi fi @@ -10223,7 +11525,8 @@ else fi if test "x$enable_xmalloc" = "x1" ; then - $as_echo "#define JEMALLOC_XMALLOC " >>confdefs.h + +$as_echo "#define JEMALLOC_XMALLOC " >>confdefs.h fi @@ -10242,7 +11545,8 @@ else fi if test "x$enable_cache_oblivious" = "x1" ; then - $as_echo "#define JEMALLOC_CACHE_OBLIVIOUS " >>confdefs.h + +$as_echo "#define JEMALLOC_CACHE_OBLIVIOUS " >>confdefs.h fi @@ -10261,7 +11565,8 @@ else fi if test "x$enable_log" = "x1" ; then - $as_echo "#define JEMALLOC_LOG " >>confdefs.h + +$as_echo "#define JEMALLOC_LOG " >>confdefs.h fi @@ -10280,7 +11585,8 @@ else fi if test "x$enable_readlinkat" = "x1" ; then - $as_echo "#define JEMALLOC_READLINKAT " >>confdefs.h + +$as_echo "#define JEMALLOC_READLINKAT " >>confdefs.h fi @@ -10299,7 +11605,47 @@ else fi if test "x$enable_opt_safety_checks" = "x1" ; then - $as_echo "#define JEMALLOC_OPT_SAFETY_CHECKS " >>confdefs.h + +$as_echo "#define JEMALLOC_OPT_SAFETY_CHECKS " >>confdefs.h + +fi + + +# Check whether --enable-opt-size-checks was given. +if test "${enable_opt_size_checks+set}" = set; then : + enableval=$enable_opt_size_checks; if test "x$enable_opt_size_checks" = "xno" ; then + enable_opt_size_checks="0" +else + enable_opt_size_checks="1" +fi + +else + enable_opt_size_checks="0" + +fi + +if test "x$enable_opt_size_checks" = "x1" ; then + +$as_echo "#define JEMALLOC_OPT_SIZE_CHECKS " >>confdefs.h + +fi + + +# Check whether --enable-uaf-detection was given. +if test "${enable_uaf_detection+set}" = set; then : + enableval=$enable_uaf_detection; if test "x$enable_uaf_detection" = "xno" ; then + enable_uaf_detection="0" +else + enable_uaf_detection="1" +fi + +else + enable_uaf_detection="0" + +fi + +if test "x$enable_uaf_detection" = "x1" ; then + $as_echo "#define JEMALLOC_UAF_DETECTION " >>confdefs.h fi @@ -10341,10 +11687,12 @@ fi $as_echo "$je_cv_gcc_builtin_unreachable" >&6; } if test "x${je_cv_gcc_builtin_unreachable}" = "xyes" ; then - $as_echo "#define JEMALLOC_INTERNAL_UNREACHABLE __builtin_unreachable" >>confdefs.h + +$as_echo "#define JEMALLOC_INTERNAL_UNREACHABLE __builtin_unreachable" >>confdefs.h else - $as_echo "#define JEMALLOC_INTERNAL_UNREACHABLE abort" >>confdefs.h + +$as_echo "#define JEMALLOC_INTERNAL_UNREACHABLE abort" >>confdefs.h fi @@ -10386,11 +11734,14 @@ fi $as_echo "$je_cv_gcc_builtin_ffsl" >&6; } if test "x${je_cv_gcc_builtin_ffsl}" = "xyes" ; then - $as_echo "#define JEMALLOC_INTERNAL_FFSLL __builtin_ffsll" >>confdefs.h - $as_echo "#define JEMALLOC_INTERNAL_FFSL __builtin_ffsl" >>confdefs.h +$as_echo "#define JEMALLOC_INTERNAL_FFSLL __builtin_ffsll" >>confdefs.h - $as_echo "#define JEMALLOC_INTERNAL_FFS __builtin_ffs" >>confdefs.h + +$as_echo "#define JEMALLOC_INTERNAL_FFSL __builtin_ffsl" >>confdefs.h + + +$as_echo "#define JEMALLOC_INTERNAL_FFS __builtin_ffs" >>confdefs.h else @@ -10431,11 +11782,14 @@ fi $as_echo "$je_cv_function_ffsl" >&6; } if test "x${je_cv_function_ffsl}" = "xyes" ; then - $as_echo "#define JEMALLOC_INTERNAL_FFSLL ffsll" >>confdefs.h - $as_echo "#define JEMALLOC_INTERNAL_FFSL ffsl" >>confdefs.h +$as_echo "#define JEMALLOC_INTERNAL_FFSLL ffsll" >>confdefs.h + - $as_echo "#define JEMALLOC_INTERNAL_FFS ffs" >>confdefs.h +$as_echo "#define JEMALLOC_INTERNAL_FFSL ffsl" >>confdefs.h + + +$as_echo "#define JEMALLOC_INTERNAL_FFS ffs" >>confdefs.h else as_fn_error $? "Cannot build without ffsl(3) or __builtin_ffsl()" "$LINENO" 5 @@ -10480,28 +11834,48 @@ fi $as_echo "$je_cv_gcc_builtin_popcountl" >&6; } if test "x${je_cv_gcc_builtin_popcountl}" = "xyes" ; then - $as_echo "#define JEMALLOC_INTERNAL_POPCOUNT __builtin_popcount" >>confdefs.h - $as_echo "#define JEMALLOC_INTERNAL_POPCOUNTL __builtin_popcountl" >>confdefs.h +$as_echo "#define JEMALLOC_INTERNAL_POPCOUNT __builtin_popcount" >>confdefs.h + + +$as_echo "#define JEMALLOC_INTERNAL_POPCOUNTL __builtin_popcountl" >>confdefs.h + + +$as_echo "#define JEMALLOC_INTERNAL_POPCOUNTLL __builtin_popcountll" >>confdefs.h fi # Check whether --with-lg_quantum was given. if test "${with_lg_quantum+set}" = set; then : - withval=$with_lg_quantum; LG_QUANTA="$with_lg_quantum" -else - LG_QUANTA="3 4" + withval=$with_lg_quantum; fi if test "x$with_lg_quantum" != "x" ; then - cat >>confdefs.h <<_ACEOF + +cat >>confdefs.h <<_ACEOF #define LG_QUANTUM $with_lg_quantum _ACEOF fi +# Check whether --with-lg_slab_maxregs was given. +if test "${with_lg_slab_maxregs+set}" = set; then : + withval=$with_lg_slab_maxregs; CONFIG_LG_SLAB_MAXREGS="with_lg_slab_maxregs" +else + CONFIG_LG_SLAB_MAXREGS="" +fi + +if test "x$with_lg_slab_maxregs" != "x" ; then + +cat >>confdefs.h <<_ACEOF +#define CONFIG_LG_SLAB_MAXREGS $with_lg_slab_maxregs +_ACEOF + +fi + + # Check whether --with-lg_page was given. if test "${with_lg_page+set}" = set; then : withval=$with_lg_page; LG_PAGE="$with_lg_page" @@ -10509,6 +11883,13 @@ else LG_PAGE="detect" fi +case "${host}" in + aarch64-apple-darwin*) + if test "x${host}" != "x${build}" -a "x$LG_PAGE" = "xdetect"; then + LG_PAGE=14 + fi + ;; +esac if test "x$LG_PAGE" = "xdetect"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking LG_PAGE" >&5 $as_echo_n "checking LG_PAGE... " >&6; } @@ -10578,7 +11959,8 @@ if test "x${je_cv_lg_page}" != "x" ; then LG_PAGE="${je_cv_lg_page}" fi if test "x${LG_PAGE}" != "xundefined" ; then - cat >>confdefs.h <<_ACEOF + +cat >>confdefs.h <<_ACEOF #define LG_PAGE $LG_PAGE _ACEOF @@ -10616,6 +11998,7 @@ if test "x${LG_PAGE}" != "xundefined" -a \ "${je_cv_lg_hugepage}" -lt "${LG_PAGE}" ; then as_fn_error $? "Huge page size (2^${je_cv_lg_hugepage}) must be at least page size (2^${LG_PAGE})" "$LINENO" 5 fi + cat >>confdefs.h <<_ACEOF #define LG_HUGEPAGE ${je_cv_lg_hugepage} _ACEOF @@ -10638,7 +12021,8 @@ fi if test "x$abi" != "xpecoff" ; then - $as_echo "#define JEMALLOC_HAVE_PTHREAD " >>confdefs.h + +$as_echo "#define JEMALLOC_HAVE_PTHREAD " >>confdefs.h for ac_header in pthread.h do : @@ -10827,7 +12211,8 @@ fi done if test "x$have_dlsym" = "x1" ; then - $as_echo "#define JEMALLOC_HAVE_DLSYM " >>confdefs.h + +$as_echo "#define JEMALLOC_HAVE_DLSYM " >>confdefs.h fi else @@ -10867,7 +12252,8 @@ fi $as_echo "$je_cv_pthread_atfork" >&6; } if test "x${je_cv_pthread_atfork}" = "xyes" ; then - $as_echo "#define JEMALLOC_HAVE_PTHREAD_ATFORK " >>confdefs.h + +$as_echo "#define JEMALLOC_HAVE_PTHREAD_ATFORK " >>confdefs.h fi @@ -10903,7 +12289,93 @@ fi $as_echo "$je_cv_pthread_setname_np" >&6; } if test "x${je_cv_pthread_setname_np}" = "xyes" ; then - $as_echo "#define JEMALLOC_HAVE_PTHREAD_SETNAME_NP " >>confdefs.h + +$as_echo "#define JEMALLOC_HAVE_PTHREAD_SETNAME_NP " >>confdefs.h + + fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pthread_getname_np(3) is compilable" >&5 +$as_echo_n "checking whether pthread_getname_np(3) is compilable... " >&6; } +if ${je_cv_pthread_getname_np+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include + +int +main () +{ + + { + char *name = malloc(16); + pthread_getname_np(pthread_self(), name, 16); + free(name); + } + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + je_cv_pthread_getname_np=yes +else + je_cv_pthread_getname_np=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $je_cv_pthread_getname_np" >&5 +$as_echo "$je_cv_pthread_getname_np" >&6; } + + if test "x${je_cv_pthread_getname_np}" = "xyes" ; then + +$as_echo "#define JEMALLOC_HAVE_PTHREAD_GETNAME_NP " >>confdefs.h + + fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pthread_get_name_np(3) is compilable" >&5 +$as_echo_n "checking whether pthread_get_name_np(3) is compilable... " >&6; } +if ${je_cv_pthread_get_name_np+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#include + +int +main () +{ + + { + char *name = malloc(16); + pthread_get_name_np(pthread_self(), name, 16); + free(name); + } + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + je_cv_pthread_get_name_np=yes +else + je_cv_pthread_get_name_np=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $je_cv_pthread_get_name_np" >&5 +$as_echo "$je_cv_pthread_get_name_np" >&6; } + + if test "x${je_cv_pthread_get_name_np}" = "xyes" ; then + +$as_echo "#define JEMALLOC_HAVE_PTHREAD_GET_NAME_NP " >>confdefs.h fi fi @@ -11134,7 +12606,8 @@ fi $as_echo "$je_cv_clock_monotonic_coarse" >&6; } if test "x${je_cv_clock_monotonic_coarse}" = "xyes" ; then - $as_echo "#define JEMALLOC_HAVE_CLOCK_MONOTONIC_COARSE 1" >>confdefs.h + +$as_echo "#define JEMALLOC_HAVE_CLOCK_MONOTONIC_COARSE " >>confdefs.h fi @@ -11177,7 +12650,8 @@ fi $as_echo "$je_cv_clock_monotonic" >&6; } if test "x${je_cv_clock_monotonic}" = "xyes" ; then - $as_echo "#define JEMALLOC_HAVE_CLOCK_MONOTONIC 1" >>confdefs.h + +$as_echo "#define JEMALLOC_HAVE_CLOCK_MONOTONIC " >>confdefs.h fi @@ -11214,7 +12688,48 @@ fi $as_echo "$je_cv_mach_absolute_time" >&6; } if test "x${je_cv_mach_absolute_time}" = "xyes" ; then - $as_echo "#define JEMALLOC_HAVE_MACH_ABSOLUTE_TIME 1" >>confdefs.h + +$as_echo "#define JEMALLOC_HAVE_MACH_ABSOLUTE_TIME " >>confdefs.h + +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether clock_gettime(CLOCK_REALTIME, ...) is compilable" >&5 +$as_echo_n "checking whether clock_gettime(CLOCK_REALTIME, ...) is compilable... " >&6; } +if ${je_cv_clock_realtime+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include + +int +main () +{ + + struct timespec ts; + + clock_gettime(CLOCK_REALTIME, &ts); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + je_cv_clock_realtime=yes +else + je_cv_clock_realtime=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $je_cv_clock_realtime" >&5 +$as_echo "$je_cv_clock_realtime" >&6; } + +if test "x${je_cv_clock_realtime}" = "xyes" ; then + +$as_echo "#define JEMALLOC_HAVE_CLOCK_REALTIME " >>confdefs.h fi @@ -11327,7 +12842,8 @@ fi if test "x$je_cv_syscall" = "xyes" ; then - $as_echo "#define JEMALLOC_USE_SYSCALL " >>confdefs.h + +$as_echo "#define JEMALLOC_USE_SYSCALL " >>confdefs.h fi fi @@ -11341,7 +12857,8 @@ else fi if test "x$have_secure_getenv" = "x1" ; then - $as_echo "#define JEMALLOC_HAVE_SECURE_GETENV " >>confdefs.h + +$as_echo "#define JEMALLOC_HAVE_SECURE_GETENV " >>confdefs.h fi @@ -11354,7 +12871,8 @@ else fi if test "x$have_sched_getcpu" = "x1" ; then - $as_echo "#define JEMALLOC_HAVE_SCHED_GETCPU " >>confdefs.h + +$as_echo "#define JEMALLOC_HAVE_SCHED_GETCPU " >>confdefs.h fi @@ -11367,7 +12885,8 @@ else fi if test "x$have_sched_setaffinity" = "x1" ; then - $as_echo "#define JEMALLOC_HAVE_SCHED_SETAFFINITY " >>confdefs.h + +$as_echo "#define JEMALLOC_HAVE_SCHED_SETAFFINITY " >>confdefs.h fi @@ -11380,7 +12899,8 @@ else fi if test "x$have_issetugid" = "x1" ; then - $as_echo "#define JEMALLOC_HAVE_ISSETUGID " >>confdefs.h + +$as_echo "#define JEMALLOC_HAVE_ISSETUGID " >>confdefs.h fi @@ -11393,9 +12913,10 @@ else fi if test "x$have__malloc_thread_cleanup" = "x1" ; then - $as_echo "#define JEMALLOC_MALLOC_THREAD_CLEANUP " >>confdefs.h - wrap_syms="${wrap_syms} _malloc_thread_cleanup" +$as_echo "#define JEMALLOC_MALLOC_THREAD_CLEANUP " >>confdefs.h + + wrap_syms="${wrap_syms} _malloc_thread_cleanup _malloc_tsd_cleanup_register" force_tls="1" fi @@ -11408,11 +12929,25 @@ else fi if test "x$have__pthread_mutex_init_calloc_cb" = "x1" ; then - $as_echo "#define JEMALLOC_MUTEX_INIT_CB 1" >>confdefs.h + +$as_echo "#define JEMALLOC_MUTEX_INIT_CB " >>confdefs.h wrap_syms="${wrap_syms} _malloc_prefork _malloc_postfork" fi +ac_fn_c_check_func "$LINENO" "memcntl" "ac_cv_func_memcntl" +if test "x$ac_cv_func_memcntl" = xyes; then : + have_memcntl="1" +else + have_memcntl="0" +fi + +if test "x$have_memcntl" = "x1" ; then + +$as_echo "#define JEMALLOC_HAVE_MEMCNTL " >>confdefs.h + +fi + # Check whether --enable-lazy_lock was given. if test "${enable_lazy_lock+set}" = set; then : enableval=$enable_lazy_lock; if test "x$enable_lazy_lock" = "xno" ; then @@ -11442,7 +12977,8 @@ $as_echo "Forcing no lazy-lock because thread creation monitoring is unimplement fi if test "x$enable_lazy_lock" = "x1" ; then if test "x$have_dlsym" = "x1" ; then - $as_echo "#define JEMALLOC_LAZY_LOCK " >>confdefs.h + +$as_echo "#define JEMALLOC_LAZY_LOCK " >>confdefs.h else as_fn_error $? "Missing dlsym support: lazy-lock cannot be enabled." "$LINENO" 5 @@ -11491,7 +13027,8 @@ else fi if test "x${enable_tls}" = "x1" ; then - cat >>confdefs.h <<_ACEOF + +cat >>confdefs.h <<_ACEOF #define JEMALLOC_TLS _ACEOF @@ -11540,7 +13077,8 @@ fi $as_echo "$je_cv_c11_atomics" >&6; } if test "x${je_cv_c11_atomics}" = "xyes" ; then - $as_echo "#define JEMALLOC_C11_ATOMICS 1" >>confdefs.h + +$as_echo "#define JEMALLOC_C11_ATOMICS " >>confdefs.h fi @@ -11581,7 +13119,8 @@ fi $as_echo "$je_cv_gcc_atomic_atomics" >&6; } if test "x${je_cv_gcc_atomic_atomics}" = "xyes" ; then - $as_echo "#define JEMALLOC_GCC_ATOMIC_ATOMICS 1" >>confdefs.h + +$as_echo "#define JEMALLOC_GCC_ATOMIC_ATOMICS " >>confdefs.h @@ -11620,7 +13159,8 @@ fi $as_echo "$je_cv_gcc_u8_atomic_atomics" >&6; } if test "x${je_cv_gcc_u8_atomic_atomics}" = "xyes" ; then - $as_echo "#define JEMALLOC_GCC_U8_ATOMIC_ATOMICS 1" >>confdefs.h + +$as_echo "#define JEMALLOC_GCC_U8_ATOMIC_ATOMICS " >>confdefs.h fi fi @@ -11661,7 +13201,8 @@ fi $as_echo "$je_cv_gcc_sync_atomics" >&6; } if test "x${je_cv_gcc_sync_atomics}" = "xyes" ; then - $as_echo "#define JEMALLOC_GCC_SYNC_ATOMICS 1" >>confdefs.h + +$as_echo "#define JEMALLOC_GCC_SYNC_ATOMICS " >>confdefs.h @@ -11699,7 +13240,8 @@ fi $as_echo "$je_cv_gcc_u8_sync_atomics" >&6; } if test "x${je_cv_gcc_u8_sync_atomics}" = "xyes" ; then - $as_echo "#define JEMALLOC_GCC_U8_SYNC_ATOMICS 1" >>confdefs.h + +$as_echo "#define JEMALLOC_GCC_U8_SYNC_ATOMICS " >>confdefs.h fi fi @@ -11748,7 +13290,8 @@ fi $as_echo "$je_cv_osatomic" >&6; } if test "x${je_cv_osatomic}" = "xyes" ; then - $as_echo "#define JEMALLOC_OSATOMIC " >>confdefs.h + +$as_echo "#define JEMALLOC_OSATOMIC " >>confdefs.h fi @@ -11786,7 +13329,8 @@ fi $as_echo "$je_cv_madvise" >&6; } if test "x${je_cv_madvise}" = "xyes" ; then - $as_echo "#define JEMALLOC_HAVE_MADVISE " >>confdefs.h + +$as_echo "#define JEMALLOC_HAVE_MADVISE " >>confdefs.h @@ -11822,14 +13366,17 @@ fi $as_echo "$je_cv_madv_free" >&6; } if test "x${je_cv_madv_free}" = "xyes" ; then - $as_echo "#define JEMALLOC_PURGE_MADVISE_FREE " >>confdefs.h + +$as_echo "#define JEMALLOC_PURGE_MADVISE_FREE " >>confdefs.h elif test "x${je_cv_madvise}" = "xyes" ; then case "${host_cpu}" in i686|x86_64) case "${host}" in *-*-linux*) - $as_echo "#define JEMALLOC_PURGE_MADVISE_FREE " >>confdefs.h - $as_echo "#define JEMALLOC_DEFINE_MADVISE_FREE " >>confdefs.h +$as_echo "#define JEMALLOC_PURGE_MADVISE_FREE " >>confdefs.h + + +$as_echo "#define JEMALLOC_DEFINE_MADVISE_FREE " >>confdefs.h ;; esac @@ -11870,7 +13417,8 @@ fi $as_echo "$je_cv_madv_dontneed" >&6; } if test "x${je_cv_madv_dontneed}" = "xyes" ; then - $as_echo "#define JEMALLOC_PURGE_MADVISE_DONTNEED " >>confdefs.h + +$as_echo "#define JEMALLOC_PURGE_MADVISE_DONTNEED " >>confdefs.h fi @@ -11908,7 +13456,8 @@ fi $as_echo "$je_cv_madv_dontdump" >&6; } if test "x${je_cv_madv_dontdump}" = "xyes" ; then - $as_echo "#define JEMALLOC_MADVISE_DONTDUMP " >>confdefs.h + +$as_echo "#define JEMALLOC_MADVISE_DONTDUMP " >>confdefs.h fi @@ -11945,16 +13494,170 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $je_cv_thp" >&5 $as_echo "$je_cv_thp" >&6; } + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether madvise(..., MADV_[NO]CORE) is compilable" >&5 +$as_echo_n "checking whether madvise(..., MADV_[NO]CORE) is compilable... " >&6; } +if ${je_cv_madv_nocore+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include + +int +main () +{ + + madvise((void *)0, 0, MADV_NOCORE); + madvise((void *)0, 0, MADV_CORE); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + je_cv_madv_nocore=yes +else + je_cv_madv_nocore=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $je_cv_madv_nocore" >&5 +$as_echo "$je_cv_madv_nocore" >&6; } + + if test "x${je_cv_madv_nocore}" = "xyes" ; then + +$as_echo "#define JEMALLOC_MADVISE_NOCORE " >>confdefs.h + + fi case "${host_cpu}" in arm*) ;; *) if test "x${je_cv_thp}" = "xyes" ; then - $as_echo "#define JEMALLOC_HAVE_MADVISE_HUGE " >>confdefs.h + +$as_echo "#define JEMALLOC_HAVE_MADVISE_HUGE " >>confdefs.h fi ;; esac +else + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether posix_madvise is compilable" >&5 +$as_echo_n "checking whether posix_madvise is compilable... " >&6; } +if ${je_cv_posix_madvise+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #include + +int +main () +{ + + posix_madvise((void *)0, 0, 0); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + je_cv_posix_madvise=yes +else + je_cv_posix_madvise=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $je_cv_posix_madvise" >&5 +$as_echo "$je_cv_posix_madvise" >&6; } + + if test "x${je_cv_posix_madvise}" = "xyes" ; then + +$as_echo "#define JEMALLOC_HAVE_POSIX_MADVISE " >>confdefs.h + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether posix_madvise(..., POSIX_MADV_DONTNEED) is compilable" >&5 +$as_echo_n "checking whether posix_madvise(..., POSIX_MADV_DONTNEED) is compilable... " >&6; } +if ${je_cv_posix_madv_dontneed+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #include + +int +main () +{ + + posix_madvise((void *)0, 0, POSIX_MADV_DONTNEED); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + je_cv_posix_madv_dontneed=yes +else + je_cv_posix_madv_dontneed=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $je_cv_posix_madv_dontneed" >&5 +$as_echo "$je_cv_posix_madv_dontneed" >&6; } + + if test "x${je_cv_posix_madv_dontneed}" = "xyes" ; then + +$as_echo "#define JEMALLOC_PURGE_POSIX_MADVISE_DONTNEED " >>confdefs.h + + fi + fi +fi + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mprotect(2) is compilable" >&5 +$as_echo_n "checking whether mprotect(2) is compilable... " >&6; } +if ${je_cv_mprotect+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include + +int +main () +{ + + mprotect((void *)0, 0, PROT_NONE); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + je_cv_mprotect=yes +else + je_cv_mprotect=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $je_cv_mprotect" >&5 +$as_echo "$je_cv_mprotect" >&6; } + +if test "x${je_cv_mprotect}" = "xyes" ; then + +$as_echo "#define JEMALLOC_HAVE_MPROTECT " >>confdefs.h + fi @@ -11978,6 +13681,10 @@ main () unsigned long x = 0; int y = __builtin_clzl(x); } + { + unsigned long long x = 0; + int y = __builtin_clzll(x); + } ; return 0; @@ -11995,7 +13702,8 @@ fi $as_echo "$je_cv_builtin_clz" >&6; } if test "x${je_cv_builtin_clz}" = "xyes" ; then - $as_echo "#define JEMALLOC_HAVE_BUILTIN_CLZ " >>confdefs.h + +$as_echo "#define JEMALLOC_HAVE_BUILTIN_CLZ " >>confdefs.h fi @@ -12040,7 +13748,8 @@ fi $as_echo "$je_cv_os_unfair_lock" >&6; } if test "x${je_cv_os_unfair_lock}" = "xyes" ; then - $as_echo "#define JEMALLOC_OS_UNFAIR_LOCK " >>confdefs.h + +$as_echo "#define JEMALLOC_OS_UNFAIR_LOCK " >>confdefs.h fi @@ -12067,7 +13776,8 @@ if test "x${enable_zone_allocator}" = "x1" ; then if test "x${abi}" != "xmacho"; then as_fn_error $? "--enable-zone-allocator is only supported on Darwin" "$LINENO" 5 fi - $as_echo "#define JEMALLOC_ZONE " >>confdefs.h + +$as_echo "#define JEMALLOC_ZONE " >>confdefs.h fi @@ -12088,20 +13798,25 @@ fi if test "x${je_cv_tls_model}" = "xyes" -a \ "x${enable_initial_exec_tls}" = "x1" ; then - $as_echo "#define JEMALLOC_TLS_MODEL __attribute__((tls_model(\"initial-exec\")))" >>confdefs.h + +$as_echo "#define JEMALLOC_TLS_MODEL __attribute__((tls_model(\"initial-exec\")))" >>confdefs.h else - $as_echo "#define JEMALLOC_TLS_MODEL " >>confdefs.h + +$as_echo "#define JEMALLOC_TLS_MODEL " >>confdefs.h fi -if test "x${have_pthread}" = "x1" -a "x${je_cv_os_unfair_lock}" != "xyes" ; then - $as_echo "#define JEMALLOC_BACKGROUND_THREAD 1" >>confdefs.h +if test "x${have_pthread}" = "x1" -a "x${je_cv_os_unfair_lock}" != "xyes" -a \ + "x${abi}" != "xmacho" ; then + +$as_echo "#define JEMALLOC_BACKGROUND_THREAD " >>confdefs.h fi +if test "x$glibc" = "x1" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether glibc malloc hook is compilable" >&5 $as_echo_n "checking whether glibc malloc hook is compilable... " >&6; } @@ -12111,20 +13826,20 @@ else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include + #include -extern void (* __free_hook)(void *ptr); -extern void *(* __malloc_hook)(size_t size); -extern void *(* __realloc_hook)(void *ptr, size_t size); + extern void (* __free_hook)(void *ptr); + extern void *(* __malloc_hook)(size_t size); + extern void *(* __realloc_hook)(void *ptr, size_t size); int main () { - void *ptr = 0L; - if (__malloc_hook) ptr = __malloc_hook(1); - if (__realloc_hook) ptr = __realloc_hook(ptr, 2); - if (__free_hook && ptr) __free_hook(ptr); + void *ptr = 0L; + if (__malloc_hook) ptr = __malloc_hook(1); + if (__realloc_hook) ptr = __realloc_hook(ptr, 2); + if (__free_hook && ptr) __free_hook(ptr); ; return 0; @@ -12141,13 +13856,14 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $je_cv_glibc_malloc_hook" >&5 $as_echo "$je_cv_glibc_malloc_hook" >&6; } -if test "x${je_cv_glibc_malloc_hook}" = "xyes" ; then - if test "x${JEMALLOC_PREFIX}" = "x" ; then - $as_echo "#define JEMALLOC_GLIBC_MALLOC_HOOK " >>confdefs.h + if test "x${je_cv_glibc_malloc_hook}" = "xyes" ; then + if test "x${JEMALLOC_PREFIX}" = "x" ; then + +$as_echo "#define JEMALLOC_GLIBC_MALLOC_HOOK " >>confdefs.h - wrap_syms="${wrap_syms} __free_hook __malloc_hook __realloc_hook" + wrap_syms="${wrap_syms} __free_hook __malloc_hook __realloc_hook" + fi fi -fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether glibc memalign hook is compilable" >&5 @@ -12158,16 +13874,16 @@ else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include + #include -extern void *(* __memalign_hook)(size_t alignment, size_t size); + extern void *(* __memalign_hook)(size_t alignment, size_t size); int main () { - void *ptr = 0L; - if (__memalign_hook) ptr = __memalign_hook(16, 7); + void *ptr = 0L; + if (__memalign_hook) ptr = __memalign_hook(16, 7); ; return 0; @@ -12184,11 +13900,13 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $je_cv_glibc_memalign_hook" >&5 $as_echo "$je_cv_glibc_memalign_hook" >&6; } -if test "x${je_cv_glibc_memalign_hook}" = "xyes" ; then - if test "x${JEMALLOC_PREFIX}" = "x" ; then - $as_echo "#define JEMALLOC_GLIBC_MEMALIGN_HOOK " >>confdefs.h + if test "x${je_cv_glibc_memalign_hook}" = "xyes" ; then + if test "x${JEMALLOC_PREFIX}" = "x" ; then - wrap_syms="${wrap_syms} __memalign_hook" +$as_echo "#define JEMALLOC_GLIBC_MEMALIGN_HOOK " >>confdefs.h + + wrap_syms="${wrap_syms} __memalign_hook" + fi fi fi @@ -12228,7 +13946,8 @@ fi $as_echo "$je_cv_pthread_mutex_adaptive_np" >&6; } if test "x${je_cv_pthread_mutex_adaptive_np}" = "xyes" ; then - $as_echo "#define JEMALLOC_HAVE_PTHREAD_MUTEX_ADAPTIVE_NP " >>confdefs.h + +$as_echo "#define JEMALLOC_HAVE_PTHREAD_MUTEX_ADAPTIVE_NP " >>confdefs.h fi @@ -12433,7 +14152,8 @@ fi if test "x${je_cv_strerror_r_returns_char_with_gnu_source}" = "xyes" ; then - $as_echo "#define JEMALLOC_STRERROR_R_RETURNS_CHAR_WITH_GNU_SOURCE " >>confdefs.h + +$as_echo "#define JEMALLOC_STRERROR_R_RETURNS_CHAR_WITH_GNU_SOURCE " >>confdefs.h fi @@ -14072,8 +15792,8 @@ $as_echo "autogen : ${enable_autogen}" >&6; } $as_echo "debug : ${enable_debug}" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: stats : ${enable_stats}" >&5 $as_echo "stats : ${enable_stats}" >&6; } -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: experimetal_smallocx : ${enable_experimental_smallocx}" >&5 -$as_echo "experimetal_smallocx : ${enable_experimental_smallocx}" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: experimental_smallocx : ${enable_experimental_smallocx}" >&5 +$as_echo "experimental_smallocx : ${enable_experimental_smallocx}" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: prof : ${enable_prof}" >&5 $as_echo "prof : ${enable_prof}" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: prof-libunwind : ${enable_prof_libunwind}" >&5 diff --git a/jemalloc-sys/jemalloc b/jemalloc-sys/jemalloc index 172143a297..54eaed1d8b 160000 --- a/jemalloc-sys/jemalloc +++ b/jemalloc-sys/jemalloc @@ -1 +1 @@ -Subproject commit 172143a2979d9d948035423ce347e35cd1388fc3 +Subproject commit 54eaed1d8b56b1aa528be3bdd1877e59c56fa90c diff --git a/jemalloc-sys/src/env.rs b/jemalloc-sys/src/env.rs new file mode 100644 index 0000000000..f4d3e8e1d9 --- /dev/null +++ b/jemalloc-sys/src/env.rs @@ -0,0 +1,25 @@ +/// `jemalloc` is known not to work on these targets: +pub static UNSUPPORTED_TARGETS: &[&str] = &[ + "rumprun", + "bitrig", + "emscripten", + "fuchsia", + "redox", + "wasm32", +]; + +/// `jemalloc-sys` is not tested on these targets in CI: +pub static UNTESTED_TARGETS: &[&str] = &["openbsd", "msvc"]; + +/// `jemalloc`'s background_thread support is known not to work on these targets: +pub static NO_BG_THREAD_TARGETS: &[&str] = &["musl"]; + +/// targets that don't support unprefixed `malloc` +// “it was found that the `realpath` function in libc would allocate with libc malloc +// (not jemalloc malloc), and then the standard library would free with jemalloc free, +// causing a segfault.” +// https://github.com/rust-lang/rust/commit/e3b414d8612314e74e2b0ebde1ed5c6997d28e8d +// https://github.com/rust-lang/rust/commit/536011d929ecbd1170baf34e09580e567c971f95 +// https://github.com/rust-lang/rust/commit/9f3de647326fbe50e0e283b9018ab7c41abccde3 +// https://github.com/rust-lang/rust/commit/ed015456a114ae907a36af80c06f81ea93182a24 +pub static NO_UNPREFIXED_MALLOC_TARGETS: &[&str] = &["android", "dragonfly", "musl", "darwin"]; diff --git a/jemalloc-sys/src/lib.rs b/jemalloc-sys/src/lib.rs index 37518028c2..1344e27b92 100644 --- a/jemalloc-sys/src/lib.rs +++ b/jemalloc-sys/src/lib.rs @@ -59,7 +59,7 @@ type c_bool = c_int; /// /// It does not validate that `la` is within the valid range. #[inline] -pub fn MALLOCX_LG_ALIGN(la: usize) -> c_int { +pub const fn MALLOCX_LG_ALIGN(la: usize) -> c_int { la as c_int } @@ -70,7 +70,7 @@ pub fn MALLOCX_LG_ALIGN(la: usize) -> c_int { /// /// This macro does not validate that a is a power of 2. #[inline] -pub fn MALLOCX_ALIGN(aling: usize) -> c_int { +pub const fn MALLOCX_ALIGN(aling: usize) -> c_int { aling.trailing_zeros() as c_int } @@ -90,7 +90,7 @@ pub const MALLOCX_ZERO: c_int = 0x40; /// `tc` must have been acquired via the `tcache.create mallctl`. This function /// does not validate that `tc` specifies a valid identifier. #[inline] -pub fn MALLOCX_TCACHE(tc: usize) -> c_int { +pub const fn MALLOCX_TCACHE(tc: usize) -> c_int { tc.wrapping_add(2).wrapping_shl(8) as c_int } @@ -104,10 +104,7 @@ pub fn MALLOCX_TCACHE(tc: usize) -> c_int { /// This option cannot be used in the same `flags` argument as /// `MALLOCX_TCACHE(tc)`. // FIXME: This should just be a const. -#[inline] -pub fn MALLOCX_TCACHE_NONE() -> c_int { - MALLOCX_TCACHE(!0) -} +pub const MALLOCX_TCACHE_NONE: c_int = MALLOCX_TCACHE((-1isize) as usize); /// Use the arena specified by the index `a`. /// @@ -119,7 +116,7 @@ pub fn MALLOCX_TCACHE_NONE() -> c_int { /// This function does not validate that `a` specifies an arena index in the /// valid range. #[inline] -pub fn MALLOCX_ARENA(a: usize) -> c_int { +pub const fn MALLOCX_ARENA(a: usize) -> c_int { (a as c_int).wrapping_add(1).wrapping_shl(20) } @@ -899,3 +896,8 @@ pub extern "C" fn pthread_atfork( ) -> i32 { 0 } + +#[allow(missing_docs)] +mod env; + +pub use env::*; diff --git a/jemallocator-global/Cargo.toml b/jemallocator-global/Cargo.toml index fb75d4263f..7d544b5180 100644 --- a/jemallocator-global/Cargo.toml +++ b/jemallocator-global/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "tikv-jemallocator-global" # Make sure to update the version in the readme as well: -version = "0.4.0" +version = "0.4.3" authors = [ "Gonzalo Brito Gadeschi ", "The TiKV Project Developers", @@ -26,7 +26,7 @@ is-it-maintained-open-issues = { repository = "tikv/jemallocator" } maintenance = { status = "actively-developed" } [dependencies] -tikv-jemallocator = { version = "0.4.0", path = "..", optional = true } +tikv-jemallocator = { version = "0.4.0", path = "../jemallocator", optional = true } cfg-if = "0.1" [features] @@ -38,11 +38,11 @@ force_global_jemalloc = [ "tikv-jemallocator" ] # for a particular target, white-list the target explicitly here: [target.'cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd"))'.dependencies] -tikv-jemallocator = { version = "0.4.0", path = "..", optional = false } +tikv-jemallocator = { version = "0.4.0", path = "../jemallocator", optional = false } # FIXME: https://github.com/gnzlbg/jemallocator/issues/91 # [target.'cfg(target_os = "windows")'.dependencies] -# jemallocator = { path = ".." } +# jemallocator = { path = "../jemallocator" } # `jemalloc` is known not to work on - see `jemalloc-sys/build.rs`. # - rumprun diff --git a/jemallocator/Cargo.toml b/jemallocator/Cargo.toml new file mode 100644 index 0000000000..18eaa8da53 --- /dev/null +++ b/jemallocator/Cargo.toml @@ -0,0 +1,56 @@ +[package] +name = "tikv-jemallocator" +# Make sure to update the version in the README as well: +version = "0.4.3" +authors = [ + "Alex Crichton ", + "Gonzalo Brito Gadeschi ", + "Simon Sapin ", + "Steven Fackler ", + "The TiKV Project Developers", +] +license = "MIT/Apache-2.0" +readme = "README.md" +keywords = ["allocator", "jemalloc"] +categories = ["memory-management", "api-bindings"] +repository = "https://github.com/tikv/jemallocator" +homepage = "https://github.com/tikv/jemallocator" +documentation = "https://docs.rs/jemallocator" +description = """ +A Rust allocator backed by jemalloc +""" +edition = "2018" + +[badges] +travis-ci = { repository = "tikv/jemallocator" } +codecov = { repository = "tikv/jemallocator" } +is-it-maintained-issue-resolution = { repository = "tikv/jemallocator" } +is-it-maintained-open-issues = { repository = "tikv/jemallocator" } +maintenance = { status = "actively-developed" } + +[lib] +test = false +bench = false + +[dependencies] +tikv-jemalloc-sys = { path = "../jemalloc-sys", version = "0.4.0", default-features = false } +libc = { version = "^0.2.8", default-features = false } + +[dev-dependencies] +paste = "1" +tikv-jemalloc-ctl = { path = "../jemalloc-ctl", version = "0.4.0" } + +[features] +default = ["background_threads_runtime_support"] +alloc_trait = [] +profiling = ["tikv-jemalloc-sys/profiling"] +debug = ["tikv-jemalloc-sys/debug"] +stats = ["tikv-jemalloc-sys/stats"] +background_threads_runtime_support = ["tikv-jemalloc-sys/background_threads_runtime_support"] +background_threads = ["tikv-jemalloc-sys/background_threads"] +unprefixed_malloc_on_supported_platforms = ["tikv-jemalloc-sys/unprefixed_malloc_on_supported_platforms"] +disable_initial_exec_tls = ["tikv-jemalloc-sys/disable_initial_exec_tls"] + +[package.metadata.docs.rs] +features = [] +rustdoc-args = [ "--cfg", "jemallocator_docs" ] diff --git a/benches/roundtrip.rs b/jemallocator/benches/roundtrip.rs similarity index 100% rename from benches/roundtrip.rs rename to jemallocator/benches/roundtrip.rs diff --git a/src/lib.rs b/jemallocator/src/lib.rs similarity index 100% rename from src/lib.rs rename to jemallocator/src/lib.rs diff --git a/tests/background_thread_defaults.rs b/jemallocator/tests/background_thread_defaults.rs similarity index 100% rename from tests/background_thread_defaults.rs rename to jemallocator/tests/background_thread_defaults.rs diff --git a/tests/background_thread_enabled.rs b/jemallocator/tests/background_thread_enabled.rs similarity index 100% rename from tests/background_thread_enabled.rs rename to jemallocator/tests/background_thread_enabled.rs diff --git a/tests/ffi.rs b/jemallocator/tests/ffi.rs similarity index 100% rename from tests/ffi.rs rename to jemallocator/tests/ffi.rs diff --git a/tests/grow_in_place.rs b/jemallocator/tests/grow_in_place.rs similarity index 100% rename from tests/grow_in_place.rs rename to jemallocator/tests/grow_in_place.rs diff --git a/tests/malloctl.rs b/jemallocator/tests/malloctl.rs similarity index 100% rename from tests/malloctl.rs rename to jemallocator/tests/malloctl.rs diff --git a/tests/shrink_in_place.rs b/jemallocator/tests/shrink_in_place.rs similarity index 100% rename from tests/shrink_in_place.rs rename to jemallocator/tests/shrink_in_place.rs diff --git a/tests/smoke.rs b/jemallocator/tests/smoke.rs similarity index 100% rename from tests/smoke.rs rename to jemallocator/tests/smoke.rs diff --git a/tests/smoke_ffi.rs b/jemallocator/tests/smoke_ffi.rs similarity index 100% rename from tests/smoke_ffi.rs rename to jemallocator/tests/smoke_ffi.rs diff --git a/tests/usable_size.rs b/jemallocator/tests/usable_size.rs similarity index 100% rename from tests/usable_size.rs rename to jemallocator/tests/usable_size.rs diff --git a/systest/Cargo.toml b/systest/Cargo.toml deleted file mode 100644 index f5828ce51f..0000000000 --- a/systest/Cargo.toml +++ /dev/null @@ -1,13 +0,0 @@ -[package] -name = "systest" -version = "0.1.0" -authors = ["Alex Crichton "] -build = "build.rs" -edition = "2018" - -[dependencies] -tikv-jemalloc-sys = { path = "../jemalloc-sys" } -libc = "0.2" - -[build-dependencies] -ctest = "0.2.22" diff --git a/systest/build.rs b/systest/build.rs deleted file mode 100644 index 86c5d89e40..0000000000 --- a/systest/build.rs +++ /dev/null @@ -1,32 +0,0 @@ -use std::env; -use std::path::PathBuf; - -const FUNCTION_POINTER: &[&str] = &[ - "extent_alloc_t", - "extent_dalloc_t", - "extent_destroy_t", - "extent_commit_t", - "extent_decommit_t", - "extent_purge_t", - "extent_split_t", - "extent_merge_t", -]; - -fn main() { - let root = PathBuf::from(env::var_os("DEP_JEMALLOC_ROOT").unwrap()); - - let mut cfg = ctest::TestGenerator::new(); - cfg.header("jemalloc/jemalloc.h") - .include(root.join("include")) - .cfg("prefixed", None) - .fn_cname(|rust, link_name| link_name.unwrap_or(rust).to_string()) - .skip_signededness(|c| c.ends_with("_t")) - // No need to test pure C function pointer. - .skip_type(|name| FUNCTION_POINTER.contains(&name)); - - if cfg!(target_os = "linux") { - cfg.skip_fn(|f| f == "malloc_usable_size"); - } - - cfg.generate("../jemalloc-sys/src/lib.rs", "all.rs"); -} diff --git a/systest/src/main.rs b/systest/src/main.rs deleted file mode 100644 index 2f35191c14..0000000000 --- a/systest/src/main.rs +++ /dev/null @@ -1,13 +0,0 @@ -// TODO: remove systest -#![allow(bad_style, improper_ctypes, dead_code, unused_imports, deref_nullptr)] -#![allow(clippy::all)] - -use std::alloc::System; - -#[global_allocator] -static A: System = System; - -use libc::{c_char, c_int, c_void}; -use tikv_jemalloc_sys::*; - -include!(concat!(env!("OUT_DIR"), "/all.rs"));