This patch is an update of the original.
Signed-off-by: Mihai Pogonaru <pogonarumihai@gmail.com>
Signed-off-by: Felipe Huici <felipe.huici@neclab.eu>
Signed-off-by: Bernard Rizzo <b.rizzo@student.uliege.be>
Reviewed-by: ARGINT DRAGOS IULIAN <dragosargint21@gmail.com>
LIBNEWLIBGLUE_SRCS-y += $(LIBNEWLIBC_BASE)/pty.c
LIBNEWLIBGLUE_SRCS-y += $(LIBNEWLIBC_BASE)/locale.c
LIBNEWLIBGLUE_SRCS-y += $(LIBNEWLIBC_BASE)/dev.c
-LIBNEWLIBGLUE_SRCS-y += $(LIBNEWLIBC_BASE)/signal.c
LIBNEWLIBGLUE_SRCS-y += $(LIBNEWLIBC_BASE)/link.c
LIBNEWLIBGLUE_SRCS-y += $(LIBNEWLIBC_BASE)/mntent.c
LIBNEWLIBGLUE_SRCS-y += $(LIBNEWLIBC_BASE)/syscall.c
# Newlib/libc code -- signal
################################################################################
LIBNEWLIBC_SRCS-y += $(LIBNEWLIB_LIBC)/signal/psignal.c
-LIBNEWLIBC_SRCS-y += $(LIBNEWLIB_LIBC)/signal/raise.c
-LIBNEWLIBC_SRCS-y += $(LIBNEWLIB_LIBC)/signal/signal.c
################################################################################
# Newlib/libc code -- stdio
--- /dev/null
+/* adapted from OSv */
+#ifndef __UK_SIGNAL_H__
+#define __UK_SIGNAL_H__
+
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#define SIG_BLOCK 0
+#define SIG_UNBLOCK 1
+#define SIG_SETMASK 2
+#define SIGHUP 1
+#define SIGINT 2
+#define SIGQUIT 3
+#define SIGILL 4
+#define SIGTRAP 5
+#define SIGABRT 6
+#define SIGIOT SIGABRT
+#define SIGBUS 7
+#define SIGFPE 8
+#define SIGKILL 9
+#define SIGUSR1 10
+#define SIGSEGV 11
+#define SIGUSR2 12
+#define SIGPIPE 13
+#define SIGALRM 14
+#define SIGTERM 15
+#define SIGSTKFLT 16
+#define SIGCHLD 17
+#define SIGCONT 18
+#define SIGSTOP 19
+#define SIGTSTP 20
+#define SIGTTIN 21
+#define SIGTTOU 22
+#define SIGURG 23
+#define SIGXCPU 24
+#define SIGXFSZ 25
+#define SIGVTALRM 26
+#define SIGPROF 27
+#define SIGWINCH 28
+#define SIGIO 29
+#define SIGPOLL 29
+#define SIGPWR 30
+#define SIGSYS 31
+#define SIGUNUSED SIGSYS
+
+#define _NSIG 32
+
+#define SA_NOCLDSTOP 1
+#define SA_NOCLDWAIT 2
+#define SA_SIGINFO 4
+#define SA_ONSTACK 0x08000000
+#define SA_RESTART 0x10000000
+#define SA_NODEFER 0x40000000
+#define SA_RESETHAND 0x80000000
+#define SA_RESTORER 0x04000000
+
+typedef int pid_t;
+typedef int sig_atomic_t;
+typedef unsigned long __sigset_t;
+typedef __sigset_t sigset_t;
+
+#define NSIG _NSIG
+
+typedef struct {
+ int si_signo; /* Signal number */
+ int si_code; /* Cause of the signal */
+ pid_t si_pid; /* Sending process ID */
+} siginfo_t;
+
+struct sigaction {
+ union {
+ void (*sa_handler)(int);
+ void (*sa_sigaction)(int, siginfo_t *, void *);
+ } __sa_handler;
+ sigset_t sa_mask;
+ int sa_flags;
+ void (*sa_restorer)(void);
+};
+#define sa_handler __sa_handler.sa_handler
+#define sa_sigaction __sa_handler.sa_sigaction
+
+#define SIG_ERR ((void (*)(int))-1)
+#define SIG_DFL ((void (*)(int)) 0)
+#define SIG_IGN ((void (*)(int)) 1)
+
+/* TODO: do we have gnu statement expression? */
+#define is_sig_dfl(ptr) \
+ (!((ptr)->sa_flags & SA_SIGINFO) && (ptr)->sa_handler == SIG_DFL)
+
+#define is_sig_ign(ptr) \
+ (!((ptr)->sa_flags & SA_SIGINFO) && (ptr)->sa_handler == SIG_IGN)
+
+int sigaction(int signum, const struct sigaction *act,
+ struct sigaction *oldact);
+
+int sigpending(sigset_t *set);
+int sigprocmask(int how, const sigset_t *set,
+ sigset_t *oldset);
+int sigsuspend(const sigset_t *mask);
+int sigwait(const sigset_t *set, int *sig);
+
+int kill(pid_t pid, int sig);
+int raise(int sig);
+
+typedef void (*sighandler_t)(int);
+sighandler_t signal(int signum, sighandler_t handler);
+
+int pthread_sigmask(int how, const sigset_t *set, sigset_t *oldset);
+int sigemptyset(sigset_t *set);
+int sigfillset(sigset_t *set);
+int sigaddset(sigset_t *set, int signo);
+int sigdelset(sigset_t *set, int signo);
+int sigismember(const sigset_t *set, int signo);
+int siginterrupt(int sig, int flag);
+void psignal(int sig, const char *s);
+
+/* TODO: not used - defined just for newlib */
+union sigval {
+ int sival_int; /* Integer signal value */
+ void *sival_ptr; /* Pointer signal value */
+};
+
+struct sigevent {
+ int sigev_notify; /* Notification type */
+ int sigev_signo; /* Signal number */
+ union sigval sigev_value; /* Signal value */
+};
+
+/* TODO: not used - defined just for v8 */
+typedef struct sigaltstack {
+ void *ss_sp;
+ int ss_flags;
+ size_t ss_size;
+} stack_t;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __UK_SIGNAL_H__ */
return -1;
}
-int sigprocmask(int how __unused, const sigset_t *set __unused,
- sigset_t *oldset __unused)
-{
- /* TODO: implement. */
- errno = ENOTSUP;
- return -1;
-}
-
#include <uk/plat/bootstrap.h>
void abort(void)
+++ /dev/null
-/* SPDX-License-Identifier: BSD-3-Clause */
-/*
- * Authors: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro
- *
- * Copyright (c) 2019, University Politehnica of Bucharest. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holder nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY.
- */
-
-#include <uk/process.h>
-#include <uk/print.h>
-#include <errno.h>
-#include <signal.h>
-
-int sigaction(int sig __unused, const struct sigaction *restrict act __unused,
- struct sigaction *restrict oact __unused)
-{
- return 0;
-}
-
-unsigned int alarm(unsigned int seconds __unused)
-{
- return 0;
-}
-
-int pause(void)
-{
- return 0;
-}
-
-int siginterrupt(int sig __unused, int flag __unused)
-{
- return 0;
-}
-
-int sigsuspend(const sigset_t *mask)
-{
- return 0;
-}
-
-int kill(int pid, int sig __unused)
-{
- /* TODO check sig */
- if (pid != UNIKRAFT_PID)
- errno = ESRCH;
- return -1;
-}
-
-int killpg(int pgrp, int sig __unused)
-{
- /* TODO check sig */
- if (pgrp != UNIKRAFT_PGID)
- errno = ESRCH;
- return -1;
-}
-
-int sigaltstack(const stack_t *ss, stack_t *old_ss)
-{
- WARN_STUBBED();
- errno = ENOTSUP;
- return -1;
-}