Fix disable-threads builds

This commit is contained in:
pancake 2022-02-06 20:55:06 +01:00 committed by GitHub
parent fa834609cd
commit 1c8966bd1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 3 deletions

View File

@ -490,6 +490,9 @@ R_API void r_cons_break_end(void) {
}
R_API void *r_cons_sleep_begin(void) {
if (!r_cons_instance) {
r_cons_thready ();
}
if (!I->cb_sleep_begin) {
return NULL;
}
@ -497,6 +500,9 @@ R_API void *r_cons_sleep_begin(void) {
}
R_API void r_cons_sleep_end(void *user) {
if (!r_cons_instance) {
r_cons_thready ();
}
if (I->cb_sleep_end) {
I->cb_sleep_end (I->user, user);
}
@ -2235,6 +2241,9 @@ R_API void r_cons_clear_buffer(void) {
R_API void r_cons_thready(void) {
r_th_lock_enter (&r_cons_lock);
if (!r_cons_instance) {
r_cons_new ();
}
C->unbreakable = true;
r_th_lock_leave (&r_cons_lock);
}

View File

@ -13,6 +13,9 @@ static int backup_fdn = 1;
#endif
static bool __dupDescriptor(int fd, int fdn) {
if (fd == fdn) {
return false;
}
#if __wasi__
return false;
#elif __WINDOWS__

View File

@ -511,6 +511,7 @@ R_API void r_core_task_enqueue_oneshot(RCoreTaskScheduler *scheduler, RCoreTaskO
}
R_API int r_core_task_run_sync(RCoreTaskScheduler *scheduler, RCoreTask *task) {
r_return_val_if_fail (scheduler && task, -1);
task->thread = NULL;
return task_run (task);
}
@ -518,6 +519,9 @@ R_API int r_core_task_run_sync(RCoreTaskScheduler *scheduler, RCoreTask *task) {
/* begin running stuff synchronously on the main task */
R_API void r_core_task_sync_begin(RCoreTaskScheduler *scheduler) {
RCoreTask *task = scheduler->main_task;
if (!task) {
return;
}
TASK_SIGSET_T old_sigset;
tasks_lock_enter (scheduler, &old_sigset);
task->thread = NULL;
@ -530,16 +534,19 @@ R_API void r_core_task_sync_begin(RCoreTaskScheduler *scheduler) {
/* end running stuff synchronously, initially started with r_core_task_sync_begin() */
R_API void r_core_task_sync_end(RCoreTaskScheduler *scheduler) {
r_return_if_fail (scheduler);
task_end (scheduler->main_task);
}
/* To be called from within a task.
* Begin sleeping and schedule other tasks until r_core_task_sleep_end() is called. */
R_API void r_core_task_sleep_begin(RCoreTask *task) {
r_return_if_fail (task);
r_core_task_schedule (task, R_CORE_TASK_STATE_SLEEPING);
}
R_API void r_core_task_sleep_end(RCoreTask *task) {
r_return_if_fail (task);
task_wakeup (task);
}

View File

@ -137,7 +137,7 @@ R_API bool r_th_getname(RThread *th, char *name, size_t len) {
}
R_API bool r_th_setaffinity(RThread *th, int cpuid) {
#if defined(__wasi__) || defined(_WASI_EMULATED_SIGNAL)
#if !WANT_THREADS || defined(__wasi__) || defined(_WASI_EMULATED_SIGNAL)
return true;
#elif __linux__
#if defined(__GLIBC__) && defined (__GLIBC_MINOR__) && (__GLIBC__ <= 2) && (__GLIBC_MINOR__ <= 2)

View File

@ -2,8 +2,8 @@
# SANITIZE="address leak memory undefined"
# SANITIZE="address signed-integer-overflow" # Faster build
# default:
SANITIZE=${SANITIZE:="address undefined signed-integer-overflow"}
# SANITIZE=${SANITIZE:="thread undefined signed-integer-overflow"}
# SANITIZE=${SANITIZE:="address undefined signed-integer-overflow"}
SANITIZE=${SANITIZE:="thread"}
printf "\033[32m"
echo "========================================================================="