summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiav A <liavalb@gmail.com>2022-10-04 02:52:43 +0300
committerAndreas Kling <kling@serenityos.org>2022-12-28 11:53:41 +0100
commit92da98822aaf250e9210e5cced982149d0d320d7 (patch)
tree6cf10b174888ae8896911f3bc7c1b65660a2d4a1
parent85b453c2e4301dcabd76074191a27e41d1681e04 (diff)
downloadserenity-92da98822aaf250e9210e5cced982149d0d320d7.zip
LibC: Remove i686 support
-rw-r--r--Kernel/Arch/aarch64/RegisterState.h2
-rw-r--r--Userland/Libraries/LibC/CMakeLists.txt5
-rw-r--r--Userland/Libraries/LibC/arch/i386/crti.S23
-rw-r--r--Userland/Libraries/LibC/arch/i386/crtn.S15
-rw-r--r--Userland/Libraries/LibC/arch/i386/setjmp.S86
-rw-r--r--Userland/Libraries/LibC/math.cpp2
-rw-r--r--Userland/Libraries/LibC/pthread.cpp7
-rw-r--r--Userland/Libraries/LibC/string.cpp30
-rw-r--r--Userland/Libraries/LibC/sys/arch/aarch64/regs.h (renamed from Userland/Libraries/LibC/sys/arch/i386/regs.h)0
-rw-r--r--Userland/Libraries/LibC/sys/arch/regs.h4
-rw-r--r--Userland/Libraries/LibC/sys/arch/x86_64/regs.h4
11 files changed, 9 insertions, 169 deletions
diff --git a/Kernel/Arch/aarch64/RegisterState.h b/Kernel/Arch/aarch64/RegisterState.h
index 2ebd81f69e..92ec666a25 100644
--- a/Kernel/Arch/aarch64/RegisterState.h
+++ b/Kernel/Arch/aarch64/RegisterState.h
@@ -6,7 +6,7 @@
#pragma once
-#include <LibC/sys/arch/i386/regs.h>
+#include <LibC/sys/arch/aarch64/regs.h>
#include <AK/Platform.h>
VALIDATE_IS_AARCH64()
diff --git a/Userland/Libraries/LibC/CMakeLists.txt b/Userland/Libraries/LibC/CMakeLists.txt
index c71cab0a6c..9ef599fa1d 100644
--- a/Userland/Libraries/LibC/CMakeLists.txt
+++ b/Userland/Libraries/LibC/CMakeLists.txt
@@ -84,11 +84,6 @@ if ("${SERENITY_ARCH}" STREQUAL "aarch64")
set(ELF_SOURCES ${ELF_SOURCES} ../LibELF/Arch/aarch64/entry.S ../LibELF/Arch/aarch64/plt_trampoline.S)
set(CRTI_SOURCE "arch/aarch64/crti.S")
set(CRTN_SOURCE "arch/aarch64/crtn.S")
-elseif ("${SERENITY_ARCH}" STREQUAL "i686")
- set(ASM_SOURCES "arch/i386/setjmp.S")
- set(ELF_SOURCES ${ELF_SOURCES} ../LibELF/Arch/i386/entry.S ../LibELF/Arch/i386/plt_trampoline.S)
- set(CRTI_SOURCE "arch/i386/crti.S")
- set(CRTN_SOURCE "arch/i386/crtn.S")
elseif ("${SERENITY_ARCH}" STREQUAL "x86_64")
set(LIBC_SOURCES ${LIBC_SOURCES} "arch/x86_64/memset.cpp")
set(ASM_SOURCES "arch/x86_64/setjmp.S" "arch/x86_64/memset.S")
diff --git a/Userland/Libraries/LibC/arch/i386/crti.S b/Userland/Libraries/LibC/arch/i386/crti.S
deleted file mode 100644
index a5cd2f46c0..0000000000
--- a/Userland/Libraries/LibC/arch/i386/crti.S
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-.section .init, "ax", @progbits
-.align 4
-.global _init
-.type _init, @function
-_init:
- pushl %ebp
- movl %esp, %ebp
- andl $-16, %esp
-
-.section .fini, "ax", @progbits
-.align 4
-.global _fini
-.type _fini, @function
-_fini:
- pushl %ebp
- movl %esp, %ebp
- andl $-16, %esp
diff --git a/Userland/Libraries/LibC/arch/i386/crtn.S b/Userland/Libraries/LibC/arch/i386/crtn.S
deleted file mode 100644
index 1861755c74..0000000000
--- a/Userland/Libraries/LibC/arch/i386/crtn.S
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-.section .init, "ax", @progbits
- movl %ebp, %esp
- popl %ebp
- retl
-
-.section .fini, "ax", @progbits
- movl %ebp, %esp
- popl %ebp
- retl
diff --git a/Userland/Libraries/LibC/arch/i386/setjmp.S b/Userland/Libraries/LibC/arch/i386/setjmp.S
deleted file mode 100644
index dff0361ca4..0000000000
--- a/Userland/Libraries/LibC/arch/i386/setjmp.S
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#include <bits/sighow.h>
-
-//
-// /!\ Read setjmp.h before modifying this file!
-//
-
-.Lget_pc:
- mov (%esp), %ebx
- ret
-
-.global _setjmp
-.global setjmp
-_setjmp:
-setjmp:
- xor %eax, %eax // Grab val argument (hardcoded to zero)
- jmp .Lsigset_common
-
-.global sigsetjmp
-sigsetjmp:
- mov 8(%esp), %eax // Grab val argument
-
-.Lsigset_common:
- mov 4(%esp), %ecx // Grab jmp_buf argument
- mov %eax, 24(%ecx) // Store val into did_save_signal_mask
- movl $0, 28(%ecx) // Clear saved_signal_mask
- test %eax, %eax
- jz .Lsaveregs
-
- push %ebp // Prepare ABI-compliant call to sigprocmask
- mov %esp, %ebp
- push %ebx
- call .Lget_pc // Grab the GOT pointer
- addl $_GLOBAL_OFFSET_TABLE_, %ebx
-
- lea 28(%ecx), %eax // Set argument oldset
- push %eax
- push $0 // Set argument set
- push $0 // Set argument how
- call sigprocmask@plt
- add $12, %esp
- pop %ebx
- pop %ebp
-
-.Lsaveregs:
- mov 4(%esp), %ecx // Grab jmp_buf argument
- mov (%esp), %edx // Grab return address
- mov %ebx, (0 * 4)(%ecx) // Save registers
- mov %esi, (1 * 4)(%ecx)
- mov %edi, (2 * 4)(%ecx)
- mov %ebp, (3 * 4)(%ecx)
- mov %esp, (4 * 4)(%ecx)
- mov %edx, (5 * 4)(%ecx)
- xor %eax, %eax
- ret
-
-.global _longjmp
-.global longjmp
-_longjmp:
-longjmp:
- mov 4(%esp), %ecx // Grab jmp_buf argument
- mov 8(%esp), %eax // Grab val argument
- test %eax, %eax
- jnz .Lnonzero
- mov $1, %eax
-
-.Lnonzero:
- mov (0 * 4)(%ecx), %ebx // Restore registers
- mov (1 * 4)(%ecx), %esi
- mov (2 * 4)(%ecx), %edi
- mov (3 * 4)(%ecx), %ebp
- //
- // Until this point, the stack is still from the caller.
- //
- mov (4 * 4)(%ecx), %esp
- mov (5 * 4)(%ecx), %edx
- mov %edx, (%esp) // Patch return address
- //
- // From this point on, the former stack has been restored.
- //
- ret
diff --git a/Userland/Libraries/LibC/math.cpp b/Userland/Libraries/LibC/math.cpp
index 520a27cc16..1db9f22c0a 100644
--- a/Userland/Libraries/LibC/math.cpp
+++ b/Userland/Libraries/LibC/math.cpp
@@ -633,7 +633,7 @@ long double frexpl(long double x, int* exp) NOEXCEPT
return scalbnl(x, -(*exp));
}
-#if !(ARCH(I386) || ARCH(X86_64))
+#if !(ARCH(X86_64))
double round(double value) NOEXCEPT
{
diff --git a/Userland/Libraries/LibC/pthread.cpp b/Userland/Libraries/LibC/pthread.cpp
index 5af92b2c80..32e7b868c2 100644
--- a/Userland/Libraries/LibC/pthread.cpp
+++ b/Userland/Libraries/LibC/pthread.cpp
@@ -91,12 +91,7 @@ static int create_thread(pthread_t* thread, void* (*entry)(void*), void* argumen
while (((uintptr_t)stack - 16) % 16 != 0)
push_on_stack(nullptr);
-#if ARCH(I386)
- push_on_stack((void*)(uintptr_t)thread_params->stack_size);
- push_on_stack(thread_params->stack_location);
- push_on_stack(argument);
- push_on_stack((void*)entry);
-#elif ARCH(X86_64)
+#if ARCH(X86_64)
thread_params->rdi = (FlatPtr)entry;
thread_params->rsi = (FlatPtr)argument;
thread_params->rdx = (FlatPtr)thread_params->stack_location;
diff --git a/Userland/Libraries/LibC/string.cpp b/Userland/Libraries/LibC/string.cpp
index 37abe6fa30..6f4f8d620f 100644
--- a/Userland/Libraries/LibC/string.cpp
+++ b/Userland/Libraries/LibC/string.cpp
@@ -130,7 +130,7 @@ int timingsafe_memcmp(void const* b1, void const* b2, size_t len)
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/memcpy.html
void* memcpy(void* dest_ptr, void const* src_ptr, size_t n)
{
-#if ARCH(I386) || ARCH(X86_64)
+#if ARCH(X86_64)
void* original_dest = dest_ptr;
asm volatile(
"rep movsb"
@@ -146,34 +146,9 @@ void* memcpy(void* dest_ptr, void const* src_ptr, size_t n)
#endif
}
-#if ARCH(I386)
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/memset.html
-void* memset(void* dest_ptr, int c, size_t n)
-{
- size_t dest = (size_t)dest_ptr;
- // FIXME: Support starting at an unaligned address.
- if (!(dest & 0x3) && n >= 12) {
- size_t size_ts = n / sizeof(size_t);
- size_t expanded_c = explode_byte((u8)c);
- asm volatile(
- "rep stosl\n"
- : "=D"(dest)
- : "D"(dest), "c"(size_ts), "a"(expanded_c)
- : "memory");
- n -= size_ts * sizeof(size_t);
- if (n == 0)
- return dest_ptr;
- }
- asm volatile(
- "rep stosb\n"
- : "=D"(dest), "=c"(n)
- : "0"(dest), "1"(n), "a"(c)
- : "memory");
- return dest_ptr;
-}
-#elif ARCH(X86_64)
// For x86-64, an optimized ASM implementation is found in ./arch/x86_64/memset.S
-#elif ARCH(AARCH64)
+#if ARCH(AARCH64)
void* memset(void* dest_ptr, int c, size_t n)
{
(void)dest_ptr;
@@ -181,6 +156,7 @@ void* memset(void* dest_ptr, int c, size_t n)
(void)n;
TODO_AARCH64();
}
+#elif ARCH(X86_64)
#else
# error Unknown architecture
#endif
diff --git a/Userland/Libraries/LibC/sys/arch/i386/regs.h b/Userland/Libraries/LibC/sys/arch/aarch64/regs.h
index 2d7396b35a..2d7396b35a 100644
--- a/Userland/Libraries/LibC/sys/arch/i386/regs.h
+++ b/Userland/Libraries/LibC/sys/arch/aarch64/regs.h
diff --git a/Userland/Libraries/LibC/sys/arch/regs.h b/Userland/Libraries/LibC/sys/arch/regs.h
index 2dfb0f33eb..69c10d5fe7 100644
--- a/Userland/Libraries/LibC/sys/arch/regs.h
+++ b/Userland/Libraries/LibC/sys/arch/regs.h
@@ -8,8 +8,6 @@
#include <AK/Platform.h>
-#if ARCH(I386)
-# include "i386/regs.h"
-#elif ARCH(X86_64)
+#if ARCH(X86_64)
# include "x86_64/regs.h"
#endif
diff --git a/Userland/Libraries/LibC/sys/arch/x86_64/regs.h b/Userland/Libraries/LibC/sys/arch/x86_64/regs.h
index 849a29624a..aee4ad5b27 100644
--- a/Userland/Libraries/LibC/sys/arch/x86_64/regs.h
+++ b/Userland/Libraries/LibC/sys/arch/x86_64/regs.h
@@ -18,7 +18,7 @@
#ifdef __cplusplus
struct [[gnu::packed]] PtraceRegisters : public __mcontext {
-#if defined(__cplusplus) && defined(__cpp_concepts)
+# if defined(__cplusplus) && defined(__cpp_concepts)
FlatPtr ip() const
{
return rip;
@@ -38,7 +38,7 @@ struct [[gnu::packed]] PtraceRegisters : public __mcontext {
{
rbp = bp;
}
-#endif
+# endif
};
#else