Luna/libs/libc/src/stdlib.cpp
apio f83a6ace51 Kernel, libc: Add support for providing a status code to exit()
The exit() libc function already accepted an integer, but didn't pass it on to the kernel since we had no mechanism for it to do that.
Now, the kernel stores a task's exit status to display it later (and in the future, return it to userspace via wait()/waitpid())
2022-10-08 17:56:40 +02:00

36 lines
632 B
C++

#include <luna.h>
#include <stdlib.h>
#include <sys/syscall.h>
#include <unistd.h>
#define noreturn __attribute__((noreturn))
#define maybe_unused __attribute__((maybe_unused))
#define unused __attribute__((unused))
extern "C"
{
noreturn void abort()
{
exit(-1);
}
noreturn void exit(int status)
{
syscall(SYS_exit, status);
__builtin_unreachable();
}
int atexit(void (*)(void))
{
NOT_IMPLEMENTED("atexit");
}
int atoi(const char*)
{
NOT_IMPLEMENTED("atoi");
}
char* getenv(const char*)
{
NOT_IMPLEMENTED("getenv");
}
}