mirror of
https://git.planet-casio.com/Vhex-Kernel-Core/fxlibc.git
synced 2024-12-29 13:03:38 +01:00
inttypes: add strtoimax and strtoumax
This commit is contained in:
parent
bc53e756a8
commit
cc03641522
5 changed files with 47 additions and 1 deletions
|
@ -88,6 +88,8 @@ set(SOURCES
|
||||||
# inttypes
|
# inttypes
|
||||||
src/libc/inttypes/imaxabs.c
|
src/libc/inttypes/imaxabs.c
|
||||||
src/libc/inttypes/imaxdiv.c
|
src/libc/inttypes/imaxdiv.c
|
||||||
|
src/libc/inttypes/strtoimax.c
|
||||||
|
src/libc/inttypes/strtoumax.c
|
||||||
# locale
|
# locale
|
||||||
src/libc/locale/setlocale.c
|
src/libc/locale/setlocale.c
|
||||||
src/libc/locale/localeconv.c
|
src/libc/locale/localeconv.c
|
||||||
|
|
2
STATUS
2
STATUS
|
@ -47,7 +47,7 @@ DONE: Function/symbol/macro is defined, builds, links, and is tested
|
||||||
7.8.1 SCN* macros: LDEPS(*scanf)
|
7.8.1 SCN* macros: LDEPS(*scanf)
|
||||||
7.8.2.1 imaxabs: DONE
|
7.8.2.1 imaxabs: DONE
|
||||||
7.8.2.2 imaxdiv: DONE
|
7.8.2.2 imaxdiv: DONE
|
||||||
7.8.2.3 strotimax strtoumax: TODO
|
7.8.2.3 strtoimax strtoumax: DONE
|
||||||
7.8.2.4 wcstoimax wcstoumax: TODO
|
7.8.2.4 wcstoimax wcstoumax: TODO
|
||||||
|
|
||||||
7.9 <iso646.h>
|
7.9 <iso646.h>
|
||||||
|
|
|
@ -243,4 +243,16 @@ extern intmax_t imaxabs(intmax_t __j);
|
||||||
extern imaxdiv_t imaxdiv(intmax_t __num, intmax_t __denom);
|
extern imaxdiv_t imaxdiv(intmax_t __num, intmax_t __denom);
|
||||||
#define imaxdiv lldiv
|
#define imaxdiv lldiv
|
||||||
|
|
||||||
|
/* Parse an intmax_t from string. */
|
||||||
|
extern intmax_t strtoimax(
|
||||||
|
char const * restrict __ptr,
|
||||||
|
char ** restrict __endptr,
|
||||||
|
int __base);
|
||||||
|
|
||||||
|
/* Parse an uintmax_t from string. */
|
||||||
|
extern uintmax_t strtoumax(
|
||||||
|
char const * restrict __ptr,
|
||||||
|
char ** restrict __endptr,
|
||||||
|
int __base);
|
||||||
|
|
||||||
#endif /*__INTTYPES_H__*/
|
#endif /*__INTTYPES_H__*/
|
||||||
|
|
16
src/libc/inttypes/strtoimax.c
Normal file
16
src/libc/inttypes/strtoimax.c
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#if __INTMAX_WIDTH__ == __LONG_WIDTH__
|
||||||
|
# define __strtoimax strtol
|
||||||
|
#elif __INTMAX_WIDTH__ == __LONG_LONG_WIDTH__
|
||||||
|
# define __strtoimax strtoll
|
||||||
|
#else
|
||||||
|
# error How is intmax_t neither long nor long long?
|
||||||
|
#endif
|
||||||
|
|
||||||
|
intmax_t strtoimax(char const * restrict ptr, char ** restrict endptr,
|
||||||
|
int base)
|
||||||
|
{
|
||||||
|
return __strtoimax(ptr, endptr, base);
|
||||||
|
}
|
16
src/libc/inttypes/strtoumax.c
Normal file
16
src/libc/inttypes/strtoumax.c
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#if __INTMAX_WIDTH__ == __LONG_WIDTH__
|
||||||
|
# define __strtoumax strtoul
|
||||||
|
#elif __INTMAX_WIDTH__ == __LONG_LONG_WIDTH__
|
||||||
|
# define __strtoumax strtoull
|
||||||
|
#else
|
||||||
|
# error How is uintmax_t neither unsigned long nor unsigned long long?
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uintmax_t strtoumax(char const * restrict ptr, char ** restrict endptr,
|
||||||
|
int base)
|
||||||
|
{
|
||||||
|
return __strtoumax(ptr, endptr, base);
|
||||||
|
}
|
Loading…
Reference in a new issue