Skip to content

Commit

Permalink
fix: add conditional macro ifdef LINUX
Browse files Browse the repository at this point in the history
  • Loading branch information
onroadmuwl committed Dec 18, 2023
1 parent 8221e5b commit 0f05ee1
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 4 deletions.
2 changes: 2 additions & 0 deletions core/os_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,10 @@ is_thread_currently_native(thread_record_t *tr);
bool
thread_get_mcontext(thread_record_t *tr, priv_mcontext_t *mc);

#ifdef LINUX
bool
thread_get_nudged_mcontext(thread_record_t *tr, priv_mcontext_t *mc);
#endif

bool
thread_set_mcontext(thread_record_t *tr, priv_mcontext_t *mc);
Expand Down
6 changes: 2 additions & 4 deletions core/synch.c
Original file line number Diff line number Diff line change
Expand Up @@ -2289,7 +2289,7 @@ detach_on_permanent_stack(bool internal, bool do_cleanup, dr_stats_t *drstats)
EXITING_DR();
options_detach();
}

#ifdef LINUX
void
detach_externally_on_linux()
{
Expand Down Expand Up @@ -2382,9 +2382,6 @@ detach_externally_on_linux()
DEBUG_DECLARE(ok =)
translate_mcontext(threads[i], &my_mcontext, true /*restore mem*/,
NULL /*f*/);
ASSERT(!is_dynamo_address(my_mcontext.pc) && !in_fcache(my_mcontext.pc));
ASSERT(!in_fcache(my_mcontext.pc));
ASSERT(!is_dynamo_address(my_mcontext.pc));
continue;
} else if (IS_CLIENT_THREAD(threads[i]->dcontext)) {
/* i#297 we will kill client-owned threads later after app exit events
Expand Down Expand Up @@ -2489,3 +2486,4 @@ detach_externally_on_linux()
options_detach();
thread_set_self_mcontext(&my_mcontext);
}
#endif
2 changes: 2 additions & 0 deletions core/synch.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,10 @@ send_all_other_threads_native(void);
void
detach_on_permanent_stack(bool internal, bool do_cleanup, dr_stats_t *drstats);

#ifdef LINUX
void
detach_externally_on_linux();
#endif

/*** exported for detach only ***/

Expand Down
2 changes: 2 additions & 0 deletions core/unix/os.c
Original file line number Diff line number Diff line change
Expand Up @@ -3979,6 +3979,7 @@ thread_get_mcontext(thread_record_t *tr, priv_mcontext_t *mc)
return true;
}

#ifdef LINUX
bool
thread_get_nudged_mcontext(thread_record_t *tr, priv_mcontext_t *mc)
{
Expand All @@ -3993,6 +3994,7 @@ thread_get_nudged_mcontext(thread_record_t *tr, priv_mcontext_t *mc)
NULL));
return true;
}
#endif

bool
thread_set_mcontext(thread_record_t *tr, priv_mcontext_t *mc)
Expand Down
2 changes: 2 additions & 0 deletions core/unix/os_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,10 @@ typedef struct _os_thread_data_t {
KSYNCH_TYPE resumed;
sig_full_cxt_t *suspended_sigcxt;

#ifdef LINUX
/* For detachment on Linux*/
sig_full_cxt_t *nudged_sigcxt;
#endif

/* PR 297902: for thread termination */
bool terminate;
Expand Down
4 changes: 4 additions & 0 deletions core/unix/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -7920,9 +7920,11 @@ alarm_signal_has_DR_only_itimer(dcontext_t *dcontext, int signal)
int which = signal_to_itimer_type(signal);
if (which == -1)
return false;
#ifdef LINUX
if (dcontext == GLOBAL_DCONTEXT) {
return false;
}
#endif
thread_sig_info_t *info = (thread_sig_info_t *)dcontext->signal_field;
if (info->shared_itimer)
acquire_recursive_lock(&(*info->itimer)[which].lock);
Expand Down Expand Up @@ -8484,8 +8486,10 @@ handle_suspend_signal(dcontext_t *dcontext, kernel_siginfo_t *siginfo,
if (is_sigqueue_supported() && SUSPEND_SIGNAL == NUDGESIG_SIGNUM) {
nudge_arg_t *arg = (nudge_arg_t *)siginfo;
if (!TEST(NUDGE_IS_SUSPEND, arg->flags)) {
#ifdef LINUX
sig_full_initialize(&sc_full, ucxt);
ostd->nudged_sigcxt = &sc_full;
#endif
return handle_nudge_signal(dcontext, siginfo, ucxt);
}
}
Expand Down

0 comments on commit 0f05ee1

Please sign in to comment.