Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions arch/aarch64/signal.S
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@
.globl _signal_trampoline
.type _signal_trampoline, %function
_signal_trampoline:
/* Signal number, oldmask - keep stack aligned to 16 */
ldp x0, x19, [sp], #0x10
bl _signal_handler
/* Signal number, handler address - stack aligned to 16 */
ldp x0, x1, [sp], #0x10
blr x1

ldp x0, x1, [sp], #0x10 /* oldmask, cpu_context_t * */
ldp x2, x3, [sp], #0x10 /* pc, sp, psr */
ldr x4, [sp], #0x10 /* psr, skip padding at the end */

mov x0, x19 /* move oldmask to x0 */
ldp x1, x2, [sp], #0x10 /* cpu_context_t *, pc */
ldp x3, x4, [sp], #0x10 /* sp, psr */
bl sigreturn
.size _signal_trampoline, .-_signal_trampoline
13 changes: 5 additions & 8 deletions arch/arm/signal.S
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,11 @@
.globl _signal_trampoline
.type _signal_trampoline, %function
_signal_trampoline:
/* Signal number, oldmask - keep stack aligned to 8 */
pop {r0,r4}
blx _signal_handler
/* Signal number, handler */
pop {r0, r1}
blx r1

mov r0, r4 /* move oldmask to r0 */
pop {r1,r2,r3,r4} /* cpu_context_t *, pc, psp, psr */

/* put psr back on stack, keep aligned to 8 (r5 as padding value) */
push {r4,r5}
pop {r0,r1,r2,r3} /* oldmask, cpu_context_t *, pc, psp */
/* psr on stack */
bl sigreturn
.size _signal_trampoline, .-_signal_trampoline
3 changes: 2 additions & 1 deletion arch/ia32/signal.S
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
.globl _signal_trampoline
.type _signal_trampoline, %function
_signal_trampoline:
pop %ebx /* handler */
/* Signal number on stack */
call _signal_handler
call %ebx

addl $4, %esp
/* oldmask is now on top of the stack */
Expand Down
15 changes: 8 additions & 7 deletions arch/riscv64/signal.S
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@
.globl _signal_trampoline
.type _signal_trampoline, %function
_signal_trampoline:
/* Get signal number from stack */
/* Get signal number and handler address from stack */
lw a0, (sp)
call _signal_handler
ld a1, 8(sp)
jalr ra, a1, 0

lw a0, 8(sp) /* old signal mask */
ld a1, 16(sp) /* cpu context * */
ld a2, 24(sp) /* sepc */
ld a3, 32(sp) /* sp */
addi sp, sp, 40
lw a0, 16(sp) /* old signal mask */
ld a1, 24(sp) /* cpu context * */
ld a2, 32(sp) /* sepc */
ld a3, 40(sp) /* sp */
addi sp, sp, 48
call sigreturn
.size _signal_trampoline, .-_signal_trampoline
15 changes: 8 additions & 7 deletions arch/sparcv8leon/signal.S
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ _signal_trampoline:
save %sp, -0x60, %sp
add %sp, 0xc0, %i0

call _signal_handler
ld [%i0 + 0x04], %o1 /* handler address */
jmpl %o1 + 0, %o7
ld [%i0], %o0 /* signal number */

ld [%i0 + 0x04], %o0 /* old signal mask */
ld [%i0 + 0x08], %o1 /* cpu_context * */
ld [%i0 + 0x0c], %o2 /* pc */
ld [%i0 + 0x10], %o3 /* npc */
ld [%i0 + 0x14], %o4 /* sp */
ld [%i0 + 0x08], %o0 /* old signal mask */
ld [%i0 + 0x0c], %o1 /* cpu_context * */
ld [%i0 + 0x10], %o2 /* pc */
ld [%i0 + 0x14], %o3 /* npc */
ld [%i0 + 0x18], %o4 /* sp */
call sigreturn
ld [%i0 + 0x18], %o5 /* psr */
ld [%i0 + 0x1c], %o5 /* psr */
.size _signal_trampoline, .-_signal_trampoline
87 changes: 1 addition & 86 deletions include/signal.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
#define _LIBPHOENIX_SIGNAL_H_


#include <sys/types.h>
#include <time.h>
#include <phoenix/signal.h>


#ifdef __cplusplus
Expand All @@ -28,87 +27,6 @@ extern "C" {

typedef void (*sighandler_t)(int);

#define SIGHUP 1
#define SIGINT 2
#define SIGQUIT 3
#define SIGILL 4
#define SIGTRAP 5
#define SIGABRT 6
#define SIGIOT SIGABRT
#define SIGEMT 7
#define SIGFPE 8
#define SIGKILL 9
#define SIGBUS 10
#define SIGSEGV 11
#define SIGSYS 12
#define SIGPIPE 13
#define SIGALRM 14
#define SIGTERM 15
#define SIGURG 16
#define SIGSTOP 17
#define SIGTSTP 18
#define SIGCONT 19
#define SIGCHLD 20
#define SIGTTIN 21
#define SIGTTOU 22
#define SIGIO 23
#define SIGXCPU 24
#define SIGXFSZ 25
#define SIGVTALRM 26
#define SIGPROF 27
#define SIGWINCH 28
#define SIGINFO 29
#define SIGUSR1 30
#define SIGUSR2 31

#define NSIG 32

#define SIG_ERR ((sighandler_t)-1)
#define SIG_DFL ((sighandler_t)-2)
#define SIG_IGN ((sighandler_t)-3)


enum { SIG_BLOCK, SIG_SETMASK, SIG_UNBLOCK };


#define SA_NOCLDSTOP 1 << 0
#define SA_NOCLDWAIT 1 << 1
#define SA_NODEFER 1 << 2
#define SA_ONSTACK 1 << 3
#define SA_RESETHAND 1 << 4
#define SA_RESTART 1 << 5
#define SA_RESTORER 1 << 6
#define SA_SIGINFO 1 << 7


typedef int sigset_t;
typedef int sig_atomic_t;


union sigval {
int sival_int;
void *sival_ptr;
};


typedef struct {
int si_signo;
int si_code;
pid_t si_pid;
uid_t si_uid;
void *si_addr;
int si_status;
union sigval si_value;
} siginfo_t;


struct sigaction {
void (*sa_handler) (int);
sigset_t sa_mask;
int sa_flags;
void (*sa_sigaction) (int, siginfo_t *, void *);
};


extern void (*bsd_signal(int, void (*)(int)))(int);

Expand Down Expand Up @@ -173,9 +91,6 @@ extern int sigsuspend(const sigset_t *);
extern int sigwait(const sigset_t *, int *);


extern int signalPostPosix(int pid, int tid, int signal);


#ifdef __cplusplus
}
#endif
Expand Down
4 changes: 2 additions & 2 deletions include/sys/threads.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,10 @@
extern int resourceDestroy(handle_t h);


extern int signalHandle(void (*handler)(void), unsigned mask, unsigned mmask);
extern int signalAction(int signal, const struct sigaction *act, struct sigaction *oact, void (*trampoline)(void));

Check failure on line 158 in include/sys/threads.h

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a9-zynq7000-zedboard)

'struct sigaction' declared inside parameter list will not be visible outside of this definition or declaration [-Werror]

Check failure on line 158 in include/sys/threads.h

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7m7-imxrt106x-evk)

'struct sigaction' declared inside parameter list will not be visible outside of this definition or declaration [-Werror]

Check failure on line 158 in include/sys/threads.h

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7m7-imxrt105x-evk)

'struct sigaction' declared inside parameter list will not be visible outside of this definition or declaration [-Werror]

Check failure on line 158 in include/sys/threads.h

View workflow job for this annotation

GitHub Actions / call-ci / build (armv8r52-mps3an536-qemu)

'struct sigaction' declared inside parameter list will not be visible outside of this definition or declaration [-Werror]


extern int signalPost(int pid, int tid, int signal);
extern int sys_tkill(int pid, int tid, int signal);


extern int signalReturn(int signal);
Expand Down
11 changes: 4 additions & 7 deletions include/sys/wait.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,10 @@ enum {
};


extern const int _signals_phx2posix[];


#define WTERMSIG(stat_val) (_signals_phx2posix[(stat_val >> 8) & 0x7f])
#define WEXITSTATUS(stat_val) ((stat_val) & 0xff)
#define WIFEXITED(stat_val) (WTERMSIG(stat_val) == 0)
#define WIFSIGNALED(stat_val) (WTERMSIG(stat_val) != 0)
#define WTERMSIG(stat_val) ((stat_val >> 8) & 0x7f)
#define WEXITSTATUS(stat_val) ((stat_val) & 0xff)
#define WIFEXITED(stat_val) (WTERMSIG(stat_val) == 0)
#define WIFSIGNALED(stat_val) (WTERMSIG(stat_val) != 0)
#define WIFSTOPPED(stat_val) 0
#define WSTOPSIG(stat_val) 0
#define WIFCONTINUED(stat_val) 0
Expand Down
2 changes: 0 additions & 2 deletions misc/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

extern void _malloc_init(void);
extern int _env_init(void);
extern void _signals_init(void);
extern void _file_init(void);
extern void _errno_init(void);
extern void _atexit_init(void);
Expand All @@ -30,7 +29,6 @@ void _libc_init(void)
_errno_init();
_malloc_init();
_env_init();
_signals_init();
_file_init();
_pthread_init();
}
4 changes: 2 additions & 2 deletions pthread/pthread.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ int pthread_cancel(pthread_t thread)
mutexUnlock(pthread_common.pthread_list_lock);
pthread_key_cleanup(ctx);
pthread_ctx_put(ctx);
err = signalPost(getpid(), id, signal_cancel);
err = sys_tkill(getpid(), id, PH_SIGCANCEL);
}
else {
_pthread_ctx_put(ctx);
Expand Down Expand Up @@ -1070,7 +1070,7 @@ int pthread_sigmask(int how, const sigset_t *__restrict__ set, sigset_t *__restr
int pthread_kill(pthread_t thread, int sig)
{
pthread_ctx *ctx = (pthread_ctx *)thread;
int ret = -signalPostPosix(getpid(), ctx->id, sig);
int ret = -sys_tkill(getpid(), ctx->id, sig);
return ret;
}

Expand Down
Loading
Loading