mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-16 03:19:54 +08:00
ea55e3f7f3
* libc/sys/linux/Makefile.am: Add sig.c and sigaction.c. Also make siglist.inc dependent on sig.c instead of signal.c. * libc/sys/linux/Makefile.in: Regenerated. * libc/sys/linux/sig.c: Rename from signal.c and change code to use NSIG instead of _NSIG. * libc/sys/linux/sigaction.c: New file. * libc/sys/linux/signal.c: Changed to be linux signal() function so as to override regular newlib default signal.c. * libc/sys/linux/linuxthreads/config.h: Add __ASSUME_REALTIME_SIGNALS definition. * libc/sys/linux/linuxthreads/testrtsig.h: New file. * libc/sys/linux/machine/i386/Makefile.am: Remove sigset.c. * libc/sys/linux/machine/i386/Makefile.in: Regenerated. * libc/sys/linux/machine/i386/sigset.c: Moved to linux main directory. * libc/sys/linux/sigset.c: Moved from machine/i386 directory. * libc/sys/linux/sys/signal.h: Redefine NSIG to _NSIG and override default linux sigset_t typedef by defining it equal to __sigset_t. * libc/unix/sigset.c: Add check so code isn't compiled on systems with a sigset_t that isn't implemented with a single int.
99 lines
1.7 KiB
C
99 lines
1.7 KiB
C
/* sigset.c - signal set manipulation functions */
|
|
|
|
/* Copyright 2002, Red Hat Inc. */
|
|
|
|
/* Note: these are currently grouped together in one file so that
|
|
it will override the default version in the libc/unix
|
|
directory which has grouped all functions in one file. */
|
|
|
|
/* sigaddset function */
|
|
|
|
#include <signal.h>
|
|
#include <bits/sigset.h>
|
|
#include <errno.h>
|
|
#include <string.h>
|
|
#include <machine/weakalias.h>
|
|
|
|
int
|
|
sigaddset (sigset_t *set, const int signo)
|
|
{
|
|
int index, mask;
|
|
__sigset_t *st = (__sigset_t *)set;
|
|
|
|
if (signo > NSIG)
|
|
{
|
|
errno = EINVAL;
|
|
return -1;
|
|
}
|
|
|
|
index = (signo - 1) / (8 * sizeof(long));
|
|
mask = 1 << ((signo - 1) % (8 * sizeof(long)));
|
|
|
|
st->__val[index] |= mask;
|
|
return 0;
|
|
}
|
|
|
|
/* sigdelset function */
|
|
|
|
int
|
|
sigdelset (sigset_t *set, const int signo)
|
|
{
|
|
int index, mask;
|
|
__sigset_t *st = (__sigset_t *)set;
|
|
|
|
if (signo > NSIG)
|
|
{
|
|
errno = EINVAL;
|
|
return -1;
|
|
}
|
|
|
|
index = (signo - 1) / (8 * sizeof(long));
|
|
mask = 1 << ((signo - 1) % (8 * sizeof(long)));
|
|
|
|
st->__val[index] &= ~mask;
|
|
return 0;
|
|
}
|
|
|
|
/* sigemptyset function */
|
|
|
|
int
|
|
sigemptyset (sigset_t *set)
|
|
{
|
|
int size = NSIG / 8;
|
|
__sigset_t *st = (__sigset_t *)set;
|
|
memset (st->__val, 0, size);
|
|
return 0;
|
|
}
|
|
|
|
/* sigfillset function */
|
|
|
|
int
|
|
sigfillset (sigset_t *set)
|
|
{
|
|
int size = NSIG / 8;
|
|
__sigset_t *st = (__sigset_t *)set;
|
|
memset (st->__val, 0xff, size);
|
|
return 0;
|
|
}
|
|
|
|
/* sigismember function */
|
|
|
|
int
|
|
sigismember (const sigset_t *set, int signo)
|
|
{
|
|
int index, mask;
|
|
__sigset_t *st = (__sigset_t *)set;
|
|
|
|
if (signo > NSIG)
|
|
{
|
|
errno = EINVAL;
|
|
return -1;
|
|
}
|
|
|
|
index = (signo - 1) / (8 * sizeof(long));
|
|
mask = 1 << ((signo - 1) % (8 * sizeof(long)));
|
|
|
|
return (st->__val[index] & mask) != 0;
|
|
}
|
|
|