Skip to content

Commit 08d36e6

Browse files
Bernard RizzoSharan Santhanam
Bernard Rizzo
authored and
Sharan Santhanam
committed
lib/newlib: Support for uksignal
This patch is an update of the original. Signed-off-by: Mihai Pogonaru <[email protected]> Signed-off-by: Felipe Huici <[email protected]> Signed-off-by: Bernard Rizzo <[email protected]> Reviewed-by: ARGINT DRAGOS IULIAN <[email protected]>
1 parent 2dd8523 commit 08d36e6

File tree

4 files changed

+144
-98
lines changed

4 files changed

+144
-98
lines changed

Diff for: Makefile.uk

-3
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ LIBNEWLIBGLUE_SRCS-y += $(LIBNEWLIBC_BASE)/resource.c
136136
LIBNEWLIBGLUE_SRCS-y += $(LIBNEWLIBC_BASE)/pty.c
137137
LIBNEWLIBGLUE_SRCS-y += $(LIBNEWLIBC_BASE)/locale.c
138138
LIBNEWLIBGLUE_SRCS-y += $(LIBNEWLIBC_BASE)/dev.c
139-
LIBNEWLIBGLUE_SRCS-y += $(LIBNEWLIBC_BASE)/signal.c
140139
LIBNEWLIBGLUE_SRCS-y += $(LIBNEWLIBC_BASE)/link.c
141140
LIBNEWLIBGLUE_SRCS-y += $(LIBNEWLIBC_BASE)/mntent.c
142141
LIBNEWLIBGLUE_SRCS-y += $(LIBNEWLIBC_BASE)/syscall.c
@@ -415,8 +414,6 @@ LIBNEWLIBC_SRCS-y += $(LIBNEWLIB_LIBC)/search/bsd_qsort_r.c
415414
# Newlib/libc code -- signal
416415
################################################################################
417416
LIBNEWLIBC_SRCS-y += $(LIBNEWLIB_LIBC)/signal/psignal.c
418-
LIBNEWLIBC_SRCS-y += $(LIBNEWLIB_LIBC)/signal/raise.c
419-
LIBNEWLIBC_SRCS-y += $(LIBNEWLIB_LIBC)/signal/signal.c
420417

421418
################################################################################
422419
# Newlib/libc code -- stdio

Diff for: musl-imported/include/signal.h

+144
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
/* adapted from OSv */
2+
#ifndef __UK_SIGNAL_H__
3+
#define __UK_SIGNAL_H__
4+
5+
#include <stddef.h>
6+
7+
#ifdef __cplusplus
8+
extern "C" {
9+
#endif
10+
11+
12+
#define SIG_BLOCK 0
13+
#define SIG_UNBLOCK 1
14+
#define SIG_SETMASK 2
15+
#define SIGHUP 1
16+
#define SIGINT 2
17+
#define SIGQUIT 3
18+
#define SIGILL 4
19+
#define SIGTRAP 5
20+
#define SIGABRT 6
21+
#define SIGIOT SIGABRT
22+
#define SIGBUS 7
23+
#define SIGFPE 8
24+
#define SIGKILL 9
25+
#define SIGUSR1 10
26+
#define SIGSEGV 11
27+
#define SIGUSR2 12
28+
#define SIGPIPE 13
29+
#define SIGALRM 14
30+
#define SIGTERM 15
31+
#define SIGSTKFLT 16
32+
#define SIGCHLD 17
33+
#define SIGCONT 18
34+
#define SIGSTOP 19
35+
#define SIGTSTP 20
36+
#define SIGTTIN 21
37+
#define SIGTTOU 22
38+
#define SIGURG 23
39+
#define SIGXCPU 24
40+
#define SIGXFSZ 25
41+
#define SIGVTALRM 26
42+
#define SIGPROF 27
43+
#define SIGWINCH 28
44+
#define SIGIO 29
45+
#define SIGPOLL 29
46+
#define SIGPWR 30
47+
#define SIGSYS 31
48+
#define SIGUNUSED SIGSYS
49+
50+
#define _NSIG 32
51+
52+
#define SA_NOCLDSTOP 1
53+
#define SA_NOCLDWAIT 2
54+
#define SA_SIGINFO 4
55+
#define SA_ONSTACK 0x08000000
56+
#define SA_RESTART 0x10000000
57+
#define SA_NODEFER 0x40000000
58+
#define SA_RESETHAND 0x80000000
59+
#define SA_RESTORER 0x04000000
60+
61+
typedef int pid_t;
62+
typedef int sig_atomic_t;
63+
typedef unsigned long __sigset_t;
64+
typedef __sigset_t sigset_t;
65+
66+
#define NSIG _NSIG
67+
68+
typedef struct {
69+
int si_signo; /* Signal number */
70+
int si_code; /* Cause of the signal */
71+
pid_t si_pid; /* Sending process ID */
72+
} siginfo_t;
73+
74+
struct sigaction {
75+
union {
76+
void (*sa_handler)(int);
77+
void (*sa_sigaction)(int, siginfo_t *, void *);
78+
} __sa_handler;
79+
sigset_t sa_mask;
80+
int sa_flags;
81+
void (*sa_restorer)(void);
82+
};
83+
#define sa_handler __sa_handler.sa_handler
84+
#define sa_sigaction __sa_handler.sa_sigaction
85+
86+
#define SIG_ERR ((void (*)(int))-1)
87+
#define SIG_DFL ((void (*)(int)) 0)
88+
#define SIG_IGN ((void (*)(int)) 1)
89+
90+
/* TODO: do we have gnu statement expression? */
91+
#define is_sig_dfl(ptr) \
92+
(!((ptr)->sa_flags & SA_SIGINFO) && (ptr)->sa_handler == SIG_DFL)
93+
94+
#define is_sig_ign(ptr) \
95+
(!((ptr)->sa_flags & SA_SIGINFO) && (ptr)->sa_handler == SIG_IGN)
96+
97+
int sigaction(int signum, const struct sigaction *act,
98+
struct sigaction *oldact);
99+
100+
int sigpending(sigset_t *set);
101+
int sigprocmask(int how, const sigset_t *set,
102+
sigset_t *oldset);
103+
int sigsuspend(const sigset_t *mask);
104+
int sigwait(const sigset_t *set, int *sig);
105+
106+
int kill(pid_t pid, int sig);
107+
int raise(int sig);
108+
109+
typedef void (*sighandler_t)(int);
110+
sighandler_t signal(int signum, sighandler_t handler);
111+
112+
int pthread_sigmask(int how, const sigset_t *set, sigset_t *oldset);
113+
int sigemptyset(sigset_t *set);
114+
int sigfillset(sigset_t *set);
115+
int sigaddset(sigset_t *set, int signo);
116+
int sigdelset(sigset_t *set, int signo);
117+
int sigismember(const sigset_t *set, int signo);
118+
int siginterrupt(int sig, int flag);
119+
void psignal(int sig, const char *s);
120+
121+
/* TODO: not used - defined just for newlib */
122+
union sigval {
123+
int sival_int; /* Integer signal value */
124+
void *sival_ptr; /* Pointer signal value */
125+
};
126+
127+
struct sigevent {
128+
int sigev_notify; /* Notification type */
129+
int sigev_signo; /* Signal number */
130+
union sigval sigev_value; /* Signal value */
131+
};
132+
133+
/* TODO: not used - defined just for v8 */
134+
typedef struct sigaltstack {
135+
void *ss_sp;
136+
int ss_flags;
137+
size_t ss_size;
138+
} stack_t;
139+
140+
#ifdef __cplusplus
141+
}
142+
#endif
143+
144+
#endif /* __UK_SIGNAL_H__ */

Diff for: plat.c

-8
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,6 @@ int getentropy(void *buf __unused, size_t buflen __unused)
4747
return -1;
4848
}
4949

50-
int sigprocmask(int how __unused, const sigset_t *set __unused,
51-
sigset_t *oldset __unused)
52-
{
53-
/* TODO: implement. */
54-
errno = ENOTSUP;
55-
return -1;
56-
}
57-
5850
#include <uk/plat/bootstrap.h>
5951

6052
void abort(void)

Diff for: signal.c

-87
This file was deleted.

0 commit comments

Comments
 (0)