diff options
-rw-r--r-- | memory/mozjemalloc/jemalloc.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/memory/mozjemalloc/jemalloc.c b/memory/mozjemalloc/jemalloc.c index 0eb5241c7..e427ea60d 100644 --- a/memory/mozjemalloc/jemalloc.c +++ b/memory/mozjemalloc/jemalloc.c @@ -4735,7 +4735,7 @@ huge_dalloc(void *ptr) base_node_dealloc(node); } -/* +/* * Platform-specific methods to determine the number of CPUs in a system. * This will be used to determine the desired number of arenas. */ @@ -4841,7 +4841,7 @@ static inline unsigned malloc_ncpus(void) { SYSTEM_INFO info; - + GetSystemInfo(&info); return (info.dwNumberOfProcessors); } @@ -5015,6 +5015,7 @@ malloc_init_hard(void) malloc_mutex_lock(&init_lock); #endif +#ifndef __FreeBSD__ if (malloc_initialized) { /* * Another thread initialized the allocator before this one @@ -5025,6 +5026,11 @@ malloc_init_hard(void) #endif return (false); } +#else + if (__atomic_load_n(&malloc_initialized, __ATOMIC_ACQUIRE)) { + return (false); + } +#endif #ifdef MOZ_MEMORY_WINDOWS /* get a thread local storage index */ @@ -5450,7 +5456,11 @@ MALLOC_OUT: if (chunk_rtree == NULL) return (true); +#ifndef __FreeBSD__ malloc_initialized = true; +#else + __atomic_store_n(&malloc_initialized, true, __ATOMIC_RELEASE); +#endif #if !defined(MOZ_MEMORY_WINDOWS) && !defined(MOZ_MEMORY_DARWIN) /* Prevent potential deadlock on malloc locks after fork. */ |