From 89b639724994d96ce21bc965732ec05e46a665bb Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Mon, 1 Nov 1999 18:02:44 +0000 Subject: Removed routines that had already been separated into their own files. --- c/src/exec/posix/src/psignal.c | 505 ----------------------------------------- 1 file changed, 505 deletions(-) (limited to 'c/src/exec/posix/src/psignal.c') diff --git a/c/src/exec/posix/src/psignal.c b/c/src/exec/posix/src/psignal.c index 9185ece304..0d7d3a2e8c 100644 --- a/c/src/exec/posix/src/psignal.c +++ b/c/src/exec/posix/src/psignal.c @@ -478,508 +478,3 @@ void _POSIX_signals_Manager_Initialization( sizeof( POSIX_signals_Siginfo_node ) ); } - -/* - * 3.3.3 Manipulate Signal Sets, P1003.1b-1993, p. 69 - */ - -int sigemptyset( - sigset_t *set -) -{ - if ( !set ) - set_errno_and_return_minus_one( EINVAL ); - - *set = 0; - return 0; -} - -/* - * 3.3.3 Manipulate Signal Sets, P1003.1b-1993, p. 69 - */ - -int sigfillset( - sigset_t *set -) -{ - if ( !set ) - set_errno_and_return_minus_one( EINVAL ); - - *set = SIGNAL_ALL_MASK; - return 0; -} - -/* - * 3.3.3 Manipulate Signal Sets, P1003.1b-1993, p. 69 - */ - -int sigaddset( - sigset_t *set, - int signo -) -{ - if ( !set ) - set_errno_and_return_minus_one( EINVAL ); - - if ( !signo ) - return 0; - - if ( !is_valid_signo(signo) ) - set_errno_and_return_minus_one( EINVAL ); - - *set |= signo_to_mask(signo); - return 0; -} - -/* - * 3.3.3 Manipulate Signal Sets, P1003.1b-1993, p. 69 - */ - -int sigdelset( - sigset_t *set, - int signo -) -{ - if ( !set ) - set_errno_and_return_minus_one( EINVAL ); - - if ( !signo ) - return 0; - - if ( !is_valid_signo(signo) ) - set_errno_and_return_minus_one( EINVAL ); - - *set &= ~signo_to_mask(signo); - return 0; -} - -/* - * 3.3.3 Manipulate Signal Sets, P1003.1b-1993, p. 69 - */ - -int sigismember( - const sigset_t *set, - int signo -) -{ - if ( !set ) - set_errno_and_return_minus_one( EINVAL ); - - if ( !signo ) - return 0; - - if ( !is_valid_signo(signo) ) - set_errno_and_return_minus_one( EINVAL ); - - if ( *set & signo_to_mask(signo) ) - return 1; - - return 0; -} - -/* - * 3.3.4 Examine and Change Signal Action, P1003.1b-1993, p. 70 - */ - -/* *************************************************************************** - * The signal handler is notified to the timers manager when the - * timer is set. So, the timers manager knows the signal handler. - * ***************************************************************************/ - -int sigaction( - int sig, - const struct sigaction *act, - struct sigaction *oact -) -{ - ISR_Level level; - - - if ( oact ) - *oact = _POSIX_signals_Vectors[ sig ]; - - if ( !sig ) - return 0; - - if ( !is_valid_signo(sig) ) - set_errno_and_return_minus_one( EINVAL ); - - /* - * Some signals cannot be ignored (P1003.1b-1993, pp. 70-72 and references. - * - * NOTE: Solaris documentation claims to "silently enforce" this which - * contradicts the POSIX specification. - */ - - if ( sig == SIGKILL ) - set_errno_and_return_minus_one( EINVAL ); - - /* - * Evaluate the new action structure and set the global signal vector - * appropriately. - */ - - if ( act ) { - - /* - * Unless the user is installing the default signal actions, then - * we can just copy the provided sigaction structure into the vectors. - */ - - _ISR_Disable( level ); - if ( act->sa_handler == SIG_DFL ) { - _POSIX_signals_Vectors[ sig ] = _POSIX_signals_Default_vectors[ sig ]; - } else { - _POSIX_signals_Clear_process_signals( signo_to_mask(sig) ); - _POSIX_signals_Vectors[ sig ] = *act; - } - _ISR_Enable( level ); - } - - /* - * No need to evaluate or dispatch because: - * - * + If we were ignoring the signal before, none could be pending - * now (signals not posted when SIG_IGN). - * + If we are now ignoring a signal that was previously pending, - * we clear the pending signal indicator. - */ - - return 0; -} - -/* - * 3.3.5 Examine and Change Blocked Signals, P1003.1b-1993, p. 73 - * - * NOTE: P1003.1c/D10, p. 37 adds pthread_sigmask(). - * - */ - -int sigprocmask( - int how, - const sigset_t *set, - sigset_t *oset -) -{ - /* - * P1003.1c/Draft 10, p. 38 maps sigprocmask to pthread_sigmask. - */ - - return pthread_sigmask( how, set, oset ); -} - -/* - * 3.3.5 Examine and Change Blocked Signals, P1003.1b-1993, p. 73 - * - * NOTE: P1003.1c/D10, p. 37 adds pthread_sigmask(). - */ - -int pthread_sigmask( - int how, - const sigset_t *set, - sigset_t *oset -) -{ - POSIX_API_Control *api; - - if ( !set && !oset ) - set_errno_and_return_minus_one( EINVAL ); - - api = _Thread_Executing->API_Extensions[ THREAD_API_POSIX ]; - - if ( oset ) - *oset = api->signals_blocked; - - if ( !set ) - return 0; - - switch ( how ) { - case SIG_BLOCK: - api->signals_blocked |= *set; - break; - case SIG_UNBLOCK: - api->signals_blocked &= ~*set; - break; - case SIG_SETMASK: - api->signals_blocked = *set; - break; - default: - set_errno_and_return_minus_one( EINVAL ); - } - - /* XXX are there critical section problems here? */ - - /* XXX evaluate the new set */ - - if ( ~api->signals_blocked & - (api->signals_pending | _POSIX_signals_Pending) ) { - _Thread_Executing->do_post_task_switch_extension = TRUE; - _Thread_Dispatch(); - } - - return 0; -} - -/* - * 3.3.6 Examine Pending Signals, P1003.1b-1993, p. 75 - */ - -int sigpending( - sigset_t *set -) -{ - POSIX_API_Control *api; - - if ( !set ) - set_errno_and_return_minus_one( EINVAL ); - - api = _Thread_Executing->API_Extensions[ THREAD_API_POSIX ]; - - *set = api->signals_pending | _POSIX_signals_Pending; - - return 0; -} - -/* - * 3.3.7 Wait for a Signal, P1003.1b-1993, p. 75 - */ - -int sigsuspend( - const sigset_t *sigmask -) -{ - sigset_t saved_signals_blocked; - sigset_t all_signals; - int status; - POSIX_API_Control *api; - - api = _Thread_Executing->API_Extensions[ THREAD_API_POSIX ]; - - status = sigprocmask( SIG_BLOCK, sigmask, &saved_signals_blocked ); - - (void) sigfillset( &all_signals ); - - status = sigtimedwait( &all_signals, NULL, NULL ); - - (void) sigprocmask( SIG_SETMASK, &saved_signals_blocked, NULL ); - - return status; -} - -/* - * 3.3.8 Synchronously Accept a Signal, P1003.1b-1993, p. 76 - * - * NOTE: P1003.1c/D10, p. 39 adds sigwait(). - */ - -int sigwaitinfo( - const sigset_t *set, - siginfo_t *info -) -{ - return sigtimedwait( set, info, NULL ); -} - -/* - * 3.3.8 Synchronously Accept a Signal, P1003.1b-1993, p. 76 - * - * NOTE: P1003.1c/D10, p. 39 adds sigwait(). - */ - -int _POSIX_signals_Get_highest( - sigset_t set -) -{ - int signo; - - for ( signo = SIGRTMIN ; signo <= SIGRTMAX ; signo++ ) { - if ( set & signo_to_mask( signo ) ) - return signo; - } - -/* XXX - add __SIGFIRSTNOTRT or something like that to newlib siginfo.h */ - - for ( signo = SIGHUP ; signo <= __SIGLASTNOTRT ; signo++ ) { - if ( set & signo_to_mask( signo ) ) - return signo; - } - - return 0; -} - -int sigtimedwait( - const sigset_t *set, - siginfo_t *info, - const struct timespec *timeout -) -{ - Thread_Control *the_thread; - POSIX_API_Control *api; - Watchdog_Interval interval; - siginfo_t signal_information; - siginfo_t *the_info; - int signo; - - the_info = ( info ) ? info : &signal_information; - - the_thread = _Thread_Executing; - - api = the_thread->API_Extensions[ THREAD_API_POSIX ]; - - /* - * What if they are already pending? - */ - - /* API signals pending? */ - - if ( *set & api->signals_pending ) { - /* XXX real info later */ - the_info->si_signo = _POSIX_signals_Get_highest( api->signals_pending ); - _POSIX_signals_Clear_signals( api, the_info->si_signo, the_info, - FALSE, FALSE ); - the_info->si_code = SI_USER; - the_info->si_value.sival_int = 0; - return the_info->si_signo; - } - - /* Process pending signals? */ - - if ( *set & _POSIX_signals_Pending) { - signo = _POSIX_signals_Get_highest( _POSIX_signals_Pending ); - _POSIX_signals_Clear_signals( api, signo, the_info, TRUE, FALSE ); - - if ( !info ) { - the_info->si_signo = signo; - the_info->si_code = SI_USER; - the_info->si_value.sival_int = 0; - } - } - - interval = 0; - if ( timeout ) { - - if (timeout->tv_nsec < 0 || timeout->tv_nsec >= TOD_NANOSECONDS_PER_SECOND) - set_errno_and_return_minus_one( EINVAL ); - - interval = _POSIX_Timespec_to_interval( timeout ); - } - - the_info->si_signo = -1; - - _Thread_Disable_dispatch(); - the_thread->Wait.queue = &_POSIX_signals_Wait_queue; - the_thread->Wait.return_code = EINTR; - the_thread->Wait.option = *set; - the_thread->Wait.return_argument = (void *) the_info; - _Thread_queue_Enter_critical_section( &_POSIX_signals_Wait_queue ); - _Thread_queue_Enqueue( &_POSIX_signals_Wait_queue, interval ); - _Thread_Enable_dispatch(); - - /* - * When the thread set free by a signal, it is needed to eliminate - * that signal - */ - - _POSIX_signals_Clear_signals( api, the_info->si_signo, the_info, - FALSE, FALSE ); - - errno = _Thread_Executing->Wait.return_code; - return the_info->si_signo; -} - -/* - * 3.3.8 Synchronously Accept a Signal, P1003.1b-1993, p. 76 - * - * NOTE: P1003.1c/D10, p. 39 adds sigwait(). - */ - -int sigwait( - const sigset_t *set, - int *sig -) -{ - int status; - - status = sigtimedwait( set, NULL, NULL ); - - if ( status != -1 ) { - if ( sig ) - *sig = status; - return 0; - } - - return errno; -} - -/* - * 3.3.9 Queue a Signal to a Process, P1003.1b-1993, p. 78 - */ - -int sigqueue( - pid_t pid, - int signo, - const union sigval value -) -{ - return killinfo( pid, signo, &value ); -} - -/* - * 3.3.10 Send a Signal to a Thread, P1003.1c/D10, p. 43 - */ - -int pthread_kill( - pthread_t thread, - int sig -) -{ - POSIX_API_Control *api; - Thread_Control *the_thread; - Objects_Locations location; - - if ( sig && !is_valid_signo(sig) ) - set_errno_and_return_minus_one( EINVAL ); -/* - if ( _POSIX_signals_Vectors[ sig ].sa_flags == SA_SIGINFO ) - set_errno_and_return_minus_one( ENOSYS ); -*/ - /* - * RTEMS does not support sending a siginfo signal to a specific thread. - */ - - the_thread = _POSIX_Threads_Get( thread, &location ); - switch ( location ) { - case OBJECTS_ERROR: - case OBJECTS_REMOTE: - set_errno_and_return_minus_one( ESRCH ); - case OBJECTS_LOCAL: - /* - * If sig == 0 then just validate arguments - */ - - api = the_thread->API_Extensions[ THREAD_API_POSIX ]; - - if ( sig ) { - - if ( _POSIX_signals_Vectors[ sig ].sa_handler == SIG_IGN ) { - _Thread_Enable_dispatch(); - return 0; - } - - /* XXX critical section */ - - api->signals_pending |= signo_to_mask( sig ); - - (void) _POSIX_signals_Unblock_thread( the_thread, sig, NULL ); - - the_thread->do_post_task_switch_extension = TRUE; - - if ( _ISR_Is_in_progress() && _Thread_Is_executing( the_thread ) ) - _ISR_Signals_to_thread_executing = TRUE; - } - _Thread_Enable_dispatch(); - return 0; - } - - return POSIX_BOTTOM_REACHED(); -} -- cgit v1.2.3