From 3651306f57aa8e677accc4b3e71f7e76ad38d876 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Mon, 5 Aug 2024 00:53:27 +0300 Subject: [PATCH] LibC: Implement strto{u,i}max() --- userspace/libraries/LibC/CMakeLists.txt | 1 + userspace/libraries/LibC/inttypes.cpp | 14 ++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 userspace/libraries/LibC/inttypes.cpp diff --git a/userspace/libraries/LibC/CMakeLists.txt b/userspace/libraries/LibC/CMakeLists.txt index 113d0c0a1c..1ad81877cb 100644 --- a/userspace/libraries/LibC/CMakeLists.txt +++ b/userspace/libraries/LibC/CMakeLists.txt @@ -5,6 +5,7 @@ set(LIBC_SOURCES dirent.cpp fcntl.cpp grp.cpp + inttypes.cpp locale.cpp malloc.cpp math.cpp diff --git a/userspace/libraries/LibC/inttypes.cpp b/userspace/libraries/LibC/inttypes.cpp new file mode 100644 index 0000000000..3da954be57 --- /dev/null +++ b/userspace/libraries/LibC/inttypes.cpp @@ -0,0 +1,14 @@ +#include +#include + +intmax_t strtoimax(const char* __restrict nptr, char** __restrict endptr, int base) +{ + static_assert(sizeof(intmax_t) == sizeof(long long)); + return strtoll(nptr, endptr, base); +} + +uintmax_t strtoumax(const char* __restrict nptr, char** __restrict endptr, int base) +{ + static_assert(sizeof(uintmax_t) == sizeof(unsigned long long)); + return strtoull(nptr, endptr, base); +}