merge some OSX related fixes from ecelerity
This commit is contained in:
parent
07d8e36190
commit
724af76462
5 changed files with 28 additions and 8 deletions
2
misc.h
2
misc.h
|
@ -75,7 +75,7 @@ void log_message(const char *format, ...);
|
|||
* returns the index of the (high/low) bit + 1
|
||||
*/
|
||||
int highbit(ulong_t) __attribute__ ((pure));
|
||||
int lowbit(ulong_t) __attribute__ ((pure));;
|
||||
int lowbit(ulong_t) __attribute__ ((pure));
|
||||
/* #pragma no_side_effect(highbit, lowbit) */
|
||||
|
||||
/*
|
||||
|
|
15
umem.c
15
umem.c
|
@ -480,21 +480,21 @@ size_t umem_minfirewall; /* hardware-enforced redzone threshold */
|
|||
|
||||
uint_t umem_flags = 0;
|
||||
|
||||
mutex_t umem_init_lock; /* locks initialization */
|
||||
mutex_t umem_init_lock = DEFAULTMUTEX; /* locks initialization */
|
||||
cond_t umem_init_cv = DEFAULTCV; /* initialization CV */
|
||||
thread_t umem_init_thr; /* thread initializing */
|
||||
int umem_init_env_ready; /* environ pre-initted */
|
||||
int umem_ready = UMEM_READY_STARTUP;
|
||||
|
||||
static umem_nofail_callback_t *nofail_callback;
|
||||
static mutex_t umem_nofail_exit_lock;
|
||||
static mutex_t umem_nofail_exit_lock = DEFAULTMUTEX;
|
||||
static thread_t umem_nofail_exit_thr;
|
||||
|
||||
static umem_cache_t *umem_slab_cache;
|
||||
static umem_cache_t *umem_bufctl_cache;
|
||||
static umem_cache_t *umem_bufctl_audit_cache;
|
||||
|
||||
mutex_t umem_flags_lock;
|
||||
mutex_t umem_flags_lock = DEFAULTMUTEX;
|
||||
|
||||
static vmem_t *heap_arena;
|
||||
static vmem_alloc_t *heap_alloc;
|
||||
|
@ -518,9 +518,14 @@ umem_log_header_t *umem_failure_log;
|
|||
umem_log_header_t *umem_slab_log;
|
||||
|
||||
extern thread_t _thr_self(void);
|
||||
#if defined(__MACH__)
|
||||
# define CPUHINT() ((int)(_thr_self()))
|
||||
#endif
|
||||
|
||||
#ifndef CPUHINT
|
||||
#define CPUHINT() (_thr_self())
|
||||
#endif
|
||||
|
||||
#define CPUHINT_MAX() INT_MAX
|
||||
|
||||
#define CPU(mask) (umem_cpus + (CPUHINT() & (mask)))
|
||||
|
@ -542,12 +547,12 @@ volatile thread_t umem_st_update_thr; /* only used when single-thd */
|
|||
thr_self() == umem_st_update_thr)
|
||||
#define IN_REAP() IN_UPDATE()
|
||||
|
||||
mutex_t umem_update_lock; /* cache_u{next,prev,flags} */
|
||||
mutex_t umem_update_lock = DEFAULTMUTEX; /* cache_u{next,prev,flags} */
|
||||
cond_t umem_update_cv = DEFAULTCV;
|
||||
|
||||
volatile hrtime_t umem_reap_next; /* min hrtime of next reap */
|
||||
|
||||
mutex_t umem_cache_lock; /* inter-cache linkage only */
|
||||
mutex_t umem_cache_lock = DEFAULTMUTEX; /* inter-cache linkage only */
|
||||
|
||||
#ifdef UMEM_STANDALONE
|
||||
umem_cache_t umem_null_cache;
|
||||
|
|
13
umem_fail.c
13
umem_fail.c
|
@ -41,7 +41,6 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#include "misc.h"
|
||||
/*#include "util.h"*/
|
||||
|
||||
static volatile int umem_exiting = 0;
|
||||
#define UMEM_EXIT_ABORT 1
|
||||
|
@ -83,9 +82,21 @@ umem_do_abort(void)
|
|||
}
|
||||
|
||||
for (;;) {
|
||||
#if defined(__FreeBSD__)
|
||||
sigset_t set;
|
||||
struct sigaction sa;
|
||||
|
||||
sa.sa_handler = SIG_DFL;
|
||||
(void) sigaction(SIGABRT, &sa, NULL);
|
||||
(void) sigemptyset (&set);
|
||||
(void) sigaddset (&set, SIGABRT);
|
||||
(void) sigprocmask (SIG_UNBLOCK, &set, NULL);
|
||||
(void) raise (SIGABRT);
|
||||
#else
|
||||
(void) signal(SIGABRT, SIG_DFL);
|
||||
(void) sigrelse(SIGABRT);
|
||||
(void) raise(SIGABRT);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
5
vmem.c
5
vmem.c
|
@ -212,7 +212,10 @@ static vmem_seg_t vmem_seg0[VMEM_SEG_INITIAL];
|
|||
static vmem_seg_t *vmem_segfree;
|
||||
static mutex_t vmem_list_lock = DEFAULTMUTEX;
|
||||
static mutex_t vmem_segfree_lock = DEFAULTMUTEX;
|
||||
static vmem_populate_lock_t vmem_nosleep_lock;
|
||||
static vmem_populate_lock_t vmem_nosleep_lock = {
|
||||
DEFAULTMUTEX,
|
||||
0
|
||||
};
|
||||
#define IN_POPULATE() (vmem_nosleep_lock.vmpl_thr == thr_self())
|
||||
static vmem_t *vmem_list;
|
||||
static vmem_t *vmem_internal_arena;
|
||||
|
|
|
@ -115,6 +115,7 @@ vmem_mmap_top_alloc(vmem_t *src, size_t size, int vmflags)
|
|||
*/
|
||||
#ifdef _WIN32
|
||||
buf = VirtualAlloc(NULL, size, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE);
|
||||
if (buf == NULL) buf = MAP_FAILED;
|
||||
#else
|
||||
buf = mmap(
|
||||
#ifdef MAP_ALIGN
|
||||
|
|
Loading…
Reference in a new issue