Skip to content

Commit

Permalink
A bit of refactoring of the "fix Thread.sigmask" branch.
Browse files Browse the repository at this point in the history
* Rename back caml_signals_might_be_pending into caml_signals_are_pending,
  since this symbol is used in Coq.
* caml_process_pending_signals takes no parameter (i.e., it takes void)
  • Loading branch information
jhjourdan committed Dec 23, 2018
1 parent 2a9da17 commit fd23529
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions runtime/caml/signals.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ extern "C" {
#endif

#ifdef CAML_INTERNALS
CAMLextern intnat volatile caml_signals_might_be_pending;
CAMLextern intnat volatile caml_signals_are_pending;
CAMLextern intnat volatile caml_pending_signals[];
CAMLextern int volatile caml_something_to_do;
extern int volatile caml_requested_major_slice;
Expand All @@ -39,7 +39,7 @@ CAMLextern int caml_convert_signal_number (int);
CAMLextern int caml_rev_convert_signal_number (int);
void caml_execute_signal(int signal_number, int in_signal_handler);
void caml_record_signal(int signal_number);
void caml_process_pending_signals();
void caml_process_pending_signals(void);
void caml_process_event(void);
int caml_set_signal_action(int signo, int action);

Expand Down
18 changes: 9 additions & 9 deletions runtime/signals.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

/* The set of pending signals (received but not yet processed) */

CAMLexport intnat volatile caml_signals_might_be_pending = 0;
CAMLexport intnat volatile caml_signals_are_pending = 0;
CAMLexport intnat volatile caml_pending_signals[NSIG];

#ifdef POSIX_SIGNALS
Expand All @@ -63,15 +63,15 @@ CAMLexport void (*caml_get_sigmask_hook)(int*) = caml_get_sigmask_hook_default;

/* Execute all pending signals */

void caml_process_pending_signals()
void caml_process_pending_signals(void)
{
int i;
int blocked[NSIG];
int really_pending;

if(!caml_signals_might_be_pending)
if(!caml_signals_are_pending)
return;
caml_signals_might_be_pending = 0;
caml_signals_are_pending = 0;

/* Check that there is indeed a pending signal before issuing the
syscall in [caml_get_sigmask_hook]. */
Expand Down Expand Up @@ -102,7 +102,7 @@ void caml_process_pending_signals()
void caml_record_signal(int signal_number)
{
caml_pending_signals[signal_number] = 1;
caml_signals_might_be_pending = 1;
caml_signals_are_pending = 1;
#ifndef NATIVE_CODE
caml_something_to_do = 1;
#else
Expand Down Expand Up @@ -148,7 +148,7 @@ CAMLexport void caml_enter_blocking_section(void)
caml_enter_blocking_section_hook ();
/* Check again for pending signals.
If none, done; otherwise, try again */
if (! caml_signals_might_be_pending) break;
if (! caml_signals_are_pending) break;
caml_leave_blocking_section_hook ();
}
}
Expand All @@ -161,7 +161,7 @@ CAMLexport void caml_leave_blocking_section(void)
caml_leave_blocking_section_hook ();

/* Some other thread may have switched
[caml_signals_might_be_pending] to 0 even though there are still
[caml_signals_are_pending] to 0 even though there are still
pending signals (masked in the other thread). To handle this
case, we force re-examination of all signals by setting it back
to 1.
Expand All @@ -170,9 +170,9 @@ CAMLexport void caml_leave_blocking_section(void)
setting) is when the blocking section unmasks a pending signal:
If the signal is pending and masked but has already been
examinated by [caml_process_pending_signals], then
[caml_signals_might_be_pending] is 0 but the signal needs to be
[caml_signals_are_pending] is 0 but the signal needs to be
handled at this point. */
caml_signals_might_be_pending = 1;
caml_signals_are_pending = 1;
caml_process_pending_signals();

errno = saved_errno;
Expand Down

0 comments on commit fd23529

Please sign in to comment.