summaryrefslogtreecommitdiffstats
path: root/signal.h
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-10-27 06:45:56 -0700
committerKaz Kylheku <kaz@kylheku.com>2015-10-27 06:45:56 -0700
commit0faa7cf4c73cc7c95488ed3055dd3c693dd341bc (patch)
treeb640255b695ead0854653f68add9a16d1506566a /signal.h
parent9d02ab722536227d488a31f5d580bc41501a7f68 (diff)
downloadtxr-0faa7cf4c73cc7c95488ed3055dd3c693dd341bc.tar.gz
txr-0faa7cf4c73cc7c95488ed3055dd3c693dd341bc.tar.bz2
txr-0faa7cf4c73cc7c95488ed3055dd3c693dd341bc.zip
Reduce size of saved/restored signal masks.
On glibc, sigset_t has a ridiculous size: one kilobyte! The kernel doesn't access most of it in the sigprocmask call. Yet it blows up the size of our dynamic frames quite a lot. In this commit, we define a small_sigset_t type and use that instead. We convert to the bloated one when calling the library. * signal.c (sig_blocked_cache): Type changes to small_sigset_t. (sig_reload_cache): Retrieve signal mask with sigprocmask into a local variable, then copy a small portion from that to sig_blocked_cache. (small_sigfillset): New static function. (set_sig_handler): Local variables of sigset_t changed to small_sigset_t. (sig_mask): Arguments are pointers to small_sigset_t. Conversion to sigset_t done around the call to sigprocmask. * signal.h (copy_sigset): Inline funtion removed. (small_sigset_t): New struct type. (extended_jmp_buf): Member blocked changed to small_sigset_t. (extended_setjmp): Cast expression updated with small_sigset_t *. (extended_longjmp): Use assignment instead of copy_sigset. (sig_blocked_cache, sig_mask): Declarations updated.
Diffstat (limited to 'signal.h')
-rw-r--r--signal.h22
1 files changed, 8 insertions, 14 deletions
diff --git a/signal.h b/signal.h
index dc5b44ba..b842256a 100644
--- a/signal.h
+++ b/signal.h
@@ -111,14 +111,9 @@ void jmp_restore(struct jmp *, int);
#if HAVE_POSIX_SIGS
-INLINE void copy_sigset(volatile sigset_t *dest, const sigset_t *src)
-{
-#ifdef __cplusplus
- *strip_qual(sigset_t *, dest) = *src;
-#else
- *dest = *src;
-#endif
-}
+typedef struct {
+ uint_ptr_t set;
+} small_sigset_t;
#define sig_save_enable \
do { \
@@ -159,7 +154,7 @@ INLINE val sig_check_fast(void)
typedef struct {
struct jmp jb;
volatile sig_atomic_t se;
- volatile sigset_t blocked;
+ volatile small_sigset_t blocked;
volatile val de;
volatile int gc;
val **volatile gc_pt;
@@ -174,7 +169,7 @@ typedef struct {
gc_enabled = (EJB).gc, \
gc_prot_top = (EJB).gc_pt, \
sig_mask(SIG_SETMASK, \
- strip_qual(sigset_t *, \
+ strip_qual(small_sigset_t *, \
&(EJB).blocked), 0), \
EJ_OPT_REST(EJB) \
(EJB).rv) \
@@ -182,15 +177,14 @@ typedef struct {
(EJB).de = dyn_env, \
(EJB).gc = gc_enabled, \
(EJB).gc_pt = gc_prot_top, \
- copy_sigset(&(EJB).blocked, \
- &sig_blocked_cache), \
+ (EJB).blocked.set = sig_blocked_cache.set,\
EJ_OPT_SAVE(EJB) \
0))
#define extended_longjmp(EJB, ARG) \
((EJB).rv = (ARG), jmp_restore(&(EJB).jb, 1))
-extern sigset_t sig_blocked_cache;
+extern small_sigset_t sig_blocked_cache;
extern volatile sig_atomic_t async_sig_enabled;
#else
@@ -238,7 +232,7 @@ void sig_init(void);
val set_sig_handler(val signo, val lambda);
val get_sig_handler(val signo);
#if HAVE_POSIX_SIGS
-int sig_mask(int how, const sigset_t *set, sigset_t *oldset);
+int sig_mask(int how, const small_sigset_t *set, small_sigset_t *oldset);
#endif
#if HAVE_ITIMER