Skip to content

Commit e083d7d

Browse files
nortti0Juhani Krekelä
andauthored
Use malloc_usable_size() on FreeBSD (servo#707)
Per jemalloc(3), the non-POSIX APIs are declared in the header malloc_np.h Testing: With this change, I've successfully built mozjs-sys on FreeBSD. Without it, the build fails. Signed-off-by: Juhani Krekelä <juhani@krekelä.fi> Co-authored-by: Juhani Krekelä <juhani@krekelä.fi>
1 parent c499fec commit e083d7d

3 files changed

Lines changed: 6 additions & 4 deletions

File tree

mozjs-sys/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "mozjs_sys"
33
description = "System crate for the Mozilla SpiderMonkey JavaScript engine."
44
repository.workspace = true
5-
version = "0.140.7-1"
5+
version = "0.140.7-2"
66
authors = ["Mozilla", "The Servo Project Developers"]
77
links = "mozjs"
88
license.workspace = true

mozjs-sys/src/jsglue.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,8 @@ void DeleteRootedObjectVector(JS::PersistentRootedObjectVector* v) { delete v; }
934934

935935
#if defined(__linux__) || defined(__wasi__)
936936
# include <malloc.h>
937+
#elif defined(__FreeBSD__)
938+
# include <malloc_np.h>
937939
#elif defined(__APPLE__)
938940
# include <malloc/malloc.h>
939941
#elif defined(__MINGW32__) || defined(__MINGW64__)
@@ -946,7 +948,7 @@ void DeleteRootedObjectVector(JS::PersistentRootedObjectVector* v) { delete v; }
946948

947949
// SpiderMonkey-in-Rust currently uses system malloc, not jemalloc.
948950
static size_t MallocSizeOf(const void* aPtr) {
949-
#if defined(__linux__) || defined(__wasi__)
951+
#if defined(__linux__) || defined(__wasi__) || defined(__FreeBSD__)
950952
return malloc_usable_size((void*)aPtr);
951953
#elif defined(__APPLE__)
952954
return malloc_size((void*)aPtr);

mozjs/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "mozjs"
33
description = "Rust bindings to the Mozilla SpiderMonkey JavaScript engine."
44
repository.workspace = true
5-
version = "0.15.3"
5+
version = "0.15.4"
66
authors = ["The Servo Project Developers"]
77
license.workspace = true
88
edition.workspace = true
@@ -27,7 +27,7 @@ encoding_rs = "0.8.35"
2727
libc.workspace = true
2828
log = "0.4"
2929
# When doing non-version changes also update ../mozjs-sys/etc/sm-security-bump.py
30-
mozjs_sys = { version = "=0.140.7-1", path = "../mozjs-sys" }
30+
mozjs_sys = { version = "=0.140.7-2", path = "../mozjs-sys" }
3131
num-traits = "0.2"
3232

3333
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]

0 commit comments

Comments
 (0)