summaryrefslogtreecommitdiffstats
path: root/signal.h
Commit message (Collapse)AuthorAgeFilesLines
* Ligher weight debug instrumentation.Kaz Kylheku2015-05-221-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This speeds up the TXR Lisp interpreter, because do_eval sets up a debug frame and uses debug_return. * debug.c (debug_block_s): Symbol removed. (debug_init): Remove initialization of debug_block_s. * debug.h (debug_block_s): Declaration removed. (debug_enter): Do not establish a named block or a catch block; no time-wasting unwind stack manipulation at all. The debug_depth variable is managed by the extended setjmp context now. Provide a return value variable, and a well-defined name to branch to to exit from the debug block. (debug_return): Do not use heavy-weight uw_block_return; simply set the return variable and branch to debug_return_out label. * signal.h (EJ_DBG_MEMB, EJ_DBG_SAVE, EJ_DBG_REST, EJ_OPT_MEMB, EJ_OPT_SAVE, EJ_OPT_REST): New macros. (extended_jmp_buf): Define optional global state variables using EJ_OPT_MEMB. (extended_setjmp): Save and restore optional globals using EJ_OPT_SAVE and EJ_OPT_RESTORE. Now debug_depth is saved and restored if debugging support is compiled in. * match.c (open_data_source): Remove bogus debug_return invocations which were uncovered here by changes to the macro. * eval.c (do_eval, expand_macro): debug_return must now be after debug_end, because it won't dynamically clean up frames that it doesn't know about. The set_dyn_env is no longer unreachable in expand_macro; it is now necessary because debug_return isn't doing the longjmp that previously restored dyn_env.
* * signal.h (sig_save_disable): Bugfix: macro enablingKaz Kylheku2015-05-011-1/+1
| | | | rather than disabling async signals.
* Update copyright notices from 2014 to 2015.Kaz Kylheku2015-02-011-1/+1
| | | | | | | | | | | * arith.c, arith.h, combi.c, combi.h, debug.c, debug.h, eval.c, eval.h, filter.c, filter.h, gc.c, gc.h, hash.c, hash.h, lib.c, lib.h, match.c, match.h, parser.h, rand.c, rand.h, regex.c, regex.h, signal.c, signal.h, stream.c, stream.h, sysif.c, sysif.h, syslog.c, syslog.h, txr.c, txr.h, unwind.c, unwind.h, utf8.c, utf8.h: Update. * LICENSE, METALICENSE: Likewise.
* * signal.h (sig_save_enable, sig_save_disable):Kaz Kylheku2015-01-121-8/+6
| | | | | | | | Use do;while(0) trick instead of local typedef to cause terminating semicolon to be required. (sig_restore_enable, sig_restore_disable): Remove superfluous do { } while (0). Closing a brace is good enough.
* * Makefile: Removing trailing spaces.Kaz Kylheku2014-10-241-1/+1
| | | | | | | | | | (GREP_CHECK): New macro. (enforce): Rewritten using GREP_CHECK, with new checks. * arith.c, combi.c, debug.c, eval.c, filter.c, gc.c, hash.c, lib.c, * lib.h, match.c, parser.l, parser.y, rand.c, regex.c, signal.c, * signal.h, stream.c, syslog.c, txr.c, unwind.c, utf8.c: Remove trailing spaces.
* * gc.c (top): Renamed to gc_prot_top, turned extern.Kaz Kylheku2014-08-251-2/+9
| | | | | | | | | (prot1, rel1, mark): Follow rename. * gc.h (gc_prot_top): Declared. * signal.h (extended_jmp_buf): New member, gc_pt. (extended_setjmp): Save and restore gc_prot_top.
* * configure (have_sys_time): New variable.Kaz Kylheku2014-08-011-0/+5
| | | | | | | | | | | | | | Added check for setitimer/getitimer which also checks for <sys/time.h>. * signal.c (sig_init): Register itimer-real, itimer-virtual, itimer-prof variables and getitimer and setitimer functions. (tv_to_usec): New static function. (getitimer_wrap, setitimer_wrap): New functions. * signal.h (getitimer_wrap, setitimer_wrap): Declared. * txr.1: Documented itimers.
* * signal.c (set_sig_handler): Don't use SA_ONSTACKKaz Kylheku2014-08-011-1/+1
| | | | | | | | except for signals for which we use alt stack. * signal.h (sig_save_enable): Do sig_check before enabling async signals. This caused the !async_sig_enabled assertion to trip inside make_obj.
* * signal.c (sig_hup, sig_int, sig_quit, sig_ill, sig_trap, sig_abrt,Kaz Kylheku2014-08-011-7/+0
| | | | | | | | | | sig_bus, sig_fpe, sig_kill, sig_usr1, sig_segv, sig_usr2, sig_pipe, sig_alrm, sig_term, sig_chld, sig_cont, sig_stop, sig_tstp, sig_ttin, sig_ttou, sig_urg, sig_xcpu, sig_xfsz, sigtalrm, sig_prof, sig_poll, sig_sys, sig_winch, sig_iot, sig_stkflt, sig_io, sig_lost, sig_pwr): Remove unused global variables variables. * signal.h: Remove declarations thereof.
* * Makefile, arith.c, arith.h, combi.c, combi.h, configure, debug.c,Kaz Kylheku2014-07-231-16/+16
| | | | | | | | debug.h, eval.c, eval.h, filter.c, filter.h, gc.c, gc.h, hash.c, hash.h, lib.c, lib.h, match.c, match.h, parser.h, parser.l, parser.y, rand.c, rand.h, regex.c, regex.h, signal.c, signal.h, stream.c, stream.h, syslog.c, syslog.h, txr.c, txr.h, unwind.c, unwind.h, utf8.c, utf8.h: Synchronize license header with LICENSE.
* On platforms with sigaltstack, TXR programs can now catch theKaz Kylheku2014-03-131-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | segmentation fault that occurs when running out of stack space, and escape by throwing an exception. Also, bugfix: save and restore the gc enable/disable state. Without this, if we are ever running cod in a gc disabled state and it jumps out, gc stays disabled. * configure: added check for sigaltstack. * gc.h (gc_enabled): Declaration added for existing variable. * signal.c (is_cpu_exception): New static function. (sig_handler): For cpu_exception type signals that pertain to the execution of some instruction, turn on async_sig_enabled, so that the signal is not deferred. Otherwise we will just return without calling the user-defined handler, restart the instruction and get into a loop. Also, disable gc around the handler just in case. One issue is that we might be on an alternate stack, which gc won't like. (setup_alt_stack, teardown_alt_stack): New static functions. (set_sig_handler): If we have sigaltstack, and are asked to set up a SEGV handler, then set it up on the alternate stack. * signal.h (extended_jmp_buf): Adding new member, gc. (extended_setjmp, extended_longjmp): use gc member to save and restore the gc_enable state across setjmp and longjmp.
* Introducing some changes for improved handling of special variables.Kaz Kylheku2014-02-231-3/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Saving and restoring of individual variables is very silly and it's making it difficult to implement function parameters that are rebindings of special variables. Let's have a global pointer to a dynamic environment called dyn_env. Let's make it part of the extended_jmp_buf structure, so that it's implicitly saved and restored across exception handling. Special variable lookups go through the dyn_env chain, and fall back on the global bindings. To override some specials, we just push a new dynamic environment and stick them there. (As a bonus, the bindings can even be repeated in the lexical environment (i.e. the same objects), so they can be found faster. We have to make sure we remove that environment when we leave the scope in the normal way. If we unwind out, it is done automatically by extended_longjmp mechanism. * eval.c (dyn_env): New global variable. (lookup_var, lookup_var_l): If env is nil, look in the dyn_env first, and only if that fails, look in the global bindings top_vb. * signal.h (extended_jmp_buf): New member, de, for saving/restoring dyn_env. This structure is now used whether or not we have signals. (extended_setjmp, extended_longjmp): Updated to save and restore dyn_env, and to do it regardless of whether there is POSIX signal support. (dyn_env): Declared here.
* Long overdue MinGW port maintenance.Kaz Kylheku2014-01-091-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Makefile: Use new EXE variable from config.mk. * configure (exe, have_windows_h): New variables. Handle situations with .exe suffix; on MiGW, the rm command doesn't work on executables if the .exe suffix is not given. New tests for localtime_r and gmtime_r. * lib.c: Supply declarations which are missing on MinGW because we use gcc -ansi, because MinGW doesn't follow established conventions like -D_POSIX_SOURCE. Supply definitions for gmtime_r, localtime_r, setenv and unsetenv. * parser.l: Supply declarations which are missing on MinGW. * signal.h (async_sig_enabled): Declare differently based on HAVE_POSIX_SIGS. Misspelled typedef fixed in the code for !HAVE_POSIX_SIGS that has hitherto not been compiled. (sig_mask): Wrap declaration in #ifdef HAVE_POSIX_SIGS because it relies on sigset_t. * stream.c: Supply declarations which are missing on MinGW. Include <windows.h> if we have it. (sleep): Define for Windows. (statf): Handle missing st_blksize and st_blocks members in struct stat. (stream_init): Handle numerous missing S_* macros. * utf8.c: Supply declarations which are missing on MinGW.
* Fixing a bug and performance issue.Kaz Kylheku2013-12-201-3/+10
| | | | | | | | | | | | | | | | | | | | | 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.
* * eval.c (eval_init): Registered vars for signal numbers.Kaz Kylheku2013-12-121-0/+7
| | | | | | | | | | | | * signal.c (sig_hup, sig_int, sig_quit, sig_ill, sig_trap, sig_abrt, sig_bus, val sig_fpe, sig_kill, sig_usr1, sig_segv, sig_usr2, sig_pipe, sig_alrm, val sig_term, sig_chld, sig_cont, sig_stop, sig_tstp, sig_ttin, val sig_ttou, sig_urg, sig_xcpu, sig_xfsz, sigtalrm, sig_prof, val sig_poll, sig_sys, sig_winch, sig_iot, sig_stkflt, sig_io, sig_lost, sig_pwr): New variables. (sig_init): New variables initialized. * signal.h: New variables declared.
* First cut at signal handling support.Kaz Kylheku2013-12-121-0/+93
* Makefile (OBJS-y): Include signal.o if have_posix_sigs is "y". * configure (have_posix_sigs): New variable, set by detecting POSIX signal stuff. * dep.mk: Regenerated. * arith.c, debug.c, eval.c, filter.c, hash.c, match.c, parser.y, parser.l, rand.c, regex.c, syslog.c, txr.c, utf8.c: Include new signal.h header, now required by unwind, and the <signal.h> system header. * eval.c (exit_wrap): New function. (eval_init): New functions registered as intrinsics: exit_wrap, set_sig_handler, get_sig_handler, sig_check. * gc.c (release): Unused functions removed. * gc.h (release): Declaration removed. * lib.c (init): Call sig_init. * stream.c (set_putc, se_getc, se_fflush): New static functions. (stdio_put_char_callback, stdio_get_char_callback, stdio_put_byte, stdio_flush, stdio_get_byte): Use new functions to enable signals when blocked on I/O. (tail_strategy): Allow signals across sleep. (pipev_close): Allow signals across waitpid. (se_pclose): New static function. (pipe_close): Use new function to enable signals across pclose. * unwind.c (uw_unwind_to_exit_point): use extended_longjmp instead of longjmp. * unwind.h (struct uw_block, struct uw_catch): jb member changes from jmp_buf to extended_jmp_buf. (uw_block_begin, uw_simple_catch_begin, uw_catch_begin): Use extended_setjmp instead of setjmp. * signal.c: New file. * signal.h: New file.