Add sigandset(3), sigisemptyset(3), signotset(3), and sigorset(3).

This commit is contained in:
Jonas 'Sortie' Termansen 2013-07-27 16:28:58 +02:00
parent da94e0fb62
commit 30d35a98dd
6 changed files with 144 additions and 0 deletions

View File

@ -32,10 +32,14 @@ inttypes/strtoumax.o \
inttypes/wcstoimax.o \
inttypes/wcstoumax.o \
signal/sigaddset.o \
signal/sigandset.o \
signal/sigdelset.o \
signal/sigemptyset.o \
signal/sigfillset.o \
signal/sigisemptyset.o \
signal/sigismember.o \
signal/signotset.o \
signal/sigorset.o \
stdio/clearerr.o \
stdio/dprintf.o \
stdio/fbufsize.o \

View File

@ -176,14 +176,18 @@ int raise(int sig);
int sigaction(int, const struct sigaction* __restrict, struct sigaction* __restrict);
int sigaddset(sigset_t*, int);
int sigaltstack(const stack_t* __restrict, stack_t* __restrict);
int sigandset(sigset_t*, const sigset_t*, const sigset_t*);
int sigdelset(sigset_t*, int);
int sigemptyset(sigset_t*);
int sigfillset(sigset_t*);
/* TODO: sighold (obsolescent XSI). */
/* TODO: sigignore (obsolescent XSI). */
/* TODO: siginterrupt (obsolescent XSI). */
int sigisemptyset(const sigset_t*);
int sigismember(const sigset_t*, int);
sighandler_t signal(int, sighandler_t);
int signotset(sigset_t*, const sigset_t*);
int sigorset(sigset_t*, const sigset_t*, const sigset_t*);
/* TODO: sigpause (obsolescent XSI). */
int sigpending(sigset_t*);
int sigprocmask(int, const sigset_t* __restrict, sigset_t* __restrict);

34
libc/signal/sigandset.cpp Normal file
View File

@ -0,0 +1,34 @@
/*******************************************************************************
Copyright(C) Jonas 'Sortie' Termansen 2013.
This file is part of the Sortix C Library.
The Sortix C Library is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
The Sortix C Library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
signal/sigandset.cpp
Computes the intersection of two signal sets.
*******************************************************************************/
#include <stdint.h>
#include <signal.h>
extern "C"
int sigandset(sigset_t* set, const sigset_t* left, const sigset_t* right)
{
for ( size_t i = 0; i < sizeof(set->__val) / sizeof(set->__val[0]); i++ )
set->__val[i] = left->__val[i] & right->__val[i];
return 0;
}

View File

@ -0,0 +1,34 @@
/*******************************************************************************
Copyright(C) Jonas 'Sortie' Termansen 2013.
This file is part of the Sortix C Library.
The Sortix C Library is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
The Sortix C Library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
signal/sigisemptyset.cpp
Tests whether this is the empty signal set.
*******************************************************************************/
#include <stdint.h>
#include <signal.h>
extern "C" int sigisemptyset(const sigset_t* set)
{
for ( size_t i = 0; i < sizeof(set->__val) / sizeof(set->__val[0]); i++ )
if ( set->__val[i] != 0 )
return 1;
return 0;
}

34
libc/signal/signotset.cpp Normal file
View File

@ -0,0 +1,34 @@
/*******************************************************************************
Copyright(C) Jonas 'Sortie' Termansen 2013.
This file is part of the Sortix C Library.
The Sortix C Library is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
The Sortix C Library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
signal/signotset.cpp
Computes the complement of a signal set.
*******************************************************************************/
#include <stdint.h>
#include <signal.h>
extern "C"
int signotset(sigset_t* dst, const sigset_t* src)
{
for ( size_t i = 0; i < sizeof(dst->__val) / sizeof(dst->__val[0]); i++ )
dst->__val[i] = ~src->__val[i];
return 0;
}

34
libc/signal/sigorset.cpp Normal file
View File

@ -0,0 +1,34 @@
/*******************************************************************************
Copyright(C) Jonas 'Sortie' Termansen 2013.
This file is part of the Sortix C Library.
The Sortix C Library is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
The Sortix C Library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
signal/sigorset.cpp
Computes the union of two signal sets.
*******************************************************************************/
#include <stdint.h>
#include <signal.h>
extern "C"
int sigorset(sigset_t* set, const sigset_t* left, const sigset_t* right)
{
for ( size_t i = 0; i < sizeof(set->__val) / sizeof(set->__val[0]); i++ )
set->__val[i] = left->__val[i] | right->__val[i];
return 0;
}