diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index e684f0a..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "contrib/jemalloc"] - path = contrib/jemalloc - url = https://github.com/jemalloc/jemalloc.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 1bad69d..dd53f99 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,18 +13,6 @@ endif() find_package(Git QUIET) if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git") - option(GIT_SUBMODULE "Check submodules during build" ON) - if(GIT_SUBMODULE) - message(STATUS "Submodule update") - execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - RESULT_VARIABLE GIT_SUBMOD_RESULT - ) - if(NOT GIT_SUBMOD_RESULT EQUAL "0") - message(FATAL_ERROR "git submodule update --init --recursive failed with ${GIT_SUBMOD_RESULT}, please checkout submodules") - endif() - endif() - execute_process( COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" @@ -37,8 +25,6 @@ if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git") endif() endif() -include(./contrib/jemalloc.cmake) - add_subdirectory(src) add_subdirectory(demo) diff --git a/contrib/jemalloc b/contrib/jemalloc deleted file mode 160000 index ea6b3e9..0000000 --- a/contrib/jemalloc +++ /dev/null @@ -1 +0,0 @@ -Subproject commit ea6b3e973b477b8061e0076bb257dbd7f3faa756 diff --git a/contrib/jemalloc.cmake b/contrib/jemalloc.cmake deleted file mode 100644 index 12aca3b..0000000 --- a/contrib/jemalloc.cmake +++ /dev/null @@ -1,35 +0,0 @@ -# See the end of this file for copyright and license terms. - -set(JEMALLOC_SRCDIR "${CMAKE_SOURCE_DIR}/contrib/jemalloc") -set(JEMALLOC_PREFIX "${CMAKE_BINARY_DIR}/contrib/jemalloc") - -include(ExternalProject) -ExternalProject_Add( - libjemalloc - SOURCE_DIR ${JEMALLOC_SRCDIR} - TMP_DIR ${JEMALLOC_PREFIX} - STAMP_DIR ${JEMALLOC_PREFIX} - CONFIGURE_COMMAND ${JEMALLOC_SRCDIR}/autogen.sh --without-export --enable-static --disable-cxx --srcdir ${JEMALLOC_SRCDIR} --prefix=${JEMALLOC_PREFIX} --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu - PREFIX ${JEMALLOC_SRCDIR} - BUILD_COMMAND make build_lib_static - BUILD_IN_SOURCE 1 - BUILD_BYPRODUCTS ${JEMALLOC_PREFIX}/lib/libjemalloc.a -) - -add_library(jemalloc STATIC IMPORTED GLOBAL) -add_dependencies(jemalloc libjemalloc) -set_property( - TARGET jemalloc - PROPERTY IMPORTED_LOCATION ${JEMALLOC_PREFIX}/lib/libjemalloc.a -) - -# This file is part of libneo. -# Copyright (c) 2021 Fefie . -# -# libneo is non-violent software: you may only use, redistribute, -# and/or modify it under the terms of the CNPLv6+ as found in -# the LICENSE file in the source code root directory or at -# . -# -# libneo comes with ABSOLUTELY NO WARRANTY, to the extent -# permitted by applicable law. See the CNPLv6+ for details. diff --git a/demo/CMakeLists.txt b/demo/CMakeLists.txt index af6b910..2d86b19 100644 --- a/demo/CMakeLists.txt +++ b/demo/CMakeLists.txt @@ -2,9 +2,6 @@ add_executable(demo) -add_compile_options(-nostdlib -nodefaultlibs) -set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -nostdlib") - target_link_libraries(demo PRIVATE neo) target_sources(demo PRIVATE diff --git a/demo/main.c b/demo/main.c index 92ae878..c96f544 100644 --- a/demo/main.c +++ b/demo/main.c @@ -1,11 +1,9 @@ /** See the end of this file for copyright and license terms. */ #include "neo.h" -#include "neo/_unistd.h" int main(int argc, char **argv) { - _neo_sys_write(1, "hello, world\n", 14); return 69; } diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 40f3f79..3d40f9f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,11 +1,17 @@ # See the end of this file for copyright and license terms. -add_library(neo) +add_library(neo STATIC) -add_compile_options(-nostdlib -nodefaultlibs) -set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -nostdlib") +add_compile_options(-nodefaultlibs) +set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}") -target_link_libraries(neo PRIVATE jemalloc) +execute_process(COMMAND uname -m OUTPUT_VARIABLE HOST_ARCH OUTPUT_STRIP_TRAILING_WHITESPACE) +string(TOLOWER "${HOST_ARCH}" HOST_ARCH) +execute_process(COMMAND uname OUTPUT_VARIABLE HOST_OS OUTPUT_STRIP_TRAILING_WHITESPACE) +string(TOLOWER "${HOST_OS}" HOST_OS) + +set(TARGET_ARCH "${HOST_ARCH}" CACHE STRING "Target architecture") +set(TARGET_OS "${HOST_OS}" CACHE STRING "Target operating system") configure_file( ./include/neo/buildconfig.h.in diff --git a/src/arch/x86_64/CMakeLists.txt b/src/arch/x86_64/CMakeLists.txt deleted file mode 100644 index 0f8b071..0000000 --- a/src/arch/x86_64/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -target_sources(neo PRIVATE - arch/${TARGET_ARCH}/syscall_${TARGET_OS}.S -) diff --git a/src/arch/x86_64/syscall_linux.S b/src/arch/x86_64/syscall_linux.S deleted file mode 100644 index 2dc82b8..0000000 --- a/src/arch/x86_64/syscall_linux.S +++ /dev/null @@ -1,46 +0,0 @@ -/** See the end of this file for copyright and license terms. */ - -.global _neo_syscall - -/* - * long _neo_syscall(long number, ...); - * - * We just want to get stuff working for now, therefore we don't care - * about efficiency and just always copy all 6 arguments to the - * respective registers and hope Linux just ignores them lmao - * - * SysV ABI -> Linux syscall - * ----------------------------- - * 1. %rdi -> %rax (number) - * 2. %rsi -> %rdi (arg1) - * 3. %rdx -> %rsi (arg2) - * 4. %rcx -> %rdx (arg3) - * 5. %r8 -> %r10 (arg4) - * 6. %r9 -> %r8 (arg5) - * 7. stack -> %r9 (arg6) - */ -_neo_syscall: - mov %rdi, %rax - mov %rsi, %rdi - mov %rdx, %rsi - mov %rcx, %rdx - mov %r8, %r10 - mov %r9, %r8 - mov (%rsp), %r9 - syscall - ret /* result is already in %rax */ -.size _neo_syscall,.-_neo_syscall -.type _neo_syscall,function - -/* - * This file is part of libneo. - * Copyright (c) 2021 Fefie . - * - * libneo is non-violent software: you may only use, redistribute, - * and/or modify it under the terms of the CNPLv6+ as found in - * the LICENSE file in the source code root directory or at - * . - * - * libneo comes with ABSOLUTELY NO WARRANTY, to the extent - * permitted by applicable law. See the CNPLv6+ for details. - */ diff --git a/src/entry.c b/src/entry.c deleted file mode 100644 index 85e5256..0000000 --- a/src/entry.c +++ /dev/null @@ -1,40 +0,0 @@ -/** See the end of this file for copyright and license terms. */ - -#include "neo.h" -#include "neo/buildconfig.h" - -extern int main(int argc, char **argv); - -/* this is only temporary to test stuff until i implement syscall() */ -__attribute__((__noreturn__)) -static void exit(int code) -{ - register u64 rax __asm__("rax") = 60; - register u64 rdi __asm__("rdi") = code; - __asm__ __volatile__ ( - "syscall" - : "+r" (rax) - : "r" (rdi) - : "rcx", "r11", "memory" - ); - while (1); -} - -void _start(void) -{ - int exit_code = main(0, nil); - exit(exit_code); -} - -/* - * This file is part of libneo. - * Copyright (c) 2021 Fefie . - * - * libneo is non-violent software: you may only use, redistribute, - * and/or modify it under the terms of the CNPLv6+ as found in - * the LICENSE file in the source code root directory or at - * . - * - * libneo comes with ABSOLUTELY NO WARRANTY, to the extent - * permitted by applicable law. See the CNPLv6+ for details. - */ diff --git a/src/unistd.c b/src/unistd.c deleted file mode 100644 index 8e2fdaf..0000000 --- a/src/unistd.c +++ /dev/null @@ -1,30 +0,0 @@ -/** See the end of this file for copyright and license terms. */ - -#include "neo.h" -#include "neo/_unistd.h" - -/* TODO: get rid of hardcoded syscall numbers */ - -isize _neo_sys_write(int fd, const void *buf, usize len) -{ - return _neo_syscall(1, fd, buf, len); -} - -void _neo_sys_exit(int status) -{ - _neo_syscall(60, status); - while (1); /* should not be reached */ -} - -/* - * This file is part of libneo. - * Copyright (c) 2021 Fefie . - * - * libneo is non-violent software: you may only use, redistribute, - * and/or modify it under the terms of the CNPLv6+ as found in - * the LICENSE file in the source code root directory or at - * . - * - * libneo comes with ABSOLUTELY NO WARRANTY, to the extent - * permitted by applicable law. See the CNPLv6+ for details. - */