From: Michalis Pappas Date: Fri, 26 Jan 2024 02:58:05 +0000 (+0100) Subject: lib/uksignal: Retire libuksignal X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=8842b26cc9b53b3d5c404b3a7509eb9f837e227c;p=unikraft%2Funikraft.git lib/uksignal: Retire libuksignal Retire libuksignal in favor of the new implementation introduced in libposix-process. Stubs of equivalent functionality previously provided in libuksignal are still available in libposix-process, when CONFIG_POSIX_PROCESS_SIGNAL is not selected. Signed-off-by: Michalis Pappas Reviewed-by: Ioan-Teodor Teugea Reviewed-by: Sergiu Moga Reviewed-by: Andrei Tatar Approved-by: Andrei Tatar GitHub-Closes: #1248 --- diff --git a/lib/Makefile.uk b/lib/Makefile.uk index f26eeb762..a59338d77 100644 --- a/lib/Makefile.uk +++ b/lib/Makefile.uk @@ -60,7 +60,6 @@ $(eval $(call import_lib,$(CONFIG_UK_BASE)/lib/ukring)) $(eval $(call import_lib,$(CONFIG_UK_BASE)/lib/uksched)) $(eval $(call import_lib,$(CONFIG_UK_BASE)/lib/ukschedcoop)) $(eval $(call import_lib,$(CONFIG_UK_BASE)/lib/uksglist)) -$(eval $(call import_lib,$(CONFIG_UK_BASE)/lib/uksignal)) $(eval $(call import_lib,$(CONFIG_UK_BASE)/lib/uksp)) $(eval $(call import_lib,$(CONFIG_UK_BASE)/lib/ukstore)) $(eval $(call import_lib,$(CONFIG_UK_BASE)/lib/ukrandom)) diff --git a/lib/uksignal/Config.uk b/lib/uksignal/Config.uk deleted file mode 100644 index 089020fd7..000000000 --- a/lib/uksignal/Config.uk +++ /dev/null @@ -1,8 +0,0 @@ -menuconfig LIBUKSIGNAL - bool "uksignal: Unikraft signals" - default n - select LIBNOLIBC if !HAVE_LIBC - select LIBUKDEBUG - select LIBUKALLOC - select LIBUKSCHED - select LIBPOSIX_PROCESS diff --git a/lib/uksignal/Makefile.uk b/lib/uksignal/Makefile.uk deleted file mode 100644 index da38590f5..000000000 --- a/lib/uksignal/Makefile.uk +++ /dev/null @@ -1,18 +0,0 @@ -$(eval $(call addlib_s,libuksignal,$(CONFIG_LIBUKSIGNAL))) - -CINCLUDES-$(CONFIG_LIBUKSIGNAL) += -I$(LIBUKSIGNAL_BASE)/include -CXXINCLUDES-$(CONFIG_LIBUKSIGNAL) += -I$(LIBUKSIGNAL_BASE)/include - -LIBUKSIGNAL_SRCS-y += $(LIBUKSIGNAL_BASE)/signal.c -LIBUKSIGNAL_SRCS-y += $(LIBUKSIGNAL_BASE)/sigset.c - -UK_PROVIDED_SYSCALLS-$(CONFIG_LIBUKSIGNAL) += sigaltstack-2 -UK_PROVIDED_SYSCALLS-$(CONFIG_LIBUKSIGNAL) += rt_sigaction-4 -UK_PROVIDED_SYSCALLS-$(CONFIG_LIBUKSIGNAL) += rt_sigprocmask-4 -UK_PROVIDED_SYSCALLS-$(CONFIG_LIBUKSIGNAL) += rt_sigpending-2 -UK_PROVIDED_SYSCALLS-$(CONFIG_LIBUKSIGNAL) += rt_sigsuspend-2 -UK_PROVIDED_SYSCALLS-$(CONFIG_LIBUKSIGNAL) += rt_sigtimedwait-4 -UK_PROVIDED_SYSCALLS-$(CONFIG_LIBUKSIGNAL) += kill-2 -UK_PROVIDED_SYSCALLS-$(CONFIG_LIBUKSIGNAL) += tkill-2 -UK_PROVIDED_SYSCALLS-$(CONFIG_LIBUKSIGNAL) += alarm-1 -UK_PROVIDED_SYSCALLS-$(CONFIG_LIBUKSIGNAL) += pause-0 diff --git a/lib/uksignal/README b/lib/uksignal/README deleted file mode 100644 index fe37aaaee..000000000 --- a/lib/uksignal/README +++ /dev/null @@ -1,7 +0,0 @@ -This library just provides stubs for the signal-related functions and syscalls -to allow applications to run that do not dependent on a working signal -implementation. - -This library replaces the previous `uksignal` implementation that is no longer -working with the new scheduling and thread APIs. A new implementation will be -part of a future release. diff --git a/lib/uksignal/exportsyms.uk b/lib/uksignal/exportsyms.uk deleted file mode 100644 index a432a3f66..000000000 --- a/lib/uksignal/exportsyms.uk +++ /dev/null @@ -1,36 +0,0 @@ -# signal.h -sigaltstack - -sigaction -signal -rt_sigaction - -sigprocmask -rt_sigprocmask - -sigsuspend -rt_sigsuspend - -sigpending -rt_sigpending - -sigwait -rt_sigtimedwait - -kill -killpg -tkill - -raise -siginterrupt - -# sigset.h -sigemptyset -sigfillset -sigaddset -sigdelset -sigismember - -# unistd.h -alarm -pause diff --git a/lib/uksignal/ksigaction.h b/lib/uksignal/ksigaction.h deleted file mode 100644 index 199dcdf92..000000000 --- a/lib/uksignal/ksigaction.h +++ /dev/null @@ -1,28 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright (c) 2023, Unikraft GmbH and The Unikraft Authors. - * Licensed under the BSD-3-Clause License (the "License"). - * You may not use this file except in compliance with the License. - */ - -#ifndef __UK_KSIGACTION_H__ -#define __UK_KSIGACTION_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Imported from musl 1.2.3 */ -/* In line with the Linux kernel struct for x86_64 and aarch64. */ - -struct k_sigaction { - void (*handler)(int); - unsigned long flags; - void (*restorer)(void); - unsigned mask[2]; -}; - -#ifdef __cplusplus -} -#endif - -#endif /* __UK_KSIGACTION_H__ */ diff --git a/lib/uksignal/signal.c b/lib/uksignal/signal.c deleted file mode 100644 index fa214eca4..000000000 --- a/lib/uksignal/signal.c +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Copyright (C) 2013 Cloudius Systems, Ltd. - * - * Parts are copyright by other contributors. Please refer to copyright notices - * in the individual source files, and to the git commit log, for a more accurate - * list of copyright holders. - * - * OSv is open-source software, distributed under the 3-clause BSD license: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * 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. - * - * * Neither the name of the Cloudius Systems, Ltd. 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. - */ -/* adapted from OSv */ - -#define _GNU_SOURCE -#include -#include -#include - -#include -#include -#include -#ifndef __NEED_struct_timespec -#define __NEED_struct_timespec -#endif -#include -#include "sigset.h" -#include "ksigaction.h" - -UK_SYSCALL_R_DEFINE(int, sigaltstack, const stack_t *, ss, - stack_t *, old_ss) -{ - return 0; -} - -UK_SYSCALL_R_DEFINE(int, rt_sigaction, int, signum, - const struct k_sigaction *__unused, act, - struct k_sigaction *, oldact, - size_t __unused, sigsetsize) -{ - if (unlikely(signum == SIGKILL || signum == SIGSTOP)) - return -EINVAL; - - if (oldact) - *oldact = (struct k_sigaction){0}; - - return 0; -} - -#if UK_LIBC_SYSCALLS -int sigaction(int signum, const struct sigaction __unused *act, - struct sigaction *oldact) -{ - /* Not actually an implementation of sigaction. - * Do minimal argument matching for the stub syscall. */ - int r; - struct k_sigaction kold; - r = rt_sigaction(signum, NULL, oldact ? &kold : NULL, sizeof(sigset_t)); - if (oldact && !r) { - oldact->sa_handler = kold.handler; - oldact->sa_flags = kold.flags; - } - return r; -} - -sighandler_t signal(int signum, sighandler_t handler) -{ - struct k_sigaction old; - struct k_sigaction act = { - .handler = handler, - .flags = SA_RESTART, /* BSD signal semantics */ - }; - - if (unlikely(rt_sigaction(signum, &act, &old, sizeof(sigset_t)) < 0)) - return SIG_ERR; - - return (old.flags & SA_SIGINFO) ? NULL : old.handler; -} -#endif /* UK_LIBC_SYSCALLS */ - -UK_SYSCALL_R_DEFINE(int, rt_sigpending, - sigset_t *, set, - size_t __unused, sigsetsize) -{ - sigemptyset(set); - - return 0; -} - -#if UK_LIBC_SYSCALLS -int sigpending(sigset_t *set) -{ - return rt_sigpending(set, sizeof(sigset_t)); -} -#endif /* UK_LIBC_SYSCALLS */ - -UK_SYSCALL_R_DEFINE(int, rt_sigprocmask, - int __unused, how, - const sigset_t *__unused, set, - sigset_t *__unused, oldset, - size_t __unused, sigsetsize) -{ - return 0; -} - -#if UK_LIBC_SYSCALLS -int sigprocmask(int how, const sigset_t *set, sigset_t *oldset) -{ - return rt_sigprocmask(how, set, oldset, sizeof(sigset_t)); -} -#endif /* UK_LIBC_SYSCALLS */ - -UK_SYSCALL_R_DEFINE(int, rt_sigsuspend, - const sigset_t *__unused, mask, - size_t __unused, sigsetsize) -{ - return -EINTR; -} - -#if UK_LIBC_SYSCALLS -int sigsuspend(const sigset_t *mask) -{ - return rt_sigsuspend(mask, sizeof(sigset_t)); -} -#endif /* UK_LIBC_SYSCALLS */ - -UK_SYSCALL_R_DEFINE(int, rt_sigtimedwait, - const sigset_t *__unused, set, - siginfo_t *, info, - const struct timespec *__unused, timeout, - size_t __unused, sigsetsize) -{ - *info = (siginfo_t){0}; - info->si_signo = SIGINT; - - return 0; -} - -#if UK_LIBC_SYSCALLS -int sigwait(const sigset_t *set, int *sig) -{ - int error; - siginfo_t si; - - error = rt_sigtimedwait(set, &si, NULL, sizeof(sigset_t)); - *sig = si.si_signo; - - return error; -} -#endif /* UK_LIBC_SYSCALLS */ - -UK_SYSCALL_R_DEFINE(int, tkill, - int __unused, tid, - int __unused, sig) -{ - return 0; -} - -#if UK_LIBC_SYSCALLS -int raise(int sig) -{ - return tkill(-1, sig); -} -#endif /* UK_LIBC_SYSCALLS */ - -UK_SYSCALL_R_DEFINE(int, kill, - pid_t, pid, - int __unused, sig) -{ - if (unlikely(pid != 0)) - return -ESRCH; - - return 0; -} - -#if UK_LIBC_SYSCALLS -int killpg(int pgrp, int sig) -{ - return kill(-pgrp, sig); -} -#endif /* UK_LIBC_SYSCALLS */ - -UK_SYSCALL_R_DEFINE(unsigned int, alarm, - unsigned int __unused, seconds) -{ - return 0; -} - -#if UK_LIBC_SYSCALLS -int siginterrupt(int sig __unused, int flag __unused) -{ - return 0; -} -#endif /* UK_LIBC_SYSCALLS */ - -UK_SYSCALL_R_DEFINE(int, pause) -{ - return 0; -} diff --git a/lib/uksignal/sigset.c b/lib/uksignal/sigset.c deleted file mode 100644 index 033e0b810..000000000 --- a/lib/uksignal/sigset.c +++ /dev/null @@ -1,55 +0,0 @@ -/* taken from newlib */ -#include "sigset.h" - -#include -#include -#include - -#if UK_LIBC_SYSCALLS -int sigemptyset(sigset_t *set) -{ - uk_sigemptyset(set); - return 0; -} - -int sigfillset(sigset_t *set) -{ - uk_sigfillset(set); - return 0; -} - -int sigaddset(sigset_t *set, int signo) -{ - if (signo >= NSIG || signo <= 0) { - errno = EINVAL; - return -1; - } - - uk_sigaddset(set, signo); - return 0; -} - -int sigdelset(sigset_t *set, int signo) -{ - if (signo >= NSIG || signo <= 0) { - errno = EINVAL; - return -1; - } - - uk_sigdelset(set, signo); - return 0; -} - -int sigismember(const sigset_t *set, int signo) -{ - if (signo >= NSIG || signo <= 0) { - errno = EINVAL; - return -1; - } - - if (uk_sigismember(set, signo)) - return 1; - else - return 0; -} -#endif /* UK_LIBC_SYSCALLS */