fxlibc/src/libc/stdlib/stdlib_p.h

45 lines
1.5 KiB
C

#ifndef __STDLIB_P_H__
# define __STDLIB_P_H__
#include <stdlib.h>
#include <stdbool.h>
/* Parse an integer from a string. This is the base function for strtol,
strtoul, strtoll, and strtoull.
This function does not set errno, and instead returns the error code
according to conversion rules. Setting errno is troublesome because it's a
global state that cannot be reverted and thus cannot be tested.
If outl is non-NULL, strto_int produces a long or an unsigned long result
(depending on use_unsigned). Signedness only affects the range of values
that are considered to be ERANGE, and both results are stored in *outl.
Similarly, if outll is non-NULL, strto_int produces a long long or unsigned
long long result. Only one pointer should be non-NULL.
On platforms where long is 32-bit, 64-bit operations are performed only if
outll is non-NULL. This is because multiplications with overflow can be
expensive. */
int strto_int(
char const * restrict __ptr,
char ** restrict __endptr,
int __base,
long *__outl,
long long *__outll,
bool __use_unsigned);
/* Parse a floating-point value from a string. This is the base function for
strtod, strtof, and strtold.
This function is similar to strto_int(). If returns the error code to set in
errno, and can produce one of three outputs depending on which of out, outf
and outl is set. */
int strto_fp(
char const * restrict __ptr,
char ** restrict __endptr,
double *out,
float *outf,
long double *outl);
#endif /*__STDLIB_P_H__*/