jehanne: introduce sigaction; signal as macro
This commit is contained in:
@ -16,7 +16,7 @@ lib_a_SOURCES = getenv_r.c getenv.c malloc.c mallocr.c free.c freer.c \
|
||||
|
||||
lib_a_LIBADD = $(extra_objs)
|
||||
EXTRA_lib_a_SOURCES = libposix_conf.c syscalls.c chown.c getrusage.c \
|
||||
ids.c chmod.c sigsets.c
|
||||
ids.c chmod.c sigsets.c sigaction.c
|
||||
lib_a_DEPENDENCIES = $(extra_objs)
|
||||
lib_a_CCASFLAGS = $(AM_CCASFLAGS)
|
||||
lib_a_CFLAGS = $(AM_CFLAGS)
|
||||
|
@ -187,7 +187,7 @@ lib_a_SOURCES = getenv_r.c getenv.c malloc.c mallocr.c free.c freer.c \
|
||||
|
||||
lib_a_LIBADD = $(extra_objs)
|
||||
EXTRA_lib_a_SOURCES = libposix_conf.c syscalls.c chown.c getrusage.c \
|
||||
ids.c chmod.c sigsets.c
|
||||
ids.c chmod.c sigsets.c sigaction.c
|
||||
|
||||
lib_a_DEPENDENCIES = $(extra_objs)
|
||||
lib_a_CCASFLAGS = $(AM_CCASFLAGS)
|
||||
@ -370,6 +370,12 @@ lib_a-sigsets.o: sigsets.c
|
||||
lib_a-sigsets.obj: sigsets.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-sigsets.obj `if test -f 'sigsets.c'; then $(CYGPATH_W) 'sigsets.c'; else $(CYGPATH_W) '$(srcdir)/sigsets.c'; fi`
|
||||
|
||||
lib_a-sigaction.o: sigaction.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-sigaction.o `test -f 'sigaction.c' || echo '$(srcdir)/'`sigaction.c
|
||||
|
||||
lib_a-sigaction.obj: sigaction.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-sigaction.obj `if test -f 'sigaction.c'; then $(CYGPATH_W) 'sigaction.c'; else $(CYGPATH_W) '$(srcdir)/sigaction.c'; fi`
|
||||
|
||||
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
|
@ -21,7 +21,17 @@ typedef PosixSigHandler sighandler_t; /* glibc naming */
|
||||
|
||||
struct _reent;
|
||||
|
||||
PosixSigHandler signal(int signo, PosixSigHandler handler);
|
||||
PosixSigHandler sysv_signal(int signo, PosixSigHandler handler);
|
||||
PosixSigHandler bsd_signal(int signo, PosixSigHandler handler);
|
||||
|
||||
#define ssignal(signo, handler) bsd_signal(signo, handler)
|
||||
|
||||
#ifdef _XOPEN_SOURCE
|
||||
# define signal(signo, handler) sysv_signal(signo, handler)
|
||||
#else
|
||||
# define signal(signo, handler) bsd_signal(signo, handler)
|
||||
#endif
|
||||
|
||||
int raise(int signo);
|
||||
void psignal(int signo, const char *s);
|
||||
|
||||
|
28
newlib/libc/sys/jehanne/sigaction.c
Normal file
28
newlib/libc/sys/jehanne/sigaction.c
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* This file is part of Jehanne.
|
||||
*
|
||||
* Copyright (C) 2017 Giacomo Tesio <giacomo@tesio.it>
|
||||
*
|
||||
* Jehanne 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 Software Foundation, version 2 of the License.
|
||||
*
|
||||
* Jehanne 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Jehanne. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <u.h>
|
||||
#include <libc.h>
|
||||
#include <posix.h>
|
||||
#include <reent.h>
|
||||
|
||||
int
|
||||
sigaction(int signo, const struct sigaction *act, struct sigaction *old)
|
||||
{
|
||||
int *errnop = &_REENT->_errno;
|
||||
return POSIX_sigaction(errnop, signo, act, old);
|
||||
}
|
@ -21,8 +21,31 @@
|
||||
#include <reent.h>
|
||||
|
||||
PosixSigHandler
|
||||
signal(int signo, PosixSigHandler handler)
|
||||
sysv_signal(int signo, PosixSigHandler handler)
|
||||
{
|
||||
struct sigaction sa, old;
|
||||
int *errnop = &_REENT->_errno;
|
||||
return POSIX_signal(errnop, signo, handler);
|
||||
|
||||
sa.sa_flags = 0;
|
||||
sa.sa_handler = handler;
|
||||
if(POSIX_sigemptyset(errnop, &sa.sa_mask) != 0
|
||||
|| POSIX_sigaction(errnop, signo, &sa, &old) != 0)
|
||||
return (PosixSigHandler)-1;
|
||||
|
||||
return old.sa_handler;
|
||||
}
|
||||
|
||||
PosixSigHandler
|
||||
bsd_signal(int signo, PosixSigHandler handler)
|
||||
{
|
||||
struct sigaction sa, old;
|
||||
int *errnop = &_REENT->_errno;
|
||||
|
||||
sa.sa_flags = PosixSAFRestart;
|
||||
sa.sa_handler = handler;
|
||||
if(POSIX_sigemptyset(errnop, &sa.sa_mask) != 0
|
||||
|| POSIX_sigaction(errnop, signo, &sa, &old) != 0)
|
||||
return (PosixSigHandler)-1;
|
||||
|
||||
return old.sa_handler;
|
||||
}
|
||||
|
@ -63,11 +63,15 @@ typedef PosixSignalMask sigset_t;
|
||||
|
||||
/* 3.3.8 Synchronously Accept a Signal, P1003.1b-1993, p. 76 */
|
||||
|
||||
#define SA_NOCLDSTOP 1 /* Do not generate SIGCHLD when children stop */
|
||||
#define SA_SIGINFO 2 /* Invoke the signal catching function with */
|
||||
/* three arguments instead of one. */
|
||||
#define SA_NOCLDSTOP PosixSAFNoChildrenStop
|
||||
#define SA_RESETHAND PosixSAFResetHandler
|
||||
#define SA_RESTART PosixSAFRestart
|
||||
#define SA_SIGINFO PosixSAFSigInfo
|
||||
#define SA_NOCLDWAIT PosixSAFNoChildrenWait
|
||||
#define SA_NODEFER PosixSAFNoDefer
|
||||
|
||||
#if __BSD_VISIBLE || __XSI_VISIBLE >= 4 || __POSIX_VISIBLE >= 200809
|
||||
#define SA_ONSTACK 4 /* Signal delivery will be on a separate stack. */
|
||||
#define SA_ONSTACK PosixSAFOnStack /* Signal delivery will be on a separate stack. */
|
||||
#endif
|
||||
|
||||
|
||||
@ -86,8 +90,8 @@ typedef PosixSignalMask sigset_t;
|
||||
/*
|
||||
* Possible values for ss_flags in stack_t below.
|
||||
*/
|
||||
#define SS_ONSTACK 0x1
|
||||
#define SS_DISABLE 0x2
|
||||
#define SS_ONSTACK PosixSAFOnStack
|
||||
#define SS_DISABLE PosixSAFDisable
|
||||
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user