Skip to content

Commit

Permalink
inlined kissat_signal_name
Browse files Browse the repository at this point in the history
  • Loading branch information
arminbiere committed Jun 8, 2021
1 parent 8cf49a4 commit 00a3a33
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 26 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sc2021-sweep
2.0.0
20 changes: 0 additions & 20 deletions src/handle.c
Original file line number Diff line number Diff line change
@@ -1,40 +1,20 @@
#include "handle.h"

#include <assert.h>
#include <signal.h>
#include <stdbool.h>
#include <stdio.h>

static void (*handler) (int);
static volatile int caught_signal;
static volatile bool handler_set;

#define SIGNALS \
SIGNAL(SIGABRT) \
SIGNAL(SIGBUS) \
SIGNAL(SIGINT) \
SIGNAL(SIGSEGV) \
SIGNAL(SIGTERM)

// *INDENT-OFF*

#define SIGNAL(SIG) \
static void (*SIG ## _handler)(int);
SIGNALS
#undef SIGNAL

const char *
kissat_signal_name (int sig)
{
#define SIGNAL(SIG) \
if (sig == SIG) return #SIG;
SIGNALS
#undef SIGNAL
if (sig == SIGALRM)
return "SIGALRM";
return "SIGUNKNOWN";
}

void
kissat_reset_signal_handler (void)
{
Expand Down
25 changes: 24 additions & 1 deletion src/handle.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,35 @@
#ifndef _handle_h_INCLUDED
#define _handle_h_INCLUDED

#include <signal.h>

void kissat_init_signal_handler (void (*handler) (int));
void kissat_reset_signal_handler (void);

void kissat_init_alarm (void (*handler) (void));
void kissat_reset_alarm (void);

const char *kissat_signal_name (int sig);
#define SIGNALS \
SIGNAL(SIGABRT) \
SIGNAL(SIGBUS) \
SIGNAL(SIGINT) \
SIGNAL(SIGSEGV) \
SIGNAL(SIGTERM)

// *INDENT-OFF*

static inline const char *
kissat_signal_name (int sig)
{
#define SIGNAL(SIG) \
if (sig == SIG) return #SIG;
SIGNALS
#undef SIGNAL
if (sig == SIGALRM)
return "SIGALRM";
return "SIGUNKNOWN";
}

// *INDENT-ON*

#endif
8 changes: 4 additions & 4 deletions test/testmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,15 @@ execute_solver_and_send_signal (int sig)

#ifdef ASAN

#define SIGNALS \
#define TEST_SIGNALS \
SIGNAL(SIGABRT) \
SIGNAL(SIGALRM) \
SIGNAL(SIGINT) \
SIGNAL(SIGTERM)

#else

#define SIGNALS \
#define TEST_SIGNALS \
SIGNAL(SIGABRT) \
SIGNAL(SIGALRM) \
SIGNAL(SIGINT) \
Expand All @@ -159,7 +159,7 @@ test_main_ ## NAME (void) \
execute_solver_and_send_signal (NAME); \
}

SIGNALS
TEST_SIGNALS
#undef SIGNAL
#endif
void
Expand All @@ -170,7 +170,7 @@ tissat_schedule_main (void)
if (tissat_found_test_directory)
{
#define SIGNAL(NAME) SCHEDULE_FUNCTION (test_main_ ## NAME);
SIGNALS
TEST_SIGNALS
#undef SIGNAL
}
#endif
Expand Down

0 comments on commit 00a3a33

Please sign in to comment.