jehanne: deep refactoring of signals (WIP)
This commit is contained in:
parent
95383ee144
commit
188433192c
|
@ -12,7 +12,7 @@ extra_objs =
|
|||
endif
|
||||
|
||||
lib_a_SOURCES = getenv_r.c getenv.c malloc.c mallocr.c free.c freer.c \
|
||||
calloc.c callocr.c realloc.c reallocr.c environ.c
|
||||
calloc.c callocr.c realloc.c reallocr.c environ.c signal.c
|
||||
|
||||
lib_a_LIBADD = $(extra_objs)
|
||||
EXTRA_lib_a_SOURCES = libposix_conf.c syscalls.c chown.c getrusage.c \
|
||||
|
|
|
@ -59,7 +59,7 @@ am_lib_a_OBJECTS = lib_a-getenv_r.$(OBJEXT) lib_a-getenv.$(OBJEXT) \
|
|||
lib_a-free.$(OBJEXT) lib_a-freer.$(OBJEXT) \
|
||||
lib_a-calloc.$(OBJEXT) lib_a-callocr.$(OBJEXT) \
|
||||
lib_a-realloc.$(OBJEXT) lib_a-reallocr.$(OBJEXT) \
|
||||
lib_a-environ.$(OBJEXT)
|
||||
lib_a-environ.$(OBJEXT) lib_a-signal.$(OBJEXT)
|
||||
lib_a_OBJECTS = $(am_lib_a_OBJECTS)
|
||||
DEFAULT_INCLUDES = -I.@am__isrc@
|
||||
depcomp =
|
||||
|
@ -183,7 +183,7 @@ noinst_LIBRARIES = lib.a
|
|||
@MAY_SUPPLY_SYSCALLS_TRUE@ chmod.o sigsets.o
|
||||
|
||||
lib_a_SOURCES = getenv_r.c getenv.c malloc.c mallocr.c free.c freer.c \
|
||||
calloc.c callocr.c realloc.c reallocr.c environ.c
|
||||
calloc.c callocr.c realloc.c reallocr.c environ.c signal.c
|
||||
|
||||
lib_a_LIBADD = $(extra_objs)
|
||||
EXTRA_lib_a_SOURCES = libposix_conf.c syscalls.c chown.c getrusage.c \
|
||||
|
@ -322,6 +322,12 @@ lib_a-environ.o: environ.c
|
|||
lib_a-environ.obj: environ.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-environ.obj `if test -f 'environ.c'; then $(CYGPATH_W) 'environ.c'; else $(CYGPATH_W) '$(srcdir)/environ.c'; fi`
|
||||
|
||||
lib_a-signal.o: signal.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-signal.o `test -f 'signal.c' || echo '$(srcdir)/'`signal.c
|
||||
|
||||
lib_a-signal.obj: signal.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-signal.obj `if test -f 'signal.c'; then $(CYGPATH_W) 'signal.c'; else $(CYGPATH_W) '$(srcdir)/signal.c'; fi`
|
||||
|
||||
lib_a-libposix_conf.o: libposix_conf.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-libposix_conf.o `test -f 'libposix_conf.c' || echo '$(srcdir)/'`libposix_conf.c
|
||||
|
||||
|
|
|
@ -249,25 +249,6 @@ default_timezone_reader(void *tz, const Tm *time)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static PosixSignalAction
|
||||
signal_trampoline(int signal)
|
||||
{
|
||||
switch(__sigtramp(signal)){
|
||||
case -1: // unknown signal or uninitialized signals
|
||||
jehanne_sysfatal("newlib: error handling signal %d or unknown signal", signal);
|
||||
case 0: // catched
|
||||
return SignalCatched;
|
||||
case 3: // ignored
|
||||
return SignalIgnored;
|
||||
case 1: // default
|
||||
return SignalDefault;
|
||||
case 2: // error
|
||||
return SignalError;
|
||||
default:
|
||||
jehanne_sysfatal("newlib: unexpected PosixSignalAction from signal trampoline: %d", signal);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
initialize_newlib(void)
|
||||
{
|
||||
|
@ -279,73 +260,9 @@ initialize_newlib(void)
|
|||
libposix_translate_seek_whence(SEEK_SET, SEEK_CUR, SEEK_END);
|
||||
libposix_translate_access_mode(F_OK, R_OK, W_OK, X_OK);
|
||||
libposix_translate_open(open_translator);
|
||||
libposix_set_signal_trampoline(signal_trampoline);
|
||||
libposix_translate_error(default_error_translator, 0);
|
||||
libposix_set_wait_options(0, WNOHANG, 0);
|
||||
|
||||
/* signals */
|
||||
libposix_define_signal(PosixSIGABRT, SIGABRT);
|
||||
libposix_define_signal(PosixSIGALRM, SIGALRM);
|
||||
libposix_define_signal(PosixSIGBUS, SIGBUS);
|
||||
libposix_define_signal(PosixSIGCHLD, SIGCHLD);
|
||||
libposix_define_signal(PosixSIGCONT, SIGCONT);
|
||||
libposix_define_signal(PosixSIGFPE, SIGFPE);
|
||||
libposix_define_signal(PosixSIGHUP, SIGHUP);
|
||||
libposix_define_signal(PosixSIGILL, SIGILL);
|
||||
libposix_define_signal(PosixSIGINT, SIGINT);
|
||||
libposix_define_signal(PosixSIGKILL, SIGKILL);
|
||||
libposix_define_signal(PosixSIGPIPE, SIGPIPE);
|
||||
libposix_define_signal(PosixSIGQUIT, SIGQUIT);
|
||||
libposix_define_signal(PosixSIGSEGV, SIGSEGV);
|
||||
libposix_define_signal(PosixSIGSTOP, SIGSTOP);
|
||||
libposix_define_signal(PosixSIGTERM, SIGTERM);
|
||||
libposix_define_signal(PosixSIGTSTP, SIGTSTP);
|
||||
libposix_define_signal(PosixSIGTTIN, SIGTTIN);
|
||||
libposix_define_signal(PosixSIGTTOU, SIGTTOU);
|
||||
libposix_define_signal(PosixSIGUSR1, SIGUSR1);
|
||||
libposix_define_signal(PosixSIGUSR2, SIGUSR2);
|
||||
libposix_define_signal(PosixSIGPOLL, SIGPOLL);
|
||||
libposix_define_signal(PosixSIGPROF, SIGPROF);
|
||||
libposix_define_signal(PosixSIGSYS, SIGSYS);
|
||||
libposix_define_signal(PosixSIGTRAP, SIGTRAP);
|
||||
libposix_define_signal(PosixSIGURG, SIGURG);
|
||||
libposix_define_signal(PosixSIGVTALRM, SIGVTALRM);
|
||||
libposix_define_signal(PosixSIGXCPU, SIGXCPU);
|
||||
libposix_define_signal(PosixSIGXFSZ, SIGXFSZ);
|
||||
#ifdef SIGIOT
|
||||
libposix_define_signal(PosixSIGIOT, SIGIOT);
|
||||
#endif
|
||||
#ifdef SIGEMT
|
||||
libposix_define_signal(PosixSIGEMT, SIGEMT);
|
||||
#endif
|
||||
#ifdef SIGSTKFLT
|
||||
libposix_define_signal(PosixSIGSTKFLT, SIGSTKFLT);
|
||||
#endif
|
||||
#ifdef SIGIO
|
||||
libposix_define_signal(PosixSIGIO, SIGIO);
|
||||
#endif
|
||||
#ifdef SIGCLD
|
||||
libposix_define_signal(PosixSIGCLD, SIGCLD);
|
||||
#endif
|
||||
#ifdef SIGPWR
|
||||
libposix_define_signal(PosixSIGPWR, SIGPWR);
|
||||
#endif
|
||||
#ifdef SIGINFO
|
||||
libposix_define_signal(PosixSIGINFO, SIGINFO);
|
||||
#endif
|
||||
#ifdef SIGLOST
|
||||
libposix_define_signal(PosixSIGLOST, SIGLOST);
|
||||
#endif
|
||||
#ifdef SIGWINCH
|
||||
libposix_define_signal(PosixSIGWINCH, SIGWINCH);
|
||||
#endif
|
||||
#ifdef SIGUNUSED
|
||||
libposix_define_signal(PosixSIGUNUSED, SIGUNUSED);
|
||||
#endif
|
||||
#if defined(SIGRTMIN) && defined(SIGRTMAX)
|
||||
libposix_define_realtime_signals(SIGRTMIN, SIGRTMAX);
|
||||
#endif
|
||||
|
||||
/* error numbers */
|
||||
libposix_define_errno(PosixE2BIG, E2BIG);
|
||||
libposix_define_errno(PosixEACCES, EACCES);
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* 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>
|
||||
|
||||
PosixSigHandler
|
||||
signal(int signo, PosixSigHandler handler)
|
||||
{
|
||||
int *errnop = &_REENT->_errno;
|
||||
return POSIX_signal(errnop, signo, handler);
|
||||
}
|
||||
|
||||
int
|
||||
raise(int signo)
|
||||
{
|
||||
int *errnop = &_REENT->_errno;
|
||||
return POSIX_kill(errnop, getpid(), signo);
|
||||
}
|
|
@ -43,9 +43,6 @@ newlib(int argc, char *argv[])
|
|||
/* initialize the private reentrancy structure */
|
||||
_impure_ptr = &private_reent;
|
||||
|
||||
/* initialize signal infrastructure */
|
||||
_init_signal_r(_REENT);
|
||||
|
||||
libposix_init(argc, argv, initialize_newlib);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue