diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2013-12-20 06:57:13 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2013-12-20 06:57:13 -0800 |
commit | 6e8aaedc1f3be2c9c7c3031499ad2b4bce05dfbc (patch) | |
tree | a972a7ce0467da3e666c4f841b9970971c5c211e /rand.h | |
parent | 0231fc1659ea0a75e058b38c3085d7631162f1b1 (diff) | |
download | txr-6e8aaedc1f3be2c9c7c3031499ad2b4bce05dfbc.tar.gz txr-6e8aaedc1f3be2c9c7c3031499ad2b4bce05dfbc.tar.bz2 txr-6e8aaedc1f3be2c9c7c3031499ad2b4bce05dfbc.zip |
Fixing a bug and performance issue.
Problem: we are using sigsetjmp but with a jmp_buf structure;
it requires sigjmp_buf!
Performance issue: sigsetjmp is a dog which makes system calls.
Solution: let's roll our own cached version of sigprocmask which
only calls the real sigprocmask when the mask changes. Then
our extended_setjmp will just use regular setjmp, plus our own
custom signal saving and restoring based on the cached version.
* signal.c (sig_blocked_cache): New variable.
(set_sig_handler): Use our sig_mask instead of sigprocmask.
(mem_set_bits, mem_clr_bits): New static functions.
(sig_mask): New function.
* signal.h (extended_jmp_buf): New member, blocked.
(extended_setjmp): save blocked signals by peeking into
sig_blocked_cache, and restore using sig_mask.
(sig_blocked_cache, sig_mask): Declared.
Diffstat (limited to 'rand.h')
0 files changed, 0 insertions, 0 deletions