Apply clang-format for core/shared and product-mini files (#785)
Apply clang-format for core/shared and product-mini files
This commit is contained in:
@ -5,7 +5,6 @@
|
||||
|
||||
#include "platform_api_vmcore.h"
|
||||
|
||||
|
||||
void *
|
||||
os_malloc(unsigned size)
|
||||
{
|
||||
@ -20,6 +19,4 @@ os_realloc(void *ptr, unsigned size)
|
||||
|
||||
void
|
||||
os_free(void *ptr)
|
||||
{
|
||||
}
|
||||
|
||||
{}
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
#include "platform_api_vmcore.h"
|
||||
#include "platform_api_extension.h"
|
||||
|
||||
/* clang-format off */
|
||||
#define bh_assert(v) do { \
|
||||
if (!(v)) { \
|
||||
int _count = 1; \
|
||||
@ -15,7 +16,8 @@
|
||||
os_printf("%d\n", _count / (_count - 1)); \
|
||||
while (1); \
|
||||
} \
|
||||
} while (0)
|
||||
} while (0)
|
||||
/* clang-format on */
|
||||
|
||||
struct os_thread_data;
|
||||
typedef struct os_thread_wait_node {
|
||||
@ -56,7 +58,8 @@ static os_thread_data supervisor_thread_data;
|
||||
/* Thread name index */
|
||||
static int thread_name_index;
|
||||
|
||||
static void thread_data_list_add(os_thread_data *thread_data)
|
||||
static void
|
||||
thread_data_list_add(os_thread_data *thread_data)
|
||||
{
|
||||
xSemaphoreTake(thread_data_lock, portMAX_DELAY);
|
||||
if (!thread_data_list)
|
||||
@ -79,7 +82,8 @@ static void thread_data_list_add(os_thread_data *thread_data)
|
||||
xSemaphoreGive(thread_data_lock);
|
||||
}
|
||||
|
||||
static void thread_data_list_remove(os_thread_data *thread_data)
|
||||
static void
|
||||
thread_data_list_remove(os_thread_data *thread_data)
|
||||
{
|
||||
xSemaphoreTake(thread_data_lock, portMAX_DELAY);
|
||||
if (thread_data_list) {
|
||||
@ -204,15 +208,17 @@ os_thread_wrapper(void *arg)
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
|
||||
int os_thread_create(korp_tid *p_tid, thread_start_routine_t start, void *arg,
|
||||
unsigned int stack_size)
|
||||
int
|
||||
os_thread_create(korp_tid *p_tid, thread_start_routine_t start, void *arg,
|
||||
unsigned int stack_size)
|
||||
{
|
||||
return os_thread_create_with_prio(p_tid, start, arg, stack_size,
|
||||
BH_THREAD_DEFAULT_PRIORITY);
|
||||
}
|
||||
|
||||
int os_thread_create_with_prio(korp_tid *p_tid, thread_start_routine_t start,
|
||||
void *arg, unsigned int stack_size, int prio)
|
||||
int
|
||||
os_thread_create_with_prio(korp_tid *p_tid, thread_start_routine_t start,
|
||||
void *arg, unsigned int stack_size, int prio)
|
||||
{
|
||||
os_thread_data *thread_data;
|
||||
char thread_name[32];
|
||||
@ -235,13 +241,13 @@ int os_thread_create_with_prio(korp_tid *p_tid, thread_start_routine_t start,
|
||||
if (!(thread_data->wait_list_lock = xSemaphoreCreateMutex()))
|
||||
goto fail2;
|
||||
|
||||
snprintf(thread_name, sizeof(thread_name), "%s%d",
|
||||
"wasm-thread-", ++thread_name_index);
|
||||
snprintf(thread_name, sizeof(thread_name), "%s%d", "wasm-thread-",
|
||||
++thread_name_index);
|
||||
|
||||
/* Create the thread */
|
||||
if (pdPASS != xTaskCreate(os_thread_wrapper, thread_name,
|
||||
stack_size / 4, thread_data,
|
||||
prio, &thread_data->handle))
|
||||
if (pdPASS
|
||||
!= xTaskCreate(os_thread_wrapper, thread_name, stack_size / 4,
|
||||
thread_data, prio, &thread_data->handle))
|
||||
goto fail3;
|
||||
|
||||
thread_data_list_add(thread_data);
|
||||
@ -257,12 +263,14 @@ fail1:
|
||||
return BHT_ERROR;
|
||||
}
|
||||
|
||||
korp_tid os_self_thread()
|
||||
korp_tid
|
||||
os_self_thread()
|
||||
{
|
||||
return xTaskGetCurrentTaskHandle();
|
||||
}
|
||||
|
||||
int os_thread_join(korp_tid thread, void **value_ptr)
|
||||
int
|
||||
os_thread_join(korp_tid thread, void **value_ptr)
|
||||
{
|
||||
os_thread_data *thread_data, *curr_thread_data;
|
||||
TaskHandle_t handle = thread;
|
||||
@ -293,7 +301,8 @@ int os_thread_join(korp_tid thread, void **value_ptr)
|
||||
return BHT_OK;
|
||||
}
|
||||
|
||||
int os_mutex_init(korp_mutex *mutex)
|
||||
int
|
||||
os_mutex_init(korp_mutex *mutex)
|
||||
{
|
||||
SemaphoreHandle_t semaphore;
|
||||
|
||||
@ -304,7 +313,8 @@ int os_mutex_init(korp_mutex *mutex)
|
||||
return BHT_OK;
|
||||
}
|
||||
|
||||
int os_recursive_mutex_init(korp_mutex *mutex)
|
||||
int
|
||||
os_recursive_mutex_init(korp_mutex *mutex)
|
||||
{
|
||||
SemaphoreHandle_t semaphore;
|
||||
|
||||
@ -315,13 +325,15 @@ int os_recursive_mutex_init(korp_mutex *mutex)
|
||||
return BHT_OK;
|
||||
}
|
||||
|
||||
int os_mutex_destroy(korp_mutex *mutex)
|
||||
int
|
||||
os_mutex_destroy(korp_mutex *mutex)
|
||||
{
|
||||
vSemaphoreDelete(mutex->sem);
|
||||
return BHT_OK;
|
||||
}
|
||||
|
||||
int os_mutex_lock(korp_mutex *mutex)
|
||||
int
|
||||
os_mutex_lock(korp_mutex *mutex)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
@ -332,7 +344,8 @@ int os_mutex_lock(korp_mutex *mutex)
|
||||
return ret == pdPASS ? BHT_OK : BHT_ERROR;
|
||||
}
|
||||
|
||||
int os_mutex_unlock(korp_mutex *mutex)
|
||||
int
|
||||
os_mutex_unlock(korp_mutex *mutex)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
@ -343,7 +356,8 @@ int os_mutex_unlock(korp_mutex *mutex)
|
||||
return ret == pdPASS ? BHT_OK : BHT_ERROR;
|
||||
}
|
||||
|
||||
int os_cond_init(korp_cond *cond)
|
||||
int
|
||||
os_cond_init(korp_cond *cond)
|
||||
{
|
||||
if (!(cond->wait_list_lock = xSemaphoreCreateMutex()))
|
||||
return BHT_ERROR;
|
||||
@ -352,15 +366,15 @@ int os_cond_init(korp_cond *cond)
|
||||
return BHT_OK;
|
||||
}
|
||||
|
||||
int os_cond_destroy(korp_cond *cond)
|
||||
int
|
||||
os_cond_destroy(korp_cond *cond)
|
||||
{
|
||||
vSemaphoreDelete(cond->wait_list_lock);
|
||||
return BHT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
os_cond_wait_internal(korp_cond *cond, korp_mutex *mutex,
|
||||
bool timed, int mills)
|
||||
os_cond_wait_internal(korp_cond *cond, korp_mutex *mutex, bool timed, int mills)
|
||||
{
|
||||
os_thread_wait_node *node = &thread_data_current()->wait_node;
|
||||
|
||||
@ -399,12 +413,14 @@ os_cond_wait_internal(korp_cond *cond, korp_mutex *mutex,
|
||||
return BHT_OK;
|
||||
}
|
||||
|
||||
int os_cond_wait(korp_cond *cond, korp_mutex *mutex)
|
||||
int
|
||||
os_cond_wait(korp_cond *cond, korp_mutex *mutex)
|
||||
{
|
||||
return os_cond_wait_internal(cond, mutex, false, 0);
|
||||
}
|
||||
|
||||
int os_cond_reltimedwait(korp_cond *cond, korp_mutex *mutex, uint64 useconds)
|
||||
int
|
||||
os_cond_reltimedwait(korp_cond *cond, korp_mutex *mutex, uint64 useconds)
|
||||
{
|
||||
if (useconds == BHT_WAIT_FOREVER) {
|
||||
return os_cond_wait_internal(cond, mutex, false, 0);
|
||||
@ -425,7 +441,8 @@ int os_cond_reltimedwait(korp_cond *cond, korp_mutex *mutex, uint64 useconds)
|
||||
}
|
||||
}
|
||||
|
||||
int os_cond_signal(korp_cond *cond)
|
||||
int
|
||||
os_cond_signal(korp_cond *cond)
|
||||
{
|
||||
/* Signal the head wait node of wait list */
|
||||
xSemaphoreTake(cond->wait_list_lock, portMAX_DELAY);
|
||||
@ -435,4 +452,3 @@ int os_cond_signal(korp_cond *cond)
|
||||
|
||||
return BHT_OK;
|
||||
}
|
||||
|
||||
|
||||
@ -11,4 +11,3 @@ os_time_get_boot_microsecond()
|
||||
TickType_t ticks = xTaskGetTickCount();
|
||||
return (uint64)1000 * 1000 / configTICK_RATE_HZ * ticks;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -22,6 +22,3 @@ os_free(void *ptr)
|
||||
{
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -50,21 +50,19 @@ os_mmap(void *hint, size_t size, int prot, int flags)
|
||||
* (mmap's first argument) to meet the requirement.
|
||||
*/
|
||||
if (!hint && !(flags & MMAP_MAP_FIXED) && (flags & MMAP_MAP_32BIT)) {
|
||||
uint8 *stack_addr = (uint8*)&map_prot;
|
||||
uint8 *text_addr = (uint8*)os_mmap;
|
||||
uint8 *stack_addr = (uint8 *)&map_prot;
|
||||
uint8 *text_addr = (uint8 *)os_mmap;
|
||||
/* hint address begins with 1MB */
|
||||
static uint8 *hint_addr = (uint8 *)(uintptr_t)BH_MB;
|
||||
|
||||
if ((hint_addr - text_addr >= 0
|
||||
&& hint_addr - text_addr < 100 * BH_MB)
|
||||
if ((hint_addr - text_addr >= 0 && hint_addr - text_addr < 100 * BH_MB)
|
||||
|| (text_addr - hint_addr >= 0
|
||||
&& text_addr - hint_addr < 100 * BH_MB)) {
|
||||
/* hint address is possibly in text section, skip it */
|
||||
hint_addr += 100 * BH_MB;
|
||||
}
|
||||
|
||||
if ((hint_addr - stack_addr >= 0
|
||||
&& hint_addr - stack_addr < 8 * BH_MB)
|
||||
if ((hint_addr - stack_addr >= 0 && hint_addr - stack_addr < 8 * BH_MB)
|
||||
|| (stack_addr - hint_addr >= 0
|
||||
&& stack_addr - hint_addr < 8 * BH_MB)) {
|
||||
/* hint address is possibly in native stack area, skip it */
|
||||
@ -72,8 +70,7 @@ os_mmap(void *hint, size_t size, int prot, int flags)
|
||||
}
|
||||
|
||||
/* try 10 times, step with 1MB each time */
|
||||
for (i = 0;
|
||||
i < 10 && hint_addr < (uint8 *)(uintptr_t)(2ULL * BH_GB);
|
||||
for (i = 0; i < 10 && hint_addr < (uint8 *)(uintptr_t)(2ULL * BH_GB);
|
||||
i++) {
|
||||
addr = mmap(hint_addr, request_size, map_prot, map_flags, -1, 0);
|
||||
if (addr != MAP_FAILED) {
|
||||
@ -114,7 +111,7 @@ os_munmap(void *addr, size_t size)
|
||||
|
||||
if (addr) {
|
||||
if (munmap(addr, request_size)) {
|
||||
os_printf("os_munmap error addr:%p, size:0x%"PRIx64", errno:%d\n",
|
||||
os_printf("os_munmap error addr:%p, size:0x%" PRIx64 ", errno:%d\n",
|
||||
addr, request_size, errno);
|
||||
}
|
||||
}
|
||||
@ -144,5 +141,4 @@ os_mprotect(void *addr, size_t size, int prot)
|
||||
|
||||
void
|
||||
os_dcache_flush(void)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
@ -22,7 +22,8 @@ typedef struct {
|
||||
static os_thread_local_attribute os_signal_handler signal_handler;
|
||||
#endif
|
||||
|
||||
static void *os_thread_wrapper(void *arg)
|
||||
static void *
|
||||
os_thread_wrapper(void *arg)
|
||||
{
|
||||
thread_wrapper_arg *targ = arg;
|
||||
thread_start_routine_t start_func = targ->start;
|
||||
@ -44,8 +45,9 @@ static void *os_thread_wrapper(void *arg)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int os_thread_create_with_prio(korp_tid *tid, thread_start_routine_t start,
|
||||
void *arg, unsigned int stack_size, int prio)
|
||||
int
|
||||
os_thread_create_with_prio(korp_tid *tid, thread_start_routine_t start,
|
||||
void *arg, unsigned int stack_size, int prio)
|
||||
{
|
||||
pthread_attr_t tattr;
|
||||
thread_wrapper_arg *targ;
|
||||
@ -63,7 +65,7 @@ int os_thread_create_with_prio(korp_tid *tid, thread_start_routine_t start,
|
||||
return BHT_ERROR;
|
||||
}
|
||||
|
||||
targ = (thread_wrapper_arg*) BH_MALLOC(sizeof(*targ));
|
||||
targ = (thread_wrapper_arg *)BH_MALLOC(sizeof(*targ));
|
||||
if (!targ) {
|
||||
pthread_attr_destroy(&tattr);
|
||||
return BHT_ERROR;
|
||||
@ -85,24 +87,28 @@ int os_thread_create_with_prio(korp_tid *tid, thread_start_routine_t start,
|
||||
return BHT_OK;
|
||||
}
|
||||
|
||||
int os_thread_create(korp_tid *tid, thread_start_routine_t start, void *arg,
|
||||
unsigned int stack_size)
|
||||
int
|
||||
os_thread_create(korp_tid *tid, thread_start_routine_t start, void *arg,
|
||||
unsigned int stack_size)
|
||||
{
|
||||
return os_thread_create_with_prio(tid, start, arg, stack_size,
|
||||
BH_THREAD_DEFAULT_PRIORITY);
|
||||
}
|
||||
|
||||
korp_tid os_self_thread()
|
||||
korp_tid
|
||||
os_self_thread()
|
||||
{
|
||||
return (korp_tid) pthread_self();
|
||||
return (korp_tid)pthread_self();
|
||||
}
|
||||
|
||||
int os_mutex_init(korp_mutex *mutex)
|
||||
int
|
||||
os_mutex_init(korp_mutex *mutex)
|
||||
{
|
||||
return pthread_mutex_init(mutex, NULL) == 0 ? BHT_OK : BHT_ERROR;
|
||||
}
|
||||
|
||||
int os_recursive_mutex_init(korp_mutex *mutex)
|
||||
int
|
||||
os_recursive_mutex_init(korp_mutex *mutex)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@ -120,7 +126,8 @@ int os_recursive_mutex_init(korp_mutex *mutex)
|
||||
return ret == 0 ? BHT_OK : BHT_ERROR;
|
||||
}
|
||||
|
||||
int os_mutex_destroy(korp_mutex *mutex)
|
||||
int
|
||||
os_mutex_destroy(korp_mutex *mutex)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@ -130,7 +137,8 @@ int os_mutex_destroy(korp_mutex *mutex)
|
||||
return ret == 0 ? BHT_OK : BHT_ERROR;
|
||||
}
|
||||
|
||||
int os_mutex_lock(korp_mutex *mutex)
|
||||
int
|
||||
os_mutex_lock(korp_mutex *mutex)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@ -140,7 +148,8 @@ int os_mutex_lock(korp_mutex *mutex)
|
||||
return ret == 0 ? BHT_OK : BHT_ERROR;
|
||||
}
|
||||
|
||||
int os_mutex_unlock(korp_mutex *mutex)
|
||||
int
|
||||
os_mutex_unlock(korp_mutex *mutex)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@ -150,7 +159,8 @@ int os_mutex_unlock(korp_mutex *mutex)
|
||||
return ret == 0 ? BHT_OK : BHT_ERROR;
|
||||
}
|
||||
|
||||
int os_cond_init(korp_cond *cond)
|
||||
int
|
||||
os_cond_init(korp_cond *cond)
|
||||
{
|
||||
assert(cond);
|
||||
|
||||
@ -160,7 +170,8 @@ int os_cond_init(korp_cond *cond)
|
||||
return BHT_OK;
|
||||
}
|
||||
|
||||
int os_cond_destroy(korp_cond *cond)
|
||||
int
|
||||
os_cond_destroy(korp_cond *cond)
|
||||
{
|
||||
assert(cond);
|
||||
|
||||
@ -170,7 +181,8 @@ int os_cond_destroy(korp_cond *cond)
|
||||
return BHT_OK;
|
||||
}
|
||||
|
||||
int os_cond_wait(korp_cond *cond, korp_mutex *mutex)
|
||||
int
|
||||
os_cond_wait(korp_cond *cond, korp_mutex *mutex)
|
||||
{
|
||||
assert(cond);
|
||||
assert(mutex);
|
||||
@ -181,7 +193,8 @@ int os_cond_wait(korp_cond *cond, korp_mutex *mutex)
|
||||
return BHT_OK;
|
||||
}
|
||||
|
||||
static void msec_nsec_to_abstime(struct timespec *ts, uint64 usec)
|
||||
static void
|
||||
msec_nsec_to_abstime(struct timespec *ts, uint64 usec)
|
||||
{
|
||||
struct timeval tv;
|
||||
time_t tv_sec_new;
|
||||
@ -201,8 +214,7 @@ static void msec_nsec_to_abstime(struct timespec *ts, uint64 usec)
|
||||
}
|
||||
|
||||
tv_nsec_new = (long int)(tv.tv_usec * 1000 + (usec % 1000000) * 1000);
|
||||
if (tv.tv_usec * 1000 >= tv.tv_usec
|
||||
&& tv_nsec_new >= tv.tv_usec * 1000) {
|
||||
if (tv.tv_usec * 1000 >= tv.tv_usec && tv_nsec_new >= tv.tv_usec * 1000) {
|
||||
ts->tv_nsec = tv_nsec_new;
|
||||
}
|
||||
else {
|
||||
@ -218,7 +230,8 @@ static void msec_nsec_to_abstime(struct timespec *ts, uint64 usec)
|
||||
}
|
||||
}
|
||||
|
||||
int os_cond_reltimedwait(korp_cond *cond, korp_mutex *mutex, uint64 useconds)
|
||||
int
|
||||
os_cond_reltimedwait(korp_cond *cond, korp_mutex *mutex, uint64 useconds)
|
||||
{
|
||||
int ret;
|
||||
struct timespec abstime;
|
||||
@ -236,7 +249,8 @@ int os_cond_reltimedwait(korp_cond *cond, korp_mutex *mutex, uint64 useconds)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int os_cond_signal(korp_cond *cond)
|
||||
int
|
||||
os_cond_signal(korp_cond *cond)
|
||||
{
|
||||
assert(cond);
|
||||
|
||||
@ -246,17 +260,20 @@ int os_cond_signal(korp_cond *cond)
|
||||
return BHT_OK;
|
||||
}
|
||||
|
||||
int os_thread_join(korp_tid thread, void **value_ptr)
|
||||
int
|
||||
os_thread_join(korp_tid thread, void **value_ptr)
|
||||
{
|
||||
return pthread_join(thread, value_ptr);
|
||||
}
|
||||
|
||||
int os_thread_detach(korp_tid thread)
|
||||
int
|
||||
os_thread_detach(korp_tid thread)
|
||||
{
|
||||
return pthread_detach(thread);
|
||||
}
|
||||
|
||||
void os_thread_exit(void *retval)
|
||||
void
|
||||
os_thread_exit(void *retval)
|
||||
{
|
||||
#ifdef OS_ENABLE_HW_BOUND_CHECK
|
||||
os_thread_signal_destroy();
|
||||
@ -268,7 +285,8 @@ void os_thread_exit(void *retval)
|
||||
static os_thread_local_attribute uint8 *thread_stack_boundary = NULL;
|
||||
#endif
|
||||
|
||||
uint8 *os_thread_get_stack_boundary()
|
||||
uint8 *
|
||||
os_thread_get_stack_boundary()
|
||||
{
|
||||
pthread_t self;
|
||||
#ifdef __linux__
|
||||
@ -286,15 +304,15 @@ uint8 *os_thread_get_stack_boundary()
|
||||
|
||||
page_size = getpagesize();
|
||||
self = pthread_self();
|
||||
max_stack_size = (size_t)(APP_THREAD_STACK_SIZE_MAX + page_size - 1)
|
||||
& ~(page_size - 1);
|
||||
max_stack_size =
|
||||
(size_t)(APP_THREAD_STACK_SIZE_MAX + page_size - 1) & ~(page_size - 1);
|
||||
|
||||
if (max_stack_size < APP_THREAD_STACK_SIZE_DEFAULT)
|
||||
max_stack_size = APP_THREAD_STACK_SIZE_DEFAULT;
|
||||
|
||||
#ifdef __linux__
|
||||
if (pthread_getattr_np(self, &attr) == 0) {
|
||||
pthread_attr_getstack(&attr, (void**)&addr, &stack_size);
|
||||
pthread_attr_getstack(&attr, (void **)&addr, &stack_size);
|
||||
pthread_attr_getguardsize(&attr, &guard_size);
|
||||
pthread_attr_destroy(&attr);
|
||||
if (stack_size > max_stack_size)
|
||||
@ -306,7 +324,7 @@ uint8 *os_thread_get_stack_boundary()
|
||||
}
|
||||
(void)stack_size;
|
||||
#elif defined(__APPLE__) || defined(__NuttX__)
|
||||
if ((addr = (uint8*)pthread_get_stackaddr_np(self))) {
|
||||
if ((addr = (uint8 *)pthread_get_stackaddr_np(self))) {
|
||||
stack_size = pthread_get_stacksize_np(self);
|
||||
if (stack_size > max_stack_size)
|
||||
addr -= max_stack_size;
|
||||
@ -349,8 +367,7 @@ touch_pages(uint8 *stack_min_addr, uint32 page_size)
|
||||
{
|
||||
uint8 sum = 0;
|
||||
while (1) {
|
||||
volatile uint8 *touch_addr =
|
||||
(volatile uint8*)os_alloca(page_size / 2);
|
||||
volatile uint8 *touch_addr = (volatile uint8 *)os_alloca(page_size / 2);
|
||||
if (touch_addr < stack_min_addr + page_size) {
|
||||
sum += *(stack_min_addr + page_size - 1);
|
||||
break;
|
||||
@ -378,7 +395,8 @@ init_stack_guard_pages()
|
||||
(void)touch_pages(stack_min_addr, page_size);
|
||||
/* First time to call aot function, protect guard pages */
|
||||
if (os_mprotect(stack_min_addr, page_size * guard_page_count,
|
||||
MMAP_PROT_NONE) != 0) {
|
||||
MMAP_PROT_NONE)
|
||||
!= 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -413,8 +431,7 @@ signal_callback(int sig_num, siginfo_t *sig_info, void *sig_ucontext)
|
||||
|
||||
mask_signals(SIG_BLOCK);
|
||||
|
||||
if (signal_handler
|
||||
&& (sig_num == SIGSEGV || sig_num == SIGBUS)) {
|
||||
if (signal_handler && (sig_num == SIGSEGV || sig_num == SIGBUS)) {
|
||||
signal_handler(sig_addr);
|
||||
}
|
||||
|
||||
@ -427,8 +444,7 @@ signal_callback(int sig_num, siginfo_t *sig_info, void *sig_ucontext)
|
||||
os_printf("unhandled SIGBUS, si_addr: %p\n", sig_addr);
|
||||
break;
|
||||
default:
|
||||
os_printf("unhandle signal %d, si_addr: %p\n",
|
||||
sig_num, sig_addr);
|
||||
os_printf("unhandle signal %d, si_addr: %p\n", sig_num, sig_addr);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -452,8 +468,7 @@ os_thread_signal_init(os_signal_handler handler)
|
||||
}
|
||||
|
||||
/* Initialize memory for signal alternate stack of current thread */
|
||||
if (!(map_addr = os_mmap(NULL, map_size,
|
||||
MMAP_PROT_READ | MMAP_PROT_WRITE,
|
||||
if (!(map_addr = os_mmap(NULL, map_size, MMAP_PROT_READ | MMAP_PROT_WRITE,
|
||||
MMAP_MAP_NONE))) {
|
||||
os_printf("Failed to mmap memory for alternate stack\n");
|
||||
goto fail1;
|
||||
@ -533,7 +548,7 @@ void
|
||||
os_sigreturn()
|
||||
{
|
||||
#if defined(__APPLE__)
|
||||
#define UC_RESET_ALT_STACK 0x80000000
|
||||
#define UC_RESET_ALT_STACK 0x80000000
|
||||
extern int __sigreturn(void *, int);
|
||||
|
||||
/* It's necessary to call __sigreturn to restore the sigaltstack state
|
||||
@ -542,4 +557,3 @@ os_sigreturn()
|
||||
#endif
|
||||
}
|
||||
#endif /* end of OS_ENABLE_HW_BOUND_CHECK */
|
||||
|
||||
|
||||
@ -13,6 +13,5 @@ os_time_get_boot_microsecond()
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ((uint64) ts.tv_sec) * 1000 * 1000 + ((uint64)ts.tv_nsec) / 1000;
|
||||
return ((uint64)ts.tv_sec) * 1000 * 1000 + ((uint64)ts.tv_nsec) / 1000;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user