Added exit() function and renamed stdlib file to libc.a so GCC is happy.
This commit is contained in:
parent
ca08dcc79b
commit
c2a40a8104
@ -18,7 +18,7 @@ enum class Syscall : std::uint64_t
|
||||
|
||||
void setupSyscall() noexcept;
|
||||
|
||||
template<typename TParam0, typename TParam1, typename TParam2>
|
||||
template<typename TParam0 = int, typename TParam1 = int, typename TParam2 = int>
|
||||
inline void doSyscall(Syscall cmd, TParam0 param0 = 0, TParam1 param1 = 0, TParam2 param2 = 0) noexcept
|
||||
{
|
||||
register std::uint64_t r8 asm("r8") = param2;
|
||||
|
@ -28,7 +28,7 @@ if env['BUILD_TARGET'] == 'stdlib':
|
||||
stdlib_env.Append(CPPPATH = ['#targets/_any/bastl/include', '#targets/_any/stdlib/include', '#targets/_any/kernel/include'])
|
||||
|
||||
lib_stdlib = stdlib_env.StaticLibrary(
|
||||
target = stdlib_env.File('#stdlib/stdlib.a'),
|
||||
target = stdlib_env.File('#stdlib/libc.a'),
|
||||
source = stdlib_sources
|
||||
)
|
||||
crti_o = stdlib_env.Object(target = '#stdlib/crti.o', source = stdlib_env['CRTI_PATH'])
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include <stddef.h>
|
||||
#include "os/memory.hpp"
|
||||
#include "os/syscall.hpp"
|
||||
#include "os/tty.hpp"
|
||||
|
||||
namespace
|
||||
@ -44,6 +45,15 @@ void abort()
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
void exit(int exitCode) noexcept
|
||||
{
|
||||
#if !defined(__baos_kernel_source__)
|
||||
baos::doSyscall(baos::Syscall::EXIT, exitCode);
|
||||
#else
|
||||
abort(); // no exit in kernel!
|
||||
#endif
|
||||
}
|
||||
|
||||
void* malloc(size_t size) noexcept
|
||||
{
|
||||
if (size == 0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user