Changeset 14873


Ignore:
Timestamp:
Jul 11, 2011, 8:42:13 PM (8 years ago)
Author:
rme
Message:

Change signature of install_signal_handler() and update
callers.

Location:
trunk/source/lisp-kernel
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/lisp-kernel/arm-exceptions.c

    r14807 r14873  
    18601860
    18611861void
    1862 install_signal_handler(int signo, void *handler, Boolean system_p, Boolean on_altstack)
     1862install_signal_handler(int signo, void *handler, unsigned flags)
    18631863{
    18641864  struct sigaction sa;
     1865  int err;
    18651866
    18661867  sigfillset(&sa.sa_mask);
     
    18681869  sa.sa_sigaction = (void *)handler;
    18691870  sigfillset(&sa.sa_mask);
    1870   sa.sa_flags =
    1871     0 /* SA_RESTART */
    1872     | SA_NODEFER
    1873     | SA_SIGINFO
     1871  sa.sa_flags = SA_SIGINFO;
     1872
     1873#ifdef ANDROID
     1874  sa.sa_flags |= SA_NODEFER
     1875#endif
    18741876#ifdef USE_SIGALTSTACK
    1875     | (on_altstack ? SA_ONSTACK : 0)
    1876 #endif
    1877     ;
    1878 
    1879   sigaction(signo, &sa, NULL);
     1877  if (flags & ON_ALTSTACK)
     1878    sa.sa_flags |= SA_ONSTACK;
     1879#endif
     1880  if (flags & RESTART_SYSCALLS)
     1881    sa.sa_flags |= SA_RESTART;
     1882  if (flags & RESERVE_FOR_LISP) {
     1883    extern sigset_t user_signals_reserved;
     1884    sigaddset(&user_signals_reserved, signo);
     1885  }
     1886
     1887  err = sigaction(signo, &sa, NULL);
     1888  if (err) {
     1889    perror("sigaction");
     1890    exit(1);
     1891  }
    18801892}
    18811893
     
    18961908    ;
    18971909  if (install_signal_handlers_for_exceptions) {
    1898     install_signal_handler(SIGILL, (void *)sigill_handler, true, false);
    1899     install_signal_handler(SIGSEGV, (void *)ALTSTACK(signal_handler),true, true);
    1900     install_signal_handler(SIGBUS, (void *)ALTSTACK(signal_handler),true,true);
     1910    install_signal_handler(SIGILL, (void *)sigill_handler, RESERVE_FOR_LISP);
     1911    install_signal_handler(SIGSEGV, (void *)ALTSTACK(signal_handler),
     1912                           RESERVE_FOR_LISP|ON_ALTSTACK);
     1913    install_signal_handler(SIGBUS, (void *)ALTSTACK(signal_handler),
     1914                           RESERVE_FOR_LISP|ON_ALTSTACK);
    19011915
    19021916  }
    19031917 
    19041918  install_signal_handler(SIGNAL_FOR_PROCESS_INTERRUPT,
    1905                          (void *)interrupt_handler, true, false);
     1919                         (void *)interrupt_handler, RESERVE_FOR_LISP);
    19061920  signal(SIGPIPE, SIG_IGN);
    19071921}
     
    19691983  thread_kill_signal = SIG_KILL_THREAD;
    19701984
    1971   install_signal_handler(thread_suspend_signal, (void *) suspend_resume_handler, true, false);
    1972   install_signal_handler(thread_kill_signal, (void *)thread_kill_handler, true, false);
     1985  install_signal_handler(thread_suspend_signal, (void *)suspend_resume_handler,
     1986                         RESERVE_FOR_LISP);
     1987  install_signal_handler(thread_kill_signal, (void *)thread_kill_handler,
     1988                         RESERVE_FOR_LISP);
    19731989}
    19741990
  • trunk/source/lisp-kernel/lisp.h

    r14503 r14873  
    9696extern FILE *dbgout;
    9797
     98#define RESERVE_FOR_LISP 1
     99#define ON_ALTSTACK 2
     100#define RESTART_SYSCALLS 4
     101
    98102void
    99 install_signal_handler(int, void*, Boolean, Boolean);
     103install_signal_handler(int signo, void *handler, unsigned flags);
    100104
    101105#endif /* __lisp__ */
  • trunk/source/lisp-kernel/pmcl-kernel.c

    r14729 r14873  
    815815  SetConsoleCtrlHandler(ControlEventHandler,TRUE);
    816816#else
    817   install_signal_handler(SIGINT, (void *)user_signal_handler, false, false);
    818   install_signal_handler(SIGTERM, (void *)user_signal_handler, false, false);
    819   install_signal_handler(SIGQUIT, (void *)user_signal_handler, false, false);
     817  install_signal_handler(SIGINT, (void *)user_signal_handler, 0);
     818  install_signal_handler(SIGTERM, (void *)user_signal_handler, 0);
     819  install_signal_handler(SIGQUIT, (void *)user_signal_handler, 0);
    820820#endif
    821821}
     
    835835  if (user_signal_semaphores[signo] == 0) {
    836836    user_signal_semaphores[signo] = (natural)new_semaphore(0);
    837     install_signal_handler(signo,(void *)user_signal_handler, false, false);
     837    install_signal_handler(signo,(void *)user_signal_handler, 0);
    838838  }
    839839  return wait_on_semaphore((void *)user_signal_semaphores[signo],seconds,milliseconds);
  • trunk/source/lisp-kernel/ppc-exceptions.c

    r14438 r14873  
    22122212
    22132213void
    2214 install_signal_handler(int signo, void *handler, Boolean system, Boolean on_altstack)
     2214install_signal_handler(int signo, void *handler, unsigned flags)
    22152215{
    22162216  struct sigaction sa;
     2217  int err;
    22172218 
    22182219  sa.sa_sigaction = (void *)handler;
    22192220  sigfillset(&sa.sa_mask);
    2220   sa.sa_flags =
    2221     0 /* SA_RESTART */
    2222     | SA_SIGINFO
    2223 #ifdef DARWIN
    2224 #ifdef PPC64
    2225     | SA_64REGSET
    2226 #endif
    2227 #endif
    2228     ;
    2229 
    2230   sigaction(signo, &sa, NULL);
    2231   if (system) {
     2221  sa.sa_flags = SA_SIGINFO;
     2222
     2223  if (flags & RESTART_SYSCALLS)
     2224    sa.sa_flags |= SA_RESTART;
     2225  if (flags & RESERVE_FOR_LISP) {
    22322226    extern sigset_t user_signals_reserved;
    22332227    sigaddset(&user_signals_reserved, signo);
    22342228  }
    22352229
     2230  err = sigaction(signo, &sa, NULL);
     2231  if (err) {
     2232    perror("sigaction");
     2233    exit(1);
     2234  }
    22362235}
    22372236
     
    22522251  if (install_signal_handlers_for_exceptions) {
    22532252    extern int no_sigtrap;
    2254     install_signal_handler(SIGILL, (void *)signal_handler, true, false);
     2253    install_signal_handler(SIGILL, (void *)signal_handler, RESERVE_FOR_LISP);
    22552254    if (no_sigtrap != 1) {
    2256       install_signal_handler(SIGTRAP, (void *)signal_handler, true, false);
    2257     }
    2258     install_signal_handler(SIGBUS,  (void *)signal_handler, true, false);
    2259     install_signal_handler(SIGSEGV, (void *)signal_handler, true, false);
    2260     install_signal_handler(SIGFPE, (void *)signal_handler, true, false);
     2255      install_signal_handler(SIGTRAP, (void *)signal_handler, RESERVE_FOR_LISP);
     2256    }
     2257    install_signal_handler(SIGBUS,  (void *)signal_handler, RESERVE_FOR_LISP);
     2258    install_signal_handler(SIGSEGV, (void *)signal_handler, RESERVE_FOR_LISP);
     2259    install_signal_handler(SIGFPE, (void *)signal_handler, RESERVE_FOR_LISP);
    22612260  }
    22622261 
    22632262  install_signal_handler(SIGNAL_FOR_PROCESS_INTERRUPT,
    2264                          (void *)interrupt_handler, true, false);
     2263                         (void *)interrupt_handler, RESERVE_FOR_LISP);
    22652264  signal(SIGPIPE, SIG_IGN);
    22662265}
     
    23012300  thread_kill_signal = SIG_KILL_THREAD;
    23022301
    2303   install_signal_handler(thread_suspend_signal, (void *) suspend_resume_handler, true, false);
    2304   install_signal_handler(thread_kill_signal, (void *)thread_kill_handler, true, false);
     2302  install_signal_handler(thread_suspend_signal, (void *)suspend_resume_handler,
     2303                         RESERVE_FOR_LISP);
     2304  install_signal_handler(thread_kill_signal, (void *)thread_kill_handler,
     2305                         RESERVE_FOR_LISP);
    23052306}
    23062307
  • trunk/source/lisp-kernel/x86-exceptions.c

    r14871 r14873  
    18651865#ifndef WINDOWS
    18661866void
    1867 install_signal_handler(int signo, void * handler, Boolean system, Boolean on_altstack)
     1867install_signal_handler(int signo, void *handler, unsigned flags)
    18681868{
    18691869  struct sigaction sa;
     1870  int err;
    18701871 
    18711872  sa.sa_sigaction = (void *)handler;
     
    18751876  sigdelset(&sa.sa_mask,SIGTRAP);  /* let GDB work */
    18761877#endif
    1877   sa.sa_flags =
    1878     0 /* SA_RESTART */
    1879     | SA_SIGINFO
     1878  sa.sa_flags = SA_SIGINFO;
     1879
    18801880#ifdef USE_SIGALTSTACK
    1881     | (on_altstack ? SA_ONSTACK : 0)
    1882 #endif
    1883 ;
    1884 
    1885   sigaction(signo, &sa, NULL);
    1886   if (system) {
     1881  if (flags & ON_ALTSTACK)
     1882    sa.sa_flags |= SA_ONSTACK;
     1883#endif
     1884  if (flags & RESTART_SYSCALLS)
     1885    sa.sa_flags |= SA_RESTART;
     1886  if (flags & RESERVE_FOR_LISP) {
    18871887    extern sigset_t user_signals_reserved;
    18881888    sigaddset(&user_signals_reserved, signo);
     1889  }
     1890
     1891  err = sigaction(signo, &sa, NULL);
     1892  if (err) {
     1893    perror("sigaction");
     1894    exit(1);
    18891895  }
    18901896}
     
    20932099{
    20942100#ifndef DARWIN 
    2095   void *handler = (void *)
     2101  void *handler, *interrupt_hander;
     2102
    20962103#ifdef USE_SIGALTSTACK
    2097     altstack_signal_handler
    2098 #else
    2099     arbstack_signal_handler;
    2100 #endif
    2101   ;
    2102   install_signal_handler(SIGILL, handler, true, true);
     2104  handler = (void *)altstack_signal_handler;
     2105  interrupt_handler = (void *)altstack_interrupt_handler;
     2106#else
     2107  handler = (void *)arbstack_signal_handler;
     2108  interrupt_handler = (void *)arbstack_interrupt_handler;
     2109#endif
     2110
     2111  install_signal_handler(SIGILL, handler, RESERVE_FOR_LISP|ON_ALTSTACK);
     2112  install_signal_handler(SIGBUS, handler, RESERVE_FOR_LISP|ON_ALTSTACK);
     2113  install_signal_handler(SIGSEGV, handler, RESERVE_FOR_LISP|ON_ALTSTACK);
     2114  install_signal_handler(SIGFPE, handler, RESERVE_FOR_LISP|ON_ALTSTACK);
     2115#endif
    21032116 
    2104   install_signal_handler(SIGBUS, handler, true, true);
    2105   install_signal_handler(SIGSEGV,handler, true, true);
    2106   install_signal_handler(SIGFPE, handler, true, true);
    2107 #endif
    2108  
    2109   install_signal_handler(SIGNAL_FOR_PROCESS_INTERRUPT,
    2110 #ifdef USE_SIGALTSTACK
    2111                          altstack_interrupt_handler
    2112 #else
    2113                          arbstack_interrupt_handler
    2114 #endif
    2115                          , true, true);
     2117  install_signal_handler(SIGNAL_FOR_PROCESS_INTERRUPT, interrupt_handler,
     2118                         RESERVE_FOR_LISP|ON_ALTSTACK);
    21162119  signal(SIGPIPE, SIG_IGN);
    21172120}
     
    23072310  thread_kill_signal = SIG_KILL_THREAD;
    23082311
    2309   install_signal_handler(thread_suspend_signal, (void *)SUSPEND_RESUME_HANDLER, true, true);
    2310   install_signal_handler(thread_kill_signal, (void *)THREAD_KILL_HANDLER, true, true);
     2312  install_signal_handler(thread_suspend_signal, (void *)SUSPEND_RESUME_HANDLER,
     2313                         RESERVE_FOR_LISP|ON_ALTSTACK);
     2314  install_signal_handler(thread_kill_signal, (void *)THREAD_KILL_HANDLER,
     2315                         RESERVE_FOR_LISP|ON_ALTSTACK);
    23112316}
    23122317#endif
Note: See TracChangeset for help on using the changeset viewer.