----------------------------------------------------------------------- -- Howard Eng 6/94-- -- Unixpros, Inc. -- -- -- -- This package defines data types and functions required for signal -- -- handling. -- ----------------------------------------------------------------------- with UNCHECKED_CONVERSION; with SYSTEM_ENVIRONMENT; with CMA_TYPES; package body DCE_ADA_SIGNAL is ------------------------------------------------------------------------ -- ADA_THD_INIT_SIGNAL - initializes the interrupt manager and -- -- installs the two async I/O signals -- ----------------------------------------------------------------------- procedure ADA_THD_INIT_SIGNAL is begin INTERRUPT_MANAGER.INIT_INTERRUPT_MANAGER( 50, 512, 1024 ); INTERRUPT_TASK.INSTALL_HANDLER( 22 ); -- SIGIO -- INTERRUPT_TASK.INSTALL_HANDLER( 29 ); -- SIGURG -- end ADA_THD_INIT_SIGNAL; task body ADA_THD_INTERRUPT_TASK_T is procedure ADA_THD_SIG_DELIVER( SIG : INTERRUPT_MANAGER.SIGNAL_NUMBER; TCB : SYSTEM.ADDRESS := SYSTEM.NULL_ADDRESS ); pragma INTERFACE( C, ADA_THD_SIG_DELIVER ); THIS_TCB : SYSTEM.ADDRESS; begin loop select accept SIGHUP_E; ADA_THD_SIG_DELIVER( SIGHUP_N ); or accept SIGINT_E; ADA_THD_SIG_DELIVER( SIGINT_N ); or accept SIGQUIT_E; ADA_THD_SIG_DELIVER( SIGQUIT_N ); or accept SIGILL_E( TCB : in SYSTEM.ADDRESS ); ADA_THD_SIG_DELIVER( SIGILL_N ); or accept SIGTRAP_E; ADA_THD_SIG_DELIVER( SIGTRAP_N ); or accept SIGIOT_E( TCB : in SYSTEM.ADDRESS ) do THIS_TCB := TCB; end SIGIOT_E; ADA_THD_SIG_DELIVER( SIGIOT_N, THIS_TCB ); or accept SIGEMT_E( TCB : in SYSTEM.ADDRESS ) do THIS_TCB := TCB; end SIGEMT_E; ADA_THD_SIG_DELIVER( SIGEMT_N, THIS_TCB ); or accept SIGFPE_E( TCB : in SYSTEM.ADDRESS ) do THIS_TCB := TCB; end SIGFPE_E; ADA_THD_SIG_DELIVER( SIGFPE_N, THIS_TCB ); or accept SIGKILL_E; ADA_THD_SIG_DELIVER( SIGKILL_N ); or accept SIGBUS_E( TCB : in SYSTEM.ADDRESS ) do THIS_TCB := TCB; end SIGBUS_E; ADA_THD_SIG_DELIVER( SIGBUS_N, THIS_TCB ); or accept SIGSEGV_E( TCB : in SYSTEM.ADDRESS ) do THIS_TCB := TCB; end SIGSEGV_E; ADA_THD_SIG_DELIVER( SIGSEGV_N, THIS_TCB ); or accept SIGSYS_E( TCB : in SYSTEM.ADDRESS ) do THIS_TCB := TCB; end SIGSYS_E; ADA_THD_SIG_DELIVER( SIGSYS_N, THIS_TCB ); or accept SIGPIPE_E( TCB : in SYSTEM.ADDRESS ) do THIS_TCB := TCB; end SIGPIPE_E; ADA_THD_SIG_DELIVER( SIGPIPE_N, THIS_TCB ); or accept SIGALRM_E; ADA_THD_SIG_DELIVER( SIGALRM_N ); or accept SIGTERM_E; ADA_THD_SIG_DELIVER( SIGTERM_N ); or accept SIGUSR1_E; ADA_THD_SIG_DELIVER( SIGUSR1_N ); or accept SIGUSR2_E; ADA_THD_SIG_DELIVER( SIGUSR2_N ); or accept SIGCHLD_E; ADA_THD_SIG_DELIVER( SIGCHLD_N ); or accept SIGPWR_E; ADA_THD_SIG_DELIVER( SIGPWR_N ); or accept SIGVTALRM_E; ADA_THD_SIG_DELIVER( SIGVTALRM_N ); or accept SIGPROF_E; ADA_THD_SIG_DELIVER( SIGPROF_N ); or accept SIGIO_E; ADA_THD_SIG_DELIVER( SIGIO_N ); or accept SIGWINDOW_E; ADA_THD_SIG_DELIVER( SIGWINDOW_N ); or accept SIGSTOP_E; ADA_THD_SIG_DELIVER( SIGSTOP_N ); or accept SIGTSTP_E; ADA_THD_SIG_DELIVER( SIGTSTP_N ); or accept SIGCONT_E; ADA_THD_SIG_DELIVER( SIGCONT_N ); or accept SIGTTIN_E; ADA_THD_SIG_DELIVER( SIGTTIN_N ); or accept SIGTTOU_E; ADA_THD_SIG_DELIVER( SIGTTOU_N ); or accept SIGURG_E; ADA_THD_SIG_DELIVER( SIGURG_N ); or accept SIGLOST_E; ADA_THD_SIG_DELIVER( SIGLOST_N ); or accept SIGRESERVE_E; ADA_THD_SIG_DELIVER( SIGRESERVE_N ); or accept SIGDIL_E; ADA_THD_SIG_DELIVER( SIGDIL_N ); or accept INSTALL_HANDLER( SIG : CMA_TYPES.C_INTEGER ) do if not SIG_TABLE( SIG ).INSTALLED then INTERRUPT_MANAGER.INSTALL_HANDLER( SIG_TABLE( SIG ).HANDLER, SIG_TABLE( SIG ).SIGNAL, INTERRUPT_MANAGER.INTERRUPT_PRIORITY'FIRST ); SIG_TABLE( SIG ).INSTALLED := TRUE; end if; end INSTALL_HANDLER; or accept REMOVE_HANDLER( SIG : CMA_TYPES.C_INTEGER ) do if SIG_TABLE( SIG ).INSTALLED then INTERRUPT_MANAGER.REMOVE_HANDLER( SIG_TABLE( SIG ).SIGNAL ); SIG_TABLE( SIG ).INSTALLED := FALSE; end if; end REMOVE_HANDLER; or terminate; end select; end loop; end ADA_THD_INTERRUPT_TASK_T; function ADA_THD_INSTALL_HANDLER( SIG : CMA_TYPES.C_INTEGER ) return CMA_TYPES.C_INTEGER is begin INTERRUPT_TASK.INSTALL_HANDLER( SIG ); return 0; end ADA_THD_INSTALL_HANDLER; function ADA_THD_REMOVE_HANDLER( SIG : CMA_TYPES.C_INTEGER ) return CMA_TYPES.C_INTEGER is begin INTERRUPT_TASK.REMOVE_HANDLER( SIG ); return 0; end ADA_THD_REMOVE_HANDLER; function ADA_THD_GET_TASK_TCB_PTR return SYSTEM.ADDRESS; pragma INTERFACE( C, ADA_THD_GET_TASK_TCB_PTR ); ----------------------------------------------------------------------- -- Below are the handlers for each of the signals. The handler is -- installed on an as needed basis. For example, asynchronous handlers -- are installed as long as there are "sigwaiters". The basic -- processing for the async signals is to just call the signals -- interrupt entry. The signal is then delivered to any "sigwaiters". -- For synchronous signals, the current Ada TCB is stored off and then -- passed to the signal delivery code. This assumes that the runtime -- hasn't switched tasks between the event occurrence and the invocation -- of the handler. ----------------------------------------------------------------------- procedure SIGHUP_P is begin INTERRUPT_TASK.SIGHUP_E; end SIGHUP_P; procedure SIGINT_P is begin INTERRUPT_TASK.SIGINT_E; end SIGINT_P; procedure SIGQUIT_P is begin INTERRUPT_TASK.SIGQUIT_E; end SIGQUIT_P; procedure SIGILL_P is TCB : SYSTEM.ADDRESS; begin TCB := ADA_THD_GET_TASK_TCB_PTR; INTERRUPT_TASK.SIGILL_E( TCB ); end SIGILL_P; procedure SIGTRAP_P is begin INTERRUPT_TASK.SIGTRAP_E; end SIGTRAP_P; procedure SIGIOT_P is TCB : SYSTEM.ADDRESS; begin TCB := ADA_THD_GET_TASK_TCB_PTR; INTERRUPT_TASK.SIGIOT_E( TCB ); end SIGIOT_P; procedure SIGEMT_P is TCB : SYSTEM.ADDRESS; begin TCB := ADA_THD_GET_TASK_TCB_PTR; INTERRUPT_TASK.SIGEMT_E( TCB ); end SIGEMT_P; procedure SIGFPE_P is TCB : SYSTEM.ADDRESS; begin TCB := ADA_THD_GET_TASK_TCB_PTR; INTERRUPT_TASK.SIGFPE_E( TCB ); end SIGFPE_P; procedure SIGKILL_P is begin INTERRUPT_TASK.SIGKILL_E; end SIGKILL_P; procedure SIGBUS_P is TCB : SYSTEM.ADDRESS; begin TCB := ADA_THD_GET_TASK_TCB_PTR; INTERRUPT_TASK.SIGBUS_E( TCB ); end SIGBUS_P; procedure SIGSEGV_P is TCB : SYSTEM.ADDRESS; begin TCB := ADA_THD_GET_TASK_TCB_PTR; INTERRUPT_TASK.SIGSEGV_E( TCB ); end SIGSEGV_P; procedure SIGSYS_P is TCB : SYSTEM.ADDRESS; begin TCB := ADA_THD_GET_TASK_TCB_PTR; INTERRUPT_TASK.SIGSYS_E( TCB ); end SIGSYS_P; procedure SIGPIPE_P is TCB : SYSTEM.ADDRESS; begin TCB := ADA_THD_GET_TASK_TCB_PTR; INTERRUPT_TASK.SIGPIPE_E( TCB ); end SIGPIPE_P; procedure SIGALRM_P is begin INTERRUPT_TASK.SIGALRM_E; end SIGALRM_P; procedure SIGTERM_P is begin INTERRUPT_TASK.SIGTERM_E; end SIGTERM_P; procedure SIGUSR1_P is begin INTERRUPT_TASK.SIGUSR1_E; end SIGUSR1_P; procedure SIGUSR2_P is begin INTERRUPT_TASK.SIGUSR2_E; end SIGUSR2_P; procedure SIGCHLD_P is begin INTERRUPT_TASK.SIGCHLD_E; end SIGCHLD_P; procedure SIGPWR_P is begin INTERRUPT_TASK.SIGPWR_E; end SIGPWR_P; procedure SIGVTALRM_P is begin INTERRUPT_TASK.SIGVTALRM_E; end SIGVTALRM_P; procedure SIGPROF_P is begin INTERRUPT_TASK.SIGPROF_E; end SIGPROF_P; procedure SIGIO_P is begin INTERRUPT_TASK.SIGIO_E; end SIGIO_P; procedure SIGWINDOW_P is begin INTERRUPT_TASK.SIGWINDOW_E; end SIGWINDOW_P; procedure SIGSTOP_P is begin INTERRUPT_TASK.SIGSTOP_E; end SIGSTOP_P; procedure SIGTSTP_P is begin INTERRUPT_TASK.SIGTSTP_E; end SIGTSTP_P; procedure SIGCONT_P is begin INTERRUPT_TASK.SIGCONT_E; end SIGCONT_P; procedure SIGTTIN_P is begin INTERRUPT_TASK.SIGTTIN_E; end SIGTTIN_P; procedure SIGTTOU_P is begin INTERRUPT_TASK.SIGTTOU_E; end SIGTTOU_P; procedure SIGURG_P is begin INTERRUPT_TASK.SIGURG_E; end SIGURG_P; procedure SIGLOST_P is begin INTERRUPT_TASK.SIGLOST_E; end SIGLOST_P; procedure SIGRESERVE_P is begin INTERRUPT_TASK.SIGRESERVE_E; end SIGRESERVE_P; procedure SIGDIL_P is begin INTERRUPT_TASK.SIGDIL_E; end SIGDIL_P; end DCE_ADA_SIGNAL;