mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-10 13:00:29 +03:00
LibC: Implement atexit() and strtoul().
This commit is contained in:
parent
2a858719be
commit
baab9f4402
Notes:
sideshowbarker
2024-07-19 14:56:00 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/baab9f44024
@ -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…
Reference in New Issue
Block a user