[LibOS] Remove unnecessary SIGNAL_DELAYED flag

This flag was used in tcb.context.preempt.
This commit is contained in:
Dmitrii Kuvaiskii
2019-07-14 18:52:11 +02:00
committed by Michał Kowalczyk
parent 39a58957e2
commit 0dc1ecf511
4 changed files with 16 additions and 24 deletions
+9 -9
View File
@@ -173,7 +173,7 @@ static inline void do_pause (void);
do { debug("%s (" __FILE__ ":%d)\n", __func__, __LINE__); } while (0)
/* definition for syscall table */
void handle_signal (bool delayed_only);
void handle_signal (void);
long convert_pal_errno (long err);
void syscall_wrapper(void);
void syscall_wrapper_after_syscalldb(void);
@@ -210,13 +210,13 @@ static inline uint64_t get_cur_preempt (void) {
SHIM_ARG_TYPE __shim_##name(args) { \
SHIM_ARG_TYPE ret = 0; \
uint64_t preempt = get_cur_preempt(); \
/* handle_signal(true); */ \
/* handle_signal(); */ \
/* check_stack_hook(); */ \
BEGIN_SYSCALL_PROFILE();
#define END_SHIM(name) \
END_SYSCALL_PROFILE(name); \
handle_signal(false); \
handle_signal(); \
assert(preempt == get_cur_preempt()); \
return ret; \
}
@@ -470,10 +470,10 @@ static inline PAL_HANDLE thread_create (void * func, void * arg)
static inline void __disable_preempt (shim_tcb_t * tcb)
{
//tcb->context.syscall_nr += SYSCALL_NR_PREEMPT_INC;
/* Assert if this counter overflows */
assert((tcb->context.preempt & ~SIGNAL_DELAYED) != ~SIGNAL_DELAYED);
tcb->context.preempt++;
//debug("disable preempt: %d\n", tcb->context.preempt & ~SIGNAL_DELAYED);
/* Assert if this counter overflows */
assert(tcb->context.preempt != 0);
//debug("disable preempt: %d\n", tcb->context.preempt);
}
static inline void disable_preempt (shim_tcb_t * tcb)
@@ -490,7 +490,7 @@ static inline void __enable_preempt (shim_tcb_t * tcb)
/* Assert if this counter underflows */
assert(tcb->context.preempt > 0);
tcb->context.preempt--;
//debug("enable preempt: %d\n", tcb->context.preempt & ~SIGNAL_DELAYED);
//debug("enable preempt: %d\n", tcb->context.preempt);
}
void __handle_signal (shim_tcb_t * tcb, int sig);
@@ -500,10 +500,10 @@ static inline void enable_preempt (shim_tcb_t * tcb)
if (!tcb && !(tcb = shim_get_tls()))
return;
if (!(tcb->context.preempt & ~SIGNAL_DELAYED))
if (!tcb->context.preempt)
return;
if ((tcb->context.preempt & ~SIGNAL_DELAYED) == 1)
if (tcb->context.preempt == 1)
__handle_signal(tcb, 0);
__enable_preempt(tcb);
-2
View File
@@ -47,8 +47,6 @@ struct shim_context {
#include <shim_defs.h>
#define SIGNAL_DELAYED (0x80000000UL)
#endif /* IN_SHIM */
struct debug_buf;
+6 -12
View File
@@ -162,7 +162,7 @@ void deliver_signal (siginfo_t * info, PAL_CONTEXT * context)
__store_context(tcb, context, signal);
signal->pal_context = context;
if ((tcb->context.preempt & ~SIGNAL_DELAYED) > 1 ||
if (tcb->context.preempt > 1 ||
__sigismember(&cur_thread->signal_mask, sig)) {
struct shim_signal ** signal_log = NULL;
if ((signal = malloc_copy(signal,sizeof(struct shim_signal))) &&
@@ -551,11 +551,8 @@ static void resume_upcall (PAL_PTR event, PAL_NUM arg, PAL_CONTEXT * context)
if (!is_internal_tid(get_cur_tid())) {
__disable_preempt(tcb);
if ((tcb->context.preempt & ~SIGNAL_DELAYED) > 1) {
tcb->context.preempt |= SIGNAL_DELAYED;
} else {
if (tcb->context.preempt <= 1)
__handle_signal(tcb, 0);
}
__enable_preempt(tcb);
}
DkExceptionReturn(event);
@@ -695,11 +692,10 @@ void __handle_signal (shim_tcb_t * tcb, int sig)
__handle_one_signal(tcb, sig, signal);
free(signal);
DkThreadYieldExecution();
tcb->context.preempt &= ~SIGNAL_DELAYED;
}
}
void handle_signal (bool delayed_only)
void handle_signal (void)
{
shim_tcb_t * tcb = shim_get_tls();
assert(tcb);
@@ -712,12 +708,10 @@ void handle_signal (bool delayed_only)
__disable_preempt(tcb);
if ((tcb->context.preempt & ~SIGNAL_DELAYED) > 1) {
debug("signal delayed (%ld)\n", tcb->context.preempt & ~SIGNAL_DELAYED);
tcb->context.preempt |= SIGNAL_DELAYED;
} else if (!(delayed_only && !(tcb->context.preempt & SIGNAL_DELAYED))) {
if (tcb->context.preempt > 1)
debug("signal delayed (%ld)\n", tcb->context.preempt);
else
__handle_signal(tcb, 0);
}
__enable_preempt(tcb);
debug("__enable_preempt: %s:%d\n", __FILE__, __LINE__);
+1 -1
View File
@@ -82,7 +82,7 @@ void * __system_malloc (size_t size)
/* If the allocation is interrupted by signal, try to handle the
* signal and then retry the allocation. */
if (PAL_NATIVE_ERRNO == PAL_ERROR_INTERRUPTED) {
handle_signal(true);
handle_signal();
continue;
}