libc: Add very basic strtoul()

As well as returning NULL in getenv() instead of aborting.
This commit is contained in:
apio 2022-10-21 18:32:46 +02:00
parent bf026d0dea
commit 6d7a8a0d0b
2 changed files with 11 additions and 1 deletions

View File

@ -30,6 +30,9 @@ extern "C"
/* Returns an integer (of type long long) parsed from the string str. */
long long atoll(const char* str);
/* Returns an integer (of type unsigned long) parsed from the string str. */
unsigned long strtoul(const char* str, const char** endptr, int base);
/* Not implemented. */
char* getenv(const char*);

View File

@ -46,9 +46,16 @@ extern "C"
return string_to_integer_type<long long>(str);
}
unsigned long strtoul(const char* str, const char** endptr, int base)
{
if (base != 0 && base != 10) NOT_IMPLEMENTED("strtoul with base not in (0,10)");
if (endptr) NOT_IMPLEMENTED("strtoul with non-null endptr");
return string_to_integer_type<unsigned long>(str);
}
char* getenv(const char*)
{
NOT_IMPLEMENTED("getenv");
return NULL; // Not implemented :)
}
__lc_noreturn void _Exit(int status)