ladybird/LibC/entry.cpp

43 lines
745 B
C++
Raw Normal View History

#include <stdio.h>
#include <string.h>
2018-10-22 14:06:22 +02:00
#include <Kernel/Syscall.h>
#include <AK/StringImpl.h>
2018-10-22 14:06:22 +02:00
extern "C" int main(int, char**);
int errno;
char** environ;
extern "C" void __malloc_init();
2018-11-11 10:11:09 +01:00
extern "C" void __stdio_init();
extern "C" int _start()
2018-10-22 14:06:22 +02:00
{
errno = 0;
2018-11-11 10:11:09 +01:00
__stdio_init();
__malloc_init();
2018-12-21 02:10:45 +01:00
StringImpl::initialize_globals();
int status = 254;
int argc;
char** argv;
int rc = syscall(SC_get_arguments, &argc, &argv);
if (rc < 0)
goto epilogue;
rc = syscall(SC_get_environment, &environ);
if (rc < 0)
goto epilogue;
status = main(argc, argv);
fflush(stdout);
fflush(stderr);
epilogue:
syscall(SC_exit, status);
2018-10-22 14:06:22 +02:00
// Birger's birthday <3
return 20150614;
}