4
12
Fork
You've already forked LensorOS
4

Implement part of stdio and improve libc in general #11

Merged
LensPlaysGames merged 19 commits from Sirraide/LensorOS:dev into main 2022年10月30日 22:11:33 +01:00
Contributor
Copy link

This pr adds stdio (mostly stubs, but streams already work), proper handling of cdtors, the beginnings of a C++ stdlib, a cmake target to copy libc headers to the sysroot, a cmake flag to build libc for the native host, a better syscall interface for C and C++, support for native syscalls, malloc using a simple bump allocator, and the implementation of various other functions.

This pr adds stdio (mostly stubs, but streams already work), proper handling of cdtors, the beginnings of a C++ stdlib, a cmake target to copy libc headers to the sysroot, a cmake flag to build libc for the native host, a better syscall interface for C and C++, support for native syscalls, malloc using a simple bump allocator, and the implementation of various other functions.
@ -25,2 +25,2 @@
# Use cross compiler.
set( CMAKE_TOOLCHAIN_FILE "../../kernel/lensor_gnu_toolchain.cmake" )
if (NOT LENSOR_OS_LIBC_BUILD_HOST)
Author
Contributor
Copy link

Do -DLENSOR_OS_LIBC_BUILD_HOST=1 when invoking CMake to build libc for the native system. Currently, only linux is supported for obvious reasons.

Do `-DLENSOR_OS_LIBC_BUILD_HOST=1` when invoking CMake to build libc for the native system. Currently, only linux is supported for obvious reasons.
@ -74,0 +96,4 @@
-fno-exceptions
-nostdlib
-nostdinc
-Wno-prio-ctor-dtor
Author
Contributor
Copy link

This way, programs that link against libc via CMake have these set automatically.

This way, programs that link against libc via CMake have these set automatically.
Author
Contributor
Copy link

Also, I'm gonna remove -Wno-prio-ctor-dtor later and replace it locally w/ a pragma.

Also, I'm gonna remove `-Wno-prio-ctor-dtor` later and replace it locally w/ a pragma.
@ -74,0 +104,4 @@
c
PRIVATE
-g
-O0
Author
Contributor
Copy link

Force debug mode for now when compiling natively

Force debug mode for now when compiling natively
@ -74,0 +130,4 @@
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/time.h" "${ROOT}/inc/time.h"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/unistd.h" "${ROOT}/inc/unistd.h"
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/sys" "${ROOT}/inc/sys"
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/bits" "${ROOT}/inc/bits"
Author
Contributor
Copy link

You can probably improve this w/ a file(GLOB ...) + foreach()

You can probably improve this w/ a `file(GLOB ...)` + `foreach()`
@ -0,0 +28,4 @@
const char *file,
unsigned int line,
const char *func
);
Author
Contributor
Copy link

Called by assert()

Called by `assert()`
@ -0,0 +37,4 @@
const char *file,
unsigned int line,
const char *func
);
Author
Contributor
Copy link

Called by __libc_assert()

Called by `__libc_assert()`
@ -0,0 +21,4 @@
#define _LENSOROS_LIBC_CDTORS_H
#define _CDTOR_MALLOC 0
#define _CDTOR_STDIO 1
Author
Contributor
Copy link

Global constructor/destructor order

Global constructor/destructor order
@ -47,0 +259,4 @@
}
__attribute__((__noreturn__)) void _Exit(int status) {
/// TODO: call at_quick_exit handlers.

This comment is wrong.

This comment is wrong.

Things are somewhat broken (has to do with write syscall), but it is most likely in the kernel somewhere. If not, we still want all the work from this PR done, so we are just calling it a known bug 😎

Things are somewhat broken (has to do with `write` syscall), but it is most likely in the kernel somewhere. If not, we still want all the work from this PR done, so we are just calling it a known bug :sunglasses:
Sign in to join this conversation.
No reviewers
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
LensPlaysGames/LensorOS!11
Reference in a new issue
LensPlaysGames/LensorOS
No description provided.
Delete branch "Sirraide/LensorOS:dev"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?