From d48cbe75ef29a9c67c9d176bf58e56ea6448fb9e Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Mon, 21 Oct 2024 20:23:36 +0200 Subject: IMP: Major refactor of header and source files extensions. Signed-off-by: Amlal El Mahrouss --- dev/crt/src/alloca.cc | 9 +++++++ dev/crt/src/alloca.cxx | 9 ------- dev/crt/src/base_exception.cc | 9 +++++++ dev/crt/src/base_exception.cxx | 9 ------- dev/crt/src/hal/x86/base_alloc.cc | 55 ++++++++++++++++++++++++++++++++++++++ dev/crt/src/hal/x86/base_alloc.cxx | 55 -------------------------------------- dev/crt/src/hal/x86/exit.cc | 19 +++++++++++++ dev/crt/src/hal/x86/exit.cxx | 19 ------------- 8 files changed, 92 insertions(+), 92 deletions(-) create mode 100644 dev/crt/src/alloca.cc delete mode 100644 dev/crt/src/alloca.cxx create mode 100644 dev/crt/src/base_exception.cc delete mode 100644 dev/crt/src/base_exception.cxx create mode 100644 dev/crt/src/hal/x86/base_alloc.cc delete mode 100644 dev/crt/src/hal/x86/base_alloc.cxx create mode 100644 dev/crt/src/hal/x86/exit.cc delete mode 100644 dev/crt/src/hal/x86/exit.cxx (limited to 'dev/crt/src') diff --git a/dev/crt/src/alloca.cc b/dev/crt/src/alloca.cc new file mode 100644 index 00000000..ccee07a7 --- /dev/null +++ b/dev/crt/src/alloca.cc @@ -0,0 +1,9 @@ +/* ------------------------------------------- + + Copyright ZKA Web Services Co. + +------------------------------------------- */ + +#include + +/// @note Just here for building. diff --git a/dev/crt/src/alloca.cxx b/dev/crt/src/alloca.cxx deleted file mode 100644 index 042eb769..00000000 --- a/dev/crt/src/alloca.cxx +++ /dev/null @@ -1,9 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Web Services Co. - -------------------------------------------- */ - -#include - -/// @note Just here for building. diff --git a/dev/crt/src/base_exception.cc b/dev/crt/src/base_exception.cc new file mode 100644 index 00000000..75699f64 --- /dev/null +++ b/dev/crt/src/base_exception.cc @@ -0,0 +1,9 @@ +/* ------------------------------------------- + + Copyright ZKA Web Services Co. + +------------------------------------------- */ + +#include + +/// @note Just here for building. diff --git a/dev/crt/src/base_exception.cxx b/dev/crt/src/base_exception.cxx deleted file mode 100644 index f82d610a..00000000 --- a/dev/crt/src/base_exception.cxx +++ /dev/null @@ -1,9 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Web Services Co. - -------------------------------------------- */ - -#include - -/// @note Just here for building. diff --git a/dev/crt/src/hal/x86/base_alloc.cc b/dev/crt/src/hal/x86/base_alloc.cc new file mode 100644 index 00000000..10690d4b --- /dev/null +++ b/dev/crt/src/hal/x86/base_alloc.cc @@ -0,0 +1,55 @@ +/* ------------------------------------------- + + Copyright ZKA Web Services Co. + +------------------------------------------- */ + +#include +#include + +#define kAllocSyscallId "mov $10, %%r9\n\t" +#define kFreeSyscallId "mov $11, %%r9\n\t" + +void* operator new(size_t length) +{ + void* ptr = nullptr; + + // do syscall according to PEF convention. + asm("mov %0, %%r8\n\t" kAllocSyscallId + "syscall" + : "=r"(ptr)); + + if (!ptr) + std::__throw_bad_alloc(); + + return ptr; +} + +void* operator new[](size_t length) +{ + ptr_type ptr = nullptr; + + // do syscall according to PEF convention. + asm("mov %0, %%r8\n\t" kAllocSyscallId + "syscall" + : "=r"(ptr)); + + if (!ptr) + std::__throw_bad_alloc(); + + return ptr; +} + +void operator delete(void* ptr) noexcept +{ + asm("mov %0, %%r8\n\t" kFreeSyscallId + "syscall" + : "=r"(ptr)); +} + +void operator delete[](void* ptr) noexcept +{ + asm("mov %0, %%r8\n\t" kFreeSyscallId + "syscall" + : "=r"(ptr)); +} diff --git a/dev/crt/src/hal/x86/base_alloc.cxx b/dev/crt/src/hal/x86/base_alloc.cxx deleted file mode 100644 index 55a53c9d..00000000 --- a/dev/crt/src/hal/x86/base_alloc.cxx +++ /dev/null @@ -1,55 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Web Services Co. - -------------------------------------------- */ - -#include -#include - -#define kAllocSyscallId "mov $10, %%r9\n\t" -#define kFreeSyscallId "mov $11, %%r9\n\t" - -void* operator new(size_t length) -{ - void* ptr = nullptr; - - // do syscall according to PEF convention. - asm("mov %0, %%r8\n\t" kAllocSyscallId - "syscall" - : "=r"(ptr)); - - if (!ptr) - std::__throw_bad_alloc(); - - return ptr; -} - -void* operator new[](size_t length) -{ - ptr_type ptr = nullptr; - - // do syscall according to PEF convention. - asm("mov %0, %%r8\n\t" kAllocSyscallId - "syscall" - : "=r"(ptr)); - - if (!ptr) - std::__throw_bad_alloc(); - - return ptr; -} - -void operator delete(void* ptr) noexcept -{ - asm("mov %0, %%r8\n\t" kFreeSyscallId - "syscall" - : "=r"(ptr)); -} - -void operator delete[](void* ptr) noexcept -{ - asm("mov %0, %%r8\n\t" kFreeSyscallId - "syscall" - : "=r"(ptr)); -} diff --git a/dev/crt/src/hal/x86/exit.cc b/dev/crt/src/hal/x86/exit.cc new file mode 100644 index 00000000..8ee6744b --- /dev/null +++ b/dev/crt/src/hal/x86/exit.cc @@ -0,0 +1,19 @@ +/* ------------------------------------------- + + Copyright ZKA Web Services Co. + +------------------------------------------- */ + +#include + +#define kAllocSyscallId "mov $12, %%r9\n\t" + +/// @note Just here for building. +extern "C" int exit(int code) +{ + asm("mov 0, %%r8\n\t" kAllocSyscallId + "syscall" + : "=r"(code)); + + return 1; +} diff --git a/dev/crt/src/hal/x86/exit.cxx b/dev/crt/src/hal/x86/exit.cxx deleted file mode 100644 index c44c07a4..00000000 --- a/dev/crt/src/hal/x86/exit.cxx +++ /dev/null @@ -1,19 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Web Services Co. - -------------------------------------------- */ - -#include - -#define kAllocSyscallId "mov $12, %%r9\n\t" - -/// @note Just here for building. -extern "C" int exit(int code) -{ - asm("mov 0, %%r8\n\t" kAllocSyscallId - "syscall" - : "=r"(code)); - - return 1; -} -- cgit v1.2.3