Luna/libc/src/stdlib.cpp
apio 129e3c434a
Some checks failed
continuous-integration/drone/push Build is failing
Switch to C for userspace, with a very bare-bones libc!!
2023-01-06 13:31:14 +01:00

31 lines
720 B
C++

#include <luna/NumberParsing.h>
#include <stdlib.h>
#include <sys/syscall.h>
#include <unistd.h>
extern "C"
{
// FIXME: Check for overflow in both strtol() and strtoul().
long strtol(const char* str, char** endptr, int base)
{
return (long)parse_signed_integer(str, const_cast<const char**>(endptr), base);
}
unsigned long strtoul(const char* str, char** endptr, int base)
{
return (unsigned long)parse_unsigned_integer(str, const_cast<const char**>(endptr), base);
}
__noreturn void abort()
{
syscall(SYS_exit);
__builtin_unreachable();
}
__noreturn void exit(int)
{
syscall(SYS_exit);
__builtin_unreachable();
}
}