Luna/libc/src/stdlib.cpp

31 lines
720 B
C++
Raw Normal View History

#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();
}
}