summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibSystem
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-11-23 10:59:50 +0100
committerAndreas Kling <kling@serenityos.org>2021-11-23 11:33:36 +0100
commit21a5fb0fa21a92030f68bc6e9df6a9e438355f11 (patch)
tree9883ba94b650d2a6fd97f38942ba40ac3da35694 /Userland/Libraries/LibSystem
parentacc2eccede491e0c34d718e348d76c13c190347c (diff)
downloadserenity-21a5fb0fa21a92030f68bc6e9df6a9e438355f11.zip
LibCore+LibSystem: Move syscall wrappers from LibSystem to LibCore
With this change, System::foo() becomes Core::System::foo(). Since LibCore builds on other systems than SerenityOS, we now have to make sure that wrappers work with just a standard C library underneath.
Diffstat (limited to 'Userland/Libraries/LibSystem')
-rw-r--r--Userland/Libraries/LibSystem/CMakeLists.txt6
-rw-r--r--Userland/Libraries/LibSystem/Wrappers.cpp51
-rw-r--r--Userland/Libraries/LibSystem/Wrappers.h20
3 files changed, 0 insertions, 77 deletions
diff --git a/Userland/Libraries/LibSystem/CMakeLists.txt b/Userland/Libraries/LibSystem/CMakeLists.txt
index a376338226..61ffa0622f 100644
--- a/Userland/Libraries/LibSystem/CMakeLists.txt
+++ b/Userland/Libraries/LibSystem/CMakeLists.txt
@@ -1,13 +1,7 @@
set(SOURCES
- Wrappers.cpp
syscall.cpp
)
-# FIXME: This is a hack to avoid a circular dependency with LibC. Figure out a better way.
-if ("${SERENITY_ARCH}" STREQUAL "i686")
- set_source_files_properties(${SOURCES} PROPERTIES COMPILE_FLAGS "-fno-stack-protector")
-endif()
-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -nostdlib")
serenity_libc(LibSystem system)
target_include_directories(LibSystem PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
diff --git a/Userland/Libraries/LibSystem/Wrappers.cpp b/Userland/Libraries/LibSystem/Wrappers.cpp
deleted file mode 100644
index 0cade18695..0000000000
--- a/Userland/Libraries/LibSystem/Wrappers.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#include <LibSystem/Wrappers.h>
-#include <LibSystem/syscall.h>
-
-#define HANDLE_SYSCALL_RETURN_VALUE(syscall_name, rc, success_value) \
- if ((rc) < 0) { \
- return Error::from_syscall(syscall_name, rc); \
- } \
- return success_value;
-
-namespace System {
-
-ErrorOr<void> pledge(StringView promises, StringView execpromises)
-{
- Syscall::SC_pledge_params params {
- { promises.characters_without_null_termination(), promises.length() },
- { execpromises.characters_without_null_termination(), execpromises.length() },
- };
- int rc = syscall(SC_pledge, &params);
- HANDLE_SYSCALL_RETURN_VALUE("pledge"sv, rc, {});
-}
-
-ErrorOr<void> unveil(StringView path, StringView permissions)
-{
- Syscall::SC_unveil_params params {
- { path.characters_without_null_termination(), path.length() },
- { permissions.characters_without_null_termination(), permissions.length() },
- };
- int rc = syscall(SC_unveil, &params);
- HANDLE_SYSCALL_RETURN_VALUE("unveil"sv, rc, {});
-}
-
-ErrorOr<void> sigaction(int signal, struct sigaction const* action, struct sigaction* old_action)
-{
- int rc = syscall(SC_sigaction, signal, action, old_action);
- HANDLE_SYSCALL_RETURN_VALUE("sigaction"sv, rc, {});
-}
-
-ErrorOr<struct stat> fstat(int fd)
-{
- struct stat st;
- int rc = syscall(SC_fstat, fd, &st);
- HANDLE_SYSCALL_RETURN_VALUE("fstat"sv, rc, st);
-}
-
-}
diff --git a/Userland/Libraries/LibSystem/Wrappers.h b/Userland/Libraries/LibSystem/Wrappers.h
deleted file mode 100644
index 751d598334..0000000000
--- a/Userland/Libraries/LibSystem/Wrappers.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#pragma once
-
-#include <AK/Error.h>
-#include <signal.h>
-#include <sys/stat.h>
-
-namespace System {
-
-ErrorOr<void> pledge(StringView promises, StringView execpromises);
-ErrorOr<void> unveil(StringView path, StringView permissions);
-ErrorOr<void> sigaction(int signal, struct sigaction const* action, struct sigaction* old_action);
-ErrorOr<struct stat> fstat(int fd);
-
-}