mirror of
https://github.com/fluencelabs/musl
synced 2025-04-25 15:22:15 +00:00
changes to kernel sigaction struct handling in preparation for mips port
This commit is contained in:
parent
e864a29090
commit
fcaec912ed
2
Makefile
2
Makefile
@ -28,7 +28,7 @@ CFLAGS = -Os -pipe
|
|||||||
CFLAGS_C99FSE = -std=c99 -ffreestanding -nostdinc
|
CFLAGS_C99FSE = -std=c99 -ffreestanding -nostdinc
|
||||||
|
|
||||||
CFLAGS_ALL = $(CFLAGS_C99FSE)
|
CFLAGS_ALL = $(CFLAGS_C99FSE)
|
||||||
CFLAGS_ALL += -D_XOPEN_SOURCE=700 -I./src/internal -I./include -I./arch/$(ARCH)
|
CFLAGS_ALL += -D_XOPEN_SOURCE=700 -I./arch/$(ARCH) -I./src/internal -I./include
|
||||||
CFLAGS_ALL += $(CPPFLAGS) $(CFLAGS)
|
CFLAGS_ALL += $(CPPFLAGS) $(CFLAGS)
|
||||||
CFLAGS_ALL_STATIC = $(CFLAGS_ALL)
|
CFLAGS_ALL_STATIC = $(CFLAGS_ALL)
|
||||||
CFLAGS_ALL_SHARED = $(CFLAGS_ALL) -fPIC -DSHARED -O3
|
CFLAGS_ALL_SHARED = $(CFLAGS_ALL) -fPIC -DSHARED -O3
|
||||||
|
@ -0,0 +1,10 @@
|
|||||||
|
/* These functions will not work, but suffice for targets where the
|
||||||
|
* kernel sigaction structure does not actually use sa_restorer. */
|
||||||
|
|
||||||
|
void __restore()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void __restore_rt()
|
||||||
|
{
|
||||||
|
}
|
@ -4,6 +4,7 @@
|
|||||||
#include "syscall.h"
|
#include "syscall.h"
|
||||||
#include "pthread_impl.h"
|
#include "pthread_impl.h"
|
||||||
#include "libc.h"
|
#include "libc.h"
|
||||||
|
#include "ksigaction.h"
|
||||||
|
|
||||||
void __restore(), __restore_rt();
|
void __restore(), __restore_rt();
|
||||||
|
|
||||||
@ -12,28 +13,20 @@ weak_alias(dummy, __pthread_self_def);
|
|||||||
|
|
||||||
int __libc_sigaction(int sig, const struct sigaction *sa, struct sigaction *old)
|
int __libc_sigaction(int sig, const struct sigaction *sa, struct sigaction *old)
|
||||||
{
|
{
|
||||||
struct {
|
struct k_sigaction ksa, *pksa=0;
|
||||||
void *handler;
|
|
||||||
unsigned long flags;
|
|
||||||
void (*restorer)(void);
|
|
||||||
sigset_t mask;
|
|
||||||
} ksa, kold;
|
|
||||||
long pksa=0, pkold=0;
|
|
||||||
if (sa) {
|
if (sa) {
|
||||||
ksa.handler = sa->sa_handler;
|
ksa.handler = sa->sa_handler;
|
||||||
ksa.flags = sa->sa_flags | SA_RESTORER;
|
ksa.flags = sa->sa_flags | SA_RESTORER;
|
||||||
ksa.restorer = (sa->sa_flags & SA_SIGINFO) ? __restore_rt : __restore;
|
ksa.restorer = (sa->sa_flags & SA_SIGINFO) ? __restore_rt : __restore;
|
||||||
ksa.mask = sa->sa_mask;
|
memcpy(&ksa.mask, &sa->sa_mask, sizeof ksa.mask);
|
||||||
pksa = (long)&ksa;
|
|
||||||
}
|
}
|
||||||
if (old) pkold = (long)&kold;
|
|
||||||
__pthread_self_def();
|
__pthread_self_def();
|
||||||
if (syscall(SYS_rt_sigaction, sig, pksa, pkold, 8))
|
if (syscall(SYS_rt_sigaction, sig, sa?&ksa:0, old?&ksa:0, sizeof ksa.mask))
|
||||||
return -1;
|
return -1;
|
||||||
if (old) {
|
if (old) {
|
||||||
old->sa_handler = kold.handler;
|
old->sa_handler = ksa.handler;
|
||||||
old->sa_flags = kold.flags;
|
old->sa_flags = ksa.flags;
|
||||||
old->sa_mask = kold.mask;
|
memcpy(&old->sa_mask, &ksa.mask, sizeof ksa.mask);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user