mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:48:14 +00:00
LibC: Implement atexit() and strtoul().
This commit is contained in:
parent
2a858719be
commit
baab9f4402
1 changed files with 20 additions and 10 deletions
|
@ -201,12 +201,28 @@ void* realloc(void *ptr, size_t size)
|
|||
return new_ptr;
|
||||
}
|
||||
|
||||
typedef void(*__atexit_handler)();
|
||||
static int __atexit_handler_count = 0;
|
||||
static __atexit_handler __atexit_handlers[32];
|
||||
|
||||
void exit(int status)
|
||||
{
|
||||
for (int i = 0; i < __atexit_handler_count; ++i)
|
||||
__atexit_handlers[i]();
|
||||
extern void _fini();
|
||||
_fini();
|
||||
_exit(status);
|
||||
assert(false);
|
||||
}
|
||||
|
||||
int atexit(void (*handler)())
|
||||
{
|
||||
ASSERT(__atexit_handler_count < 32);
|
||||
__atexit_handlers[__atexit_handler_count++] = handler;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void abort()
|
||||
{
|
||||
// FIXME: Implement proper abort().
|
||||
|
@ -425,12 +441,6 @@ size_t mbstowcs(wchar_t*, const char*, size_t)
|
|||
assert(false);
|
||||
}
|
||||
|
||||
int atexit(void (*function)())
|
||||
{
|
||||
(void)function;
|
||||
assert(false);
|
||||
}
|
||||
|
||||
long strtol(const char* str, char** endptr, int base)
|
||||
{
|
||||
const char* s = str;
|
||||
|
@ -488,11 +498,11 @@ long strtol(const char* str, char** endptr, int base)
|
|||
return acc;
|
||||
}
|
||||
|
||||
unsigned long strtoul(const char*, char** endptr, int base)
|
||||
unsigned long strtoul(const char* str, char** endptr, int base)
|
||||
{
|
||||
(void)endptr;
|
||||
(void)base;
|
||||
assert(false);
|
||||
auto value = strtol(str, endptr, base);
|
||||
ASSERT(value >= 0);
|
||||
return value;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue