Skip to content

Commit a1a0167

Browse files
committed
fix: cr
1. Compile pthread_atfork.c when target contains "android". 2. Use original definition of "pthread_atfork". Signed-off-by: fys <fengys1996@gmail.com>
1 parent 5373acd commit a1a0167

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

jemalloc-sys/build.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -339,10 +339,15 @@ fn main() {
339339
}
340340
println!("cargo:rerun-if-changed=jemalloc");
341341

342-
cc::Build::new()
343-
.file("src/pthread_atfork.c")
344-
.compile("pthread_atfork");
345-
println!("cargo:rerun-if-changed=src/pthread_atfork.c");
342+
if target.contains("android") {
343+
// These symbols are used by jemalloc on android but the really old android
344+
// we're building on doesn't have them defined, so just make sure the symbols
345+
// are available.
346+
cc::Build::new()
347+
.file("src/pthread_atfork.c")
348+
.compile("pthread_atfork");
349+
println!("cargo:rerun-if-changed=src/pthread_atfork.c");
350+
}
346351
}
347352

348353
fn run_and_log(cmd: &mut Command, log_file: &Path) {

jemalloc-sys/src/pthread_atfork.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
#include <stdint.h>
1+
#include <pthread.h>
22

3-
// These symbols are used by jemalloc on android but the really old android
4-
// we're building on doesn't have them defined, so just make sure the symbols
5-
// are available.
3+
/*
4+
* These symbols are used by jemalloc on android but the really old android
5+
* we're building on doesn't have them defined, so just make sure the symbols
6+
* are available.
7+
*/
68
__attribute__((weak)) int
7-
pthread_atfork(uint8_t *prefork __attribute__((unused)),
8-
uint8_t *postfork_parent __attribute__((unused)),
9-
uint8_t *postfork_child __attribute__((unused))) {
9+
pthread_atfork(void (*prepare)(void) __attribute__((unused)),
10+
void (*parent)(void) __attribute__((unused)),
11+
void (*child)(void) __attribute__((unused))) {
1012
return 0;
1113
}

0 commit comments

Comments
 (0)