scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit 383f380ad18c01f99b8a5427f1b803680e936162
parent 4d873268c8a3982aa46a627873608a022d9186f7
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sat,  2 Oct 2021 21:42:30 +0200

libc: Fix sigaction() for OpenBSD

OpenBSD had the same sigaction() implementation than NetBSD,
but the implementation of OpenBSD is much simpler and we
only have to call the syscall.

Diffstat:
Ainclude/bits/openbsd/amd64/arch/sigaction.h | 15+++++++++++++++
Rinclude/bits/openbsd/amd64/stdint.h -> include/bits/openbsd/amd64/arch/stdint.h | 0
Rinclude/bits/openbsd/amd64/time.h -> include/bits/openbsd/amd64/arch/time.h | 0
Minclude/bits/openbsd/sys.h | 6+-----
Msrc/libc/arch/Makefile | 21+++++++++++----------
Msrc/libc/arch/amd64/openbsd/.gitignore | 1-
Msrc/libc/arch/amd64/openbsd/Makefile | 14+++++---------
Msrc/libc/arch/amd64/openbsd/syscall.lst | 2+-
Msrc/libc/arch/netbsd/Makefile | 5+++++
Rsrc/libc/arch/bsd/_sigaction.c -> src/libc/arch/netbsd/_sigaction.c | 0
Msrc/libc/objs/amd64-openbsd.mk | 32++++++++++++++++++++++++++++++++
11 files changed, 70 insertions(+), 26 deletions(-)

diff --git a/include/bits/openbsd/amd64/arch/sigaction.h b/include/bits/openbsd/amd64/arch/sigaction.h @@ -0,0 +1,15 @@ +typedef unsigned int sigset_t; +typedef struct siginfo siginfo_t; + +struct sigaction { + union { + void (*__sa_handler)(int); + void (*__sa_sigaction)(int, siginfo_t *, void *); + } __sigaction_u; + + sigset_t sa_mask; + int sa_flags; +}; + +#define sa_handler __sigaction_u.__sa_handler +#define sa_sigaction __sigaction_u.__sa_sigaction diff --git a/include/bits/openbsd/amd64/stdint.h b/include/bits/openbsd/amd64/arch/stdint.h diff --git a/include/bits/openbsd/amd64/time.h b/include/bits/openbsd/amd64/arch/time.h diff --git a/include/bits/openbsd/sys.h b/include/bits/openbsd/sys.h @@ -12,11 +12,7 @@ typedef int pid_t; -struct sigaction { - void (*sa_handler)(int); - int sa_mask; - int sa_flags; -}; +struct sigaction; extern pid_t _getpid(void); extern int _kill(pid_t pid, int signum); diff --git a/src/libc/arch/Makefile b/src/libc/arch/Makefile @@ -3,23 +3,26 @@ PROJECTDIR = ../../.. DIRS =\ + $(ARCHS)\ + $(SYSTEMS)\ + posix\ + +ARCHS =\ amd64\ arm64\ arm\ - darwin\ - dragonfly\ i386\ - linux\ - netbsd\ - openbsd\ - posix\ ppc\ -BSD =\ +POSIX =\ netbsd\ openbsd\ darwin\ dragonfly\ + linux\ + +SYSTEM =\ + $(POSIX)\ include $(PROJECTDIR)/scripts/rules.mk include ../rules.mk @@ -28,6 +31,4 @@ NODEP = 1 all: $(ARCH) $(SYS) -linux: posix - -$(BSD): bsd +$(POSIX): posix diff --git a/src/libc/arch/amd64/openbsd/.gitignore b/src/libc/arch/amd64/openbsd/.gitignore @@ -7,6 +7,5 @@ _lseek.s _open.s _read.s _sigaction.s -_sigaction2.s _sys_errlist.c _write.s diff --git a/src/libc/arch/amd64/openbsd/Makefile b/src/libc/arch/amd64/openbsd/Makefile @@ -13,27 +13,23 @@ GENOBJS =\ _lseek.$O\ _open.$O\ _read.$O\ - _sigaction2.$O\ + _sigaction.$O\ _write.$O\ -GENSRC = $(GENOBJS:.$O=.s) - OBJS =\ $(GENOBJS)\ _sys_errlist.$O\ -all: $(LIBC) $(CRT) +GENSRC = $(GENOBJS:.$O=.s) -$(LIBC): $(OBJS) - $(MKLST) +all: $(OBJS) $(CRT) -crt.$O: ../crt-posix.s ../openbsd/crt.s +$(CRT): ../crt-posix.s ../openbsd/crt.s $(GENSRC): syscall.lst ./gensys.sh $(@:.s=) clean: - rm -f $(GENSRC) - rm -f syscall _sys_errlist.c + rm -f $(GENSRC) _sys_errlist.c include deps.mk diff --git a/src/libc/arch/amd64/openbsd/syscall.lst b/src/libc/arch/amd64/openbsd/syscall.lst @@ -7,6 +7,6 @@ 6 _close 1 17 _brk 1 20 _getpid 0 -46 _sigaction2 5 +46 _sigaction 3 122 _kill 2 198 _lseek 3 diff --git a/src/libc/arch/netbsd/Makefile b/src/libc/arch/netbsd/Makefile @@ -3,4 +3,9 @@ PROJECTDIR = ../../../.. include $(PROJECTDIR)/scripts/rules.mk include ../../rules.mk +OBJS =\ + sigaction.$O\ + NODEP = 1 + +all: $(OBJS) diff --git a/src/libc/arch/bsd/_sigaction.c b/src/libc/arch/netbsd/_sigaction.c diff --git a/src/libc/objs/amd64-openbsd.mk b/src/libc/objs/amd64-openbsd.mk @@ -2,3 +2,35 @@ include objs/common-objs.mk OBJS =\ $(COMMON_OBJS)\ + arch/amd64/openbsd/_brk.$O\ + arch/amd64/openbsd/_close.$O\ + arch/amd64/openbsd/_exit.$O\ + arch/amd64/openbsd/_getpid.$O\ + arch/amd64/openbsd/_kill.$O\ + arch/amd64/openbsd/_lseek.$O\ + arch/amd64/openbsd/_open.$O\ + arch/amd64/openbsd/_read.$O\ + arch/amd64/openbsd/_sigaction.$O\ + arch/amd64/openbsd/_write.$O\ + arch/amd64/openbsd/crt.$O\ + arch/amd64/openbsd/_sys_errlist.$O\ + arch/amd64/longjmp.$O\ + arch/amd64/memchr.$O\ + arch/amd64/memcmp.$O\ + arch/amd64/memcpy.$O\ + arch/amd64/memmove.$O\ + arch/amd64/memset.$O\ + arch/amd64/setjmp.$O\ + arch/amd64/strchr.$O\ + arch/amd64/strcmp.$O\ + arch/amd64/strcpy.$O\ + arch/posix/_getheap.$O\ + arch/posix/_open.$O\ + arch/posix/_systime.$O\ + arch/posix/_tzone.$O\ + arch/posix/clock.$O\ + arch/posix/getenv.$O\ + arch/posix/raise.$O\ + arch/posix/signal.$O\ + arch/posix/time.$O\ + string/strlen.$O\