diff --git a/CMakeLists.txt b/CMakeLists.txt index 56501c6fe46..d8a033513f1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -140,6 +140,7 @@ add_link_options(--sysroot ${CMAKE_BINARY_DIR}/Root) include_directories(Userland/Libraries/LibC) include_directories(Userland/Libraries/LibM) +include_directories(Userland/Libraries/LibSystem) include_directories(Userland/Services) include_directories(Userland) include_directories(${CMAKE_CURRENT_BINARY_DIR}) diff --git a/Kernel/API/Syscall.h b/Kernel/API/Syscall.h index 5de5ecb6697..984405b84b4 100644 --- a/Kernel/API/Syscall.h +++ b/Kernel/API/Syscall.h @@ -504,7 +504,6 @@ inline uintptr_t invoke(Function function, T1 arg1, T2 arg2, T3 arg3) #define __ENUMERATE_SYSCALL(x) using Syscall::SC_##x; ENUMERATE_SYSCALLS(__ENUMERATE_SYSCALL) #undef __ENUMERATE_SYSCALL -#define syscall Syscall::invoke } diff --git a/Userland/DevTools/UserspaceEmulator/Emulator.cpp b/Userland/DevTools/UserspaceEmulator/Emulator.cpp index ef72f6d04af..bc5544805c6 100644 --- a/Userland/DevTools/UserspaceEmulator/Emulator.cpp +++ b/Userland/DevTools/UserspaceEmulator/Emulator.cpp @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include @@ -53,6 +52,7 @@ #include #include #include +#include #include #include diff --git a/Userland/DynamicLoader/CMakeLists.txt b/Userland/DynamicLoader/CMakeLists.txt index e96b2b4ef4e..019b7eaf898 100644 --- a/Userland/DynamicLoader/CMakeLists.txt +++ b/Userland/DynamicLoader/CMakeLists.txt @@ -10,11 +10,12 @@ set(ELF_SOURCES ${ELF_SOURCES} ../Libraries/LibELF/Arch/i386/plt_trampoline.S) file(GLOB LIBC_SOURCES1 "../Libraries/LibC/*.cpp") file(GLOB LIBC_SOURCES2 "../Libraries/LibC/*/*.cpp") file(GLOB LIBC_SOURCES3 "../Libraries/LibC/*.S") +file(GLOB LIBSYSTEM_SOURCES "../Libraries/LibSystem/*.cpp") list(FILTER LIBC_SOURCES1 EXCLUDE REGEX ".+crt0.cpp") list(FILTER LIBC_SOURCES1 EXCLUDE REGEX ".+crt0.+.cpp") -set(SOURCES ${LOADER_SOURCES} ${AK_SOURCES} ${ELF_SOURCES} ${LIBC_SOURCES1} ${LIBC_SOURCES2} ${LIBC_SOURCES3}) +set(SOURCES ${LOADER_SOURCES} ${AK_SOURCES} ${ELF_SOURCES} ${LIBC_SOURCES1} ${LIBC_SOURCES2} ${LIBC_SOURCES3} ${LIBSYSTEM_SOURCES}) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -nostdlib -pie -fpic -DNO_TLS") diff --git a/Userland/Libraries/CMakeLists.txt b/Userland/Libraries/CMakeLists.txt index 9e54e781563..ed30460a486 100644 --- a/Userland/Libraries/CMakeLists.txt +++ b/Userland/Libraries/CMakeLists.txt @@ -27,6 +27,7 @@ add_subdirectory(LibProtocol) add_subdirectory(LibPthread) add_subdirectory(LibRegex) add_subdirectory(LibSymbolClient) +add_subdirectory(LibSystem) add_subdirectory(LibTar) add_subdirectory(LibTextCodec) add_subdirectory(LibThread) diff --git a/Userland/Libraries/LibC/CMakeLists.txt b/Userland/Libraries/LibC/CMakeLists.txt index 393addb934a..cab661dcb6f 100644 --- a/Userland/Libraries/LibC/CMakeLists.txt +++ b/Userland/Libraries/LibC/CMakeLists.txt @@ -81,10 +81,10 @@ add_custom_command( set(SOURCES ${LIBC_SOURCES} ${AK_SOURCES} ${ELF_SOURCES}) serenity_libc_static(LibCStatic c) -target_link_libraries(LibCStatic crt0 ssp) -add_dependencies(LibCStatic LibM) +target_link_libraries(LibCStatic crt0 ssp system) +add_dependencies(LibCStatic LibM LibSystem) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libstdc++") serenity_libc(LibC c) -target_link_libraries(LibC crt0 ssp) -add_dependencies(LibC LibM) +target_link_libraries(LibC crt0 ssp system) +add_dependencies(LibC LibM LibSystem) diff --git a/Userland/Libraries/LibC/assert.cpp b/Userland/Libraries/LibC/assert.cpp index 7dcd7a52589..ad9c6837d28 100644 --- a/Userland/Libraries/LibC/assert.cpp +++ b/Userland/Libraries/LibC/assert.cpp @@ -24,12 +24,12 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include #include #include #include #include #include +#include #include extern "C" { diff --git a/Userland/Libraries/LibC/dirent.cpp b/Userland/Libraries/LibC/dirent.cpp index 8e9701177d5..504fa703673 100644 --- a/Userland/Libraries/LibC/dirent.cpp +++ b/Userland/Libraries/LibC/dirent.cpp @@ -26,7 +26,6 @@ #include #include -#include #include #include #include @@ -34,6 +33,7 @@ #include #include #include +#include #include extern "C" { diff --git a/Userland/Libraries/LibC/fcntl.cpp b/Userland/Libraries/LibC/fcntl.cpp index 7790bec1136..3bd873dff75 100644 --- a/Userland/Libraries/LibC/fcntl.cpp +++ b/Userland/Libraries/LibC/fcntl.cpp @@ -24,11 +24,11 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include #include #include #include #include +#include extern "C" { diff --git a/Userland/Libraries/LibC/ioctl.cpp b/Userland/Libraries/LibC/ioctl.cpp index c5fee3951e7..280c4d53784 100644 --- a/Userland/Libraries/LibC/ioctl.cpp +++ b/Userland/Libraries/LibC/ioctl.cpp @@ -24,11 +24,11 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include #include #include #include #include +#include extern "C" { diff --git a/Userland/Libraries/LibC/mman.cpp b/Userland/Libraries/LibC/mman.cpp index b3346d2e1f3..0f01395ab56 100644 --- a/Userland/Libraries/LibC/mman.cpp +++ b/Userland/Libraries/LibC/mman.cpp @@ -24,11 +24,11 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include #include #include #include #include +#include extern "C" { diff --git a/Userland/Libraries/LibC/poll.cpp b/Userland/Libraries/LibC/poll.cpp index 437ea8243ad..5695ff13181 100644 --- a/Userland/Libraries/LibC/poll.cpp +++ b/Userland/Libraries/LibC/poll.cpp @@ -24,10 +24,10 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include #include #include #include +#include extern "C" { diff --git a/Userland/Libraries/LibC/sched.cpp b/Userland/Libraries/LibC/sched.cpp index 4e3643bd01b..d5139cb1c5a 100644 --- a/Userland/Libraries/LibC/sched.cpp +++ b/Userland/Libraries/LibC/sched.cpp @@ -24,9 +24,9 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include #include #include +#include extern "C" { diff --git a/Userland/Libraries/LibC/serenity.cpp b/Userland/Libraries/LibC/serenity.cpp index 319975c6530..8899a2b7df7 100644 --- a/Userland/Libraries/LibC/serenity.cpp +++ b/Userland/Libraries/LibC/serenity.cpp @@ -24,10 +24,10 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include #include #include #include +#include extern "C" { diff --git a/Userland/Libraries/LibC/serenity.h b/Userland/Libraries/LibC/serenity.h index 70ddf295af7..8860e89d14f 100644 --- a/Userland/Libraries/LibC/serenity.h +++ b/Userland/Libraries/LibC/serenity.h @@ -106,8 +106,8 @@ int anon_create(size_t size, int options); int serenity_readlink(const char* path, size_t path_length, char* buffer, size_t buffer_size); -int getkeymap(char* name_buffer, size_t name_buffer_size, u32* map, u32* shift_map, u32* alt_map, u32* altgr_map, u32* shift_altgr_map); -int setkeymap(const char* name, const u32* map, u32* const shift_map, const u32* alt_map, const u32* altgr_map, const u32* shift_altgr_map); +int getkeymap(char* name_buffer, size_t name_buffer_size, uint32_t* map, uint32_t* shift_map, uint32_t* alt_map, uint32_t* altgr_map, uint32_t* shift_altgr_map); +int setkeymap(const char* name, const uint32_t* map, uint32_t* const shift_map, const uint32_t* alt_map, const uint32_t* altgr_map, const uint32_t* shift_altgr_map); #ifdef __i386__ ALWAYS_INLINE void send_secret_data_to_userspace_emulator(uintptr_t data1, uintptr_t data2, uintptr_t data3) diff --git a/Userland/Libraries/LibC/signal.cpp b/Userland/Libraries/LibC/signal.cpp index 55da42a04d3..cea5e149f49 100644 --- a/Userland/Libraries/LibC/signal.cpp +++ b/Userland/Libraries/LibC/signal.cpp @@ -25,12 +25,12 @@ */ #include -#include #include #include #include #include #include +#include #include extern "C" { diff --git a/Userland/Libraries/LibC/stat.cpp b/Userland/Libraries/LibC/stat.cpp index 5de2472dfa7..16bee73b9aa 100644 --- a/Userland/Libraries/LibC/stat.cpp +++ b/Userland/Libraries/LibC/stat.cpp @@ -24,12 +24,12 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include #include #include #include #include #include +#include #include extern "C" { diff --git a/Userland/Libraries/LibC/stdio.cpp b/Userland/Libraries/LibC/stdio.cpp index f96f4732ad9..c1a8bca79f7 100644 --- a/Userland/Libraries/LibC/stdio.cpp +++ b/Userland/Libraries/LibC/stdio.cpp @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -41,6 +40,7 @@ #include #include #include +#include #include struct FILE { diff --git a/Userland/Libraries/LibC/stdlib.cpp b/Userland/Libraries/LibC/stdlib.cpp index 8a0dc247d01..56f1070e760 100644 --- a/Userland/Libraries/LibC/stdlib.cpp +++ b/Userland/Libraries/LibC/stdlib.cpp @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -45,6 +44,7 @@ #include #include #include +#include #include static void strtons(const char* str, char** endptr) diff --git a/Userland/Libraries/LibC/sys/prctl.cpp b/Userland/Libraries/LibC/sys/prctl.cpp index d7aa35486b3..dbc4b53063f 100644 --- a/Userland/Libraries/LibC/sys/prctl.cpp +++ b/Userland/Libraries/LibC/sys/prctl.cpp @@ -24,11 +24,11 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include #include #include #include #include +#include extern "C" { diff --git a/Userland/Libraries/LibC/sys/ptrace.cpp b/Userland/Libraries/LibC/sys/ptrace.cpp index 9e7eb60c2af..f285ef5bb58 100644 --- a/Userland/Libraries/LibC/sys/ptrace.cpp +++ b/Userland/Libraries/LibC/sys/ptrace.cpp @@ -25,9 +25,9 @@ */ #include -#include #include #include +#include extern "C" { diff --git a/Userland/Libraries/LibC/sys/select.cpp b/Userland/Libraries/LibC/sys/select.cpp index 85c5b03d43b..dfc039d12af 100644 --- a/Userland/Libraries/LibC/sys/select.cpp +++ b/Userland/Libraries/LibC/sys/select.cpp @@ -24,11 +24,11 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include #include #include #include #include +#include extern "C" { diff --git a/Userland/Libraries/LibC/sys/socket.cpp b/Userland/Libraries/LibC/sys/socket.cpp index 95d2a015a7c..a545e00021a 100644 --- a/Userland/Libraries/LibC/sys/socket.cpp +++ b/Userland/Libraries/LibC/sys/socket.cpp @@ -25,12 +25,12 @@ */ #include -#include #include #include #include #include #include +#include extern "C" { diff --git a/Userland/Libraries/LibC/sys/uio.cpp b/Userland/Libraries/LibC/sys/uio.cpp index 4aad828c65f..2fd6c94fe92 100644 --- a/Userland/Libraries/LibC/sys/uio.cpp +++ b/Userland/Libraries/LibC/sys/uio.cpp @@ -24,9 +24,9 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include #include #include +#include extern "C" { diff --git a/Userland/Libraries/LibC/sys/wait.cpp b/Userland/Libraries/LibC/sys/wait.cpp index 9969a8eec29..2cde5e28219 100644 --- a/Userland/Libraries/LibC/sys/wait.cpp +++ b/Userland/Libraries/LibC/sys/wait.cpp @@ -24,9 +24,9 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include #include #include +#include #include extern "C" { diff --git a/Userland/Libraries/LibC/termios.cpp b/Userland/Libraries/LibC/termios.cpp index 1037b0ab617..c1c4238b5c0 100644 --- a/Userland/Libraries/LibC/termios.cpp +++ b/Userland/Libraries/LibC/termios.cpp @@ -24,7 +24,6 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include #include #include #include diff --git a/Userland/Libraries/LibC/time.cpp b/Userland/Libraries/LibC/time.cpp index e6e9f06c660..df7010c646e 100644 --- a/Userland/Libraries/LibC/time.cpp +++ b/Userland/Libraries/LibC/time.cpp @@ -27,13 +27,13 @@ #include #include #include -#include #include #include #include #include #include #include +#include #include extern "C" { diff --git a/Userland/Libraries/LibC/times.cpp b/Userland/Libraries/LibC/times.cpp index 012dfc7d700..78400a62940 100644 --- a/Userland/Libraries/LibC/times.cpp +++ b/Userland/Libraries/LibC/times.cpp @@ -24,9 +24,9 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include #include #include +#include clock_t times(struct tms* buf) { diff --git a/Userland/Libraries/LibC/unistd.cpp b/Userland/Libraries/LibC/unistd.cpp index b87220f25d6..40544d56f0c 100644 --- a/Userland/Libraries/LibC/unistd.cpp +++ b/Userland/Libraries/LibC/unistd.cpp @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -42,6 +41,7 @@ #include #include #include +#include #include #include #include diff --git a/Userland/Libraries/LibC/utime.cpp b/Userland/Libraries/LibC/utime.cpp index 501d7f06c26..a75908d80a9 100644 --- a/Userland/Libraries/LibC/utime.cpp +++ b/Userland/Libraries/LibC/utime.cpp @@ -24,9 +24,9 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include #include #include +#include #include extern "C" { diff --git a/Userland/Libraries/LibC/utsname.cpp b/Userland/Libraries/LibC/utsname.cpp index 23d10ee7e96..c0b9484f1f5 100644 --- a/Userland/Libraries/LibC/utsname.cpp +++ b/Userland/Libraries/LibC/utsname.cpp @@ -24,9 +24,9 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include #include #include +#include extern "C" { diff --git a/Userland/Libraries/LibCore/AnonymousBuffer.cpp b/Userland/Libraries/LibCore/AnonymousBuffer.cpp index 40853ff7324..8f6b1bedad9 100644 --- a/Userland/Libraries/LibCore/AnonymousBuffer.cpp +++ b/Userland/Libraries/LibCore/AnonymousBuffer.cpp @@ -33,7 +33,6 @@ #include #if defined(__serenity__) -# include # include #endif diff --git a/Userland/Libraries/LibCore/File.cpp b/Userland/Libraries/LibCore/File.cpp index 44ba8d41d79..38da00fb81f 100644 --- a/Userland/Libraries/LibCore/File.cpp +++ b/Userland/Libraries/LibCore/File.cpp @@ -25,7 +25,6 @@ */ #ifdef __serenity__ -# include # include #endif #include diff --git a/Userland/Libraries/LibELF/DynamicLinker.cpp b/Userland/Libraries/LibELF/DynamicLinker.cpp index dd2f61a4ef2..92b790eb545 100644 --- a/Userland/Libraries/LibELF/DynamicLinker.cpp +++ b/Userland/Libraries/LibELF/DynamicLinker.cpp @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include @@ -45,6 +44,7 @@ #include #include #include +#include namespace ELF { @@ -216,7 +216,7 @@ static NonnullRefPtr commit_elf(const String& name) auto object = loader->load_stage_3(RTLD_GLOBAL | RTLD_LAZY, g_total_tls_size); ASSERT(object); - if (name.is_one_of("libc.so", "libpthread.so", "/bin/UserspaceEmulator")) { + if (name == "libsystem.so") { if (syscall(SC_msyscall, object->base_address().as_ptr())) { ASSERT_NOT_REACHED(); } diff --git a/Userland/Libraries/LibKeyboard/CharacterMap.cpp b/Userland/Libraries/LibKeyboard/CharacterMap.cpp index 011a935ffc6..cf5771d67fa 100644 --- a/Userland/Libraries/LibKeyboard/CharacterMap.cpp +++ b/Userland/Libraries/LibKeyboard/CharacterMap.cpp @@ -26,7 +26,6 @@ #include "CharacterMap.h" #include -#include #include #ifndef KERNEL diff --git a/Userland/Libraries/LibPthread/CMakeLists.txt b/Userland/Libraries/LibPthread/CMakeLists.txt index c8644e08687..c28f072b5e1 100644 --- a/Userland/Libraries/LibPthread/CMakeLists.txt +++ b/Userland/Libraries/LibPthread/CMakeLists.txt @@ -4,5 +4,5 @@ set(SOURCES ) serenity_libc(LibPthread pthread) -target_link_libraries(LibPthread LibC) +target_link_libraries(LibPthread LibC LibSystem) target_include_directories(LibPthread PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/Userland/Libraries/LibPthread/pthread.cpp b/Userland/Libraries/LibPthread/pthread.cpp index b366b773b55..b4b5240efa5 100644 --- a/Userland/Libraries/LibPthread/pthread.cpp +++ b/Userland/Libraries/LibPthread/pthread.cpp @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -36,6 +35,7 @@ #include #include #include +#include #include #include diff --git a/Userland/Libraries/LibSystem/CMakeLists.txt b/Userland/Libraries/LibSystem/CMakeLists.txt new file mode 100644 index 00000000000..f93dbe2c9b6 --- /dev/null +++ b/Userland/Libraries/LibSystem/CMakeLists.txt @@ -0,0 +1,7 @@ +set(SOURCES + syscall.cpp +) + +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/syscall.cpp b/Userland/Libraries/LibSystem/syscall.cpp new file mode 100644 index 00000000000..081d3709e77 --- /dev/null +++ b/Userland/Libraries/LibSystem/syscall.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2021, Andreas Kling + * 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. + * + * 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. + */ + +#include +#include + +extern "C" { + +uintptr_t syscall0(uintptr_t function) +{ + return Syscall::invoke((Syscall::Function)function); +} + +uintptr_t syscall1(uintptr_t function, uintptr_t arg0) +{ + return Syscall::invoke((Syscall::Function)function, arg0); +} + +uintptr_t syscall2(uintptr_t function, uintptr_t arg0, uintptr_t arg1) +{ + return Syscall::invoke((Syscall::Function)function, arg0, arg1); +} + +uintptr_t syscall3(uintptr_t function, uintptr_t arg0, uintptr_t arg1, uintptr_t arg2) +{ + return Syscall::invoke((Syscall::Function)function, arg0, arg1, arg2); +} +} diff --git a/Userland/Libraries/LibSystem/syscall.h b/Userland/Libraries/LibSystem/syscall.h new file mode 100644 index 00000000000..68aea022587 --- /dev/null +++ b/Userland/Libraries/LibSystem/syscall.h @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2021, Andreas Kling + * 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. + * + * 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. + */ + +#pragma once + +#include +#include + +extern "C" { + +uintptr_t syscall0(uintptr_t function); +uintptr_t syscall1(uintptr_t function, uintptr_t arg0); +uintptr_t syscall2(uintptr_t function, uintptr_t arg0, uintptr_t arg1); +uintptr_t syscall3(uintptr_t function, uintptr_t arg0, uintptr_t arg1, uintptr_t arg2); +} + +#ifdef __cplusplus + +inline uintptr_t syscall(auto function) +{ + return syscall0(function); +} + +inline uintptr_t syscall(auto function, auto arg0) +{ + return syscall1((uintptr_t)function, (uintptr_t)arg0); +} + +inline uintptr_t syscall(auto function, auto arg0, auto arg1) +{ + return syscall2((uintptr_t)function, (uintptr_t)arg0, (uintptr_t)arg1); +} + +inline uintptr_t syscall(auto function, auto arg0, auto arg1, auto arg2) +{ + return syscall3((uintptr_t)function, (uintptr_t)arg0, (uintptr_t)arg1, (uintptr_t)arg2); +} + +#endif diff --git a/Userland/Tests/Kernel/invalid-any-pointer-assert.cpp b/Userland/Tests/Kernel/invalid-any-pointer-assert.cpp index afdd539e736..0491b79c910 100644 --- a/Userland/Tests/Kernel/invalid-any-pointer-assert.cpp +++ b/Userland/Tests/Kernel/invalid-any-pointer-assert.cpp @@ -25,9 +25,9 @@ */ #include -#include #include #include +#include int main() { diff --git a/Userland/Tests/Kernel/invalid-path-pointer-assert.cpp b/Userland/Tests/Kernel/invalid-path-pointer-assert.cpp index fe503753d11..85001f8dd6d 100644 --- a/Userland/Tests/Kernel/invalid-path-pointer-assert.cpp +++ b/Userland/Tests/Kernel/invalid-path-pointer-assert.cpp @@ -24,10 +24,10 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include #include #include #include +#include int main() { diff --git a/Userland/Utilities/crash.cpp b/Userland/Utilities/crash.cpp index 7e96360ddf3..188eb690aaa 100644 --- a/Userland/Utilities/crash.cpp +++ b/Userland/Utilities/crash.cpp @@ -27,13 +27,13 @@ #include #include -#include #include #include #include #include #include #include +#include #pragma GCC optimize("O0") diff --git a/Userland/Utilities/functrace.cpp b/Userland/Utilities/functrace.cpp index dcb2d046b32..01059090f95 100644 --- a/Userland/Utilities/functrace.cpp +++ b/Userland/Utilities/functrace.cpp @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include @@ -45,6 +44,7 @@ #include #include #include +#include #include static OwnPtr g_debug_session; diff --git a/Userland/Utilities/purge.cpp b/Userland/Utilities/purge.cpp index 95257ec563f..efd3e7a4868 100644 --- a/Userland/Utilities/purge.cpp +++ b/Userland/Utilities/purge.cpp @@ -24,7 +24,6 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include #include #include #include diff --git a/Userland/Utilities/strace.cpp b/Userland/Utilities/strace.cpp index e915e7d3f2f..64d005cfbbd 100644 --- a/Userland/Utilities/strace.cpp +++ b/Userland/Utilities/strace.cpp @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -37,6 +36,7 @@ #include #include #include +#include #include static int g_pid = -1; diff --git a/Userland/Utilities/syscall.cpp b/Userland/Utilities/syscall.cpp index fcb7862e3c4..d80692ffec7 100644 --- a/Userland/Utilities/syscall.cpp +++ b/Userland/Utilities/syscall.cpp @@ -24,13 +24,13 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include #include #include #include #include #include #include +#include #include #if !defined __ENUMERATE_SYSCALL