Mercurial > ecos
changeset 409:10e7722168ad
* src/signal.cxx: Added three exportable routines that may be used
by other packages to manipulate the signal mask, test for
deliverable signals, and have signals delivered at controlled
points.
* include/export.h: Added macros to export signal mask management,
detection and delivery to other packages.
| author | nickg |
|---|---|
| date | Mon, 11 Nov 2002 23:57:47 +0000 |
| parents | dbc601e76824 |
| children | 064536ee7f68 |
| files | packages/compat/posix/current/ChangeLog packages/compat/posix/current/include/export.h packages/compat/posix/current/src/signal.cxx |
| diffstat | 3 files changed, 90 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/packages/compat/posix/current/ChangeLog +++ b/packages/compat/posix/current/ChangeLog @@ -1,3 +1,13 @@ +2002-11-10 Nick Garnett <nickg@ecoscentric.com> + + * src/signal.cxx: Added three exportable routines that may be used + by other packages to manipulate the signal mask, test for + deliverable signals, and have signals delivered at controlled + points. + + * include/export.h: Added macros to export signal mask management, + detection and delivery to other packages. + 2002-11-05 Jonathan Larmour <jifl@eCosCentric.com> * tests/tm_basic.cxx: Use <cyg/infra/diag.h> for diag_printf
--- a/packages/compat/posix/current/include/export.h +++ b/packages/compat/posix/current/include/export.h @@ -11,6 +11,7 @@ // ------------------------------------------- // This file is part of eCos, the Embedded Configurable Operating System. // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. +// Copyright (C) 2002 Nick Garnett // // eCos is free software; you can redistribute it and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -71,6 +72,7 @@ #include <stddef.h> // NULL, size_t #include <limits.h> +#include <signal.h> #include <sys/types.h> @@ -89,5 +91,22 @@ #define CYG_POSIX_FUNCTION_FINISH() cyg_posix_function_finish() //----------------------------------------------------------------------------- +// Signal mask management +// +// These are exported to allow functions in other packages to +// manipulate the current threads signal mask. they are currently only +// used in the implementation of cyg_pselect() in the FILEIO package. + +__externC void cyg_pthread_sigmask_set (const sigset_t *set, sigset_t *oset); +__externC cyg_bool cyg_posix_sigpending(void); +__externC void cyg_posix_deliver_signals(const sigset_t *mask); + +#define CYG_PTHREAD_SIGMASK_SET cyg_pthread_sigmask_set + +#define CYG_POSIX_SIGPENDING() cyg_posix_sigpending() + +#define CYG_POSIX_DELIVER_SIGNALS cyg_posix_deliver_signals + +//----------------------------------------------------------------------------- #endif // ifndef CYGONCE_POSIX_EXPORT_H // End of export.h
--- a/packages/compat/posix/current/src/signal.cxx +++ b/packages/compat/posix/current/src/signal.cxx @@ -9,6 +9,7 @@ // ------------------------------------------- // This file is part of eCos, the Embedded Configurable Operating System. // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. +// Copyright (C) 2002 Nick Garnett // // eCos is free software; you can redistribute it and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -712,6 +713,66 @@ externC int pthread_sigmask (int how, co } // ------------------------------------------------------------------------- +// Exported routine to set calling thread's blocked signal mask +// +// Optionally set and return the current thread's signal mask. This is +// exported to other packages so that they can manipulate the signal +// mask without necessarily having them delivered (as calling +// pthread_sigmask() would). Signals can be delivered by calling +// cyg_posix_deliver_signals(). + +externC void cyg_pthread_sigmask_set (const sigset_t *set, sigset_t *oset) +{ + pthread_info *self = pthread_self_info(); + + if( oset != NULL ) + *oset = self->sigmask; + + if( set != NULL ) + self->sigmask = *set; +} + +// ------------------------------------------------------------------------- +// Exported routine to test for any pending signals. +// +// This routine tests for any pending undelivered, unmasked +// signals. If there are any it returns true. This is exported to +// other packages, such as FILEIO, so that they can detect whether to +// abort a current API call with an EINTR result. + +externC cyg_bool cyg_posix_sigpending(void) +{ + pthread_info *self = pthread_self_info(); + + return ( ((sig_pending | self->sigpending) & ~self->sigmask) != 0 ); +} + +// ------------------------------------------------------------------------- +// Exported routine to deliver selected signals +// +// This routine optionally sets the given mask and then tries to +// deliver any pending signals that have been unmasked. This is +// exported to other packages so that they can cause signals to be +// delivered at controlled points during execution. + +externC void cyg_posix_deliver_signals( const sigset_t *mask ) +{ + sigset_t oldmask; + pthread_info *self = pthread_self_info(); + + if( mask != NULL ) + { + oldmask = self->sigmask; + self->sigmask = *mask; + } + + cyg_deliver_signals(); + + if( mask != NULL ) + self->sigmask = oldmask; +} + +// ------------------------------------------------------------------------- // Get set of pending signals for this process externC int sigpending (sigset_t *set)
