From fad8165231f833477c68f369f807240cd31b9c96 Mon Sep 17 00:00:00 2001 From: fys Date: Tue, 30 Apr 2024 17:27:13 +0800 Subject: [PATCH] fix: cr 1. Compile pthread_atfork.c when target contains "android". 2. Use original definition of "pthread_atfork". --- jemalloc-sys/build.rs | 13 +++++++++---- jemalloc-sys/src/pthread_atfork.c | 16 +++++++++------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/jemalloc-sys/build.rs b/jemalloc-sys/build.rs index 4f4f6f1e5..12daa04d4 100644 --- a/jemalloc-sys/build.rs +++ b/jemalloc-sys/build.rs @@ -339,10 +339,15 @@ fn main() { } println!("cargo:rerun-if-changed=jemalloc"); - cc::Build::new() - .file("src/pthread_atfork.c") - .compile("pthread_atfork"); - println!("cargo:rerun-if-changed=src/pthread_atfork.c"); + if target.contains("android") { + // These symbols are used by jemalloc on android but the really old android + // we're building on doesn't have them defined, so just make sure the symbols + // are available. + cc::Build::new() + .file("src/pthread_atfork.c") + .compile("pthread_atfork"); + println!("cargo:rerun-if-changed=src/pthread_atfork.c"); + } } fn run_and_log(cmd: &mut Command, log_file: &Path) { diff --git a/jemalloc-sys/src/pthread_atfork.c b/jemalloc-sys/src/pthread_atfork.c index df8d68b25..a075845c2 100644 --- a/jemalloc-sys/src/pthread_atfork.c +++ b/jemalloc-sys/src/pthread_atfork.c @@ -1,11 +1,13 @@ -#include +#include -// These symbols are used by jemalloc on android but the really old android -// we're building on doesn't have them defined, so just make sure the symbols -// are available. +/* + * These symbols are used by jemalloc on android but the really old android + * we're building on doesn't have them defined, so just make sure the symbols + * are available. + */ __attribute__((weak)) int -pthread_atfork(uint8_t *prefork __attribute__((unused)), - uint8_t *postfork_parent __attribute__((unused)), - uint8_t *postfork_child __attribute__((unused))) { +pthread_atfork(void (*prepare)(void) __attribute__((unused)), + void (*parent)(void) __attribute__((unused)), + void (*child)(void) __attribute__((unused))) { return 0; }