fxlibc/src/stdlib/stdlib_p.h

54 lines
1.6 KiB
C

#ifndef __STDLIB_P_H__
# define __STDLIB_P_H__
#include <stdlib.h>
#include <stdbool.h>
#include <limits.h>
#include "../stdio/stdio_p.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.
**
** N is the bound on the number of characters to read. To disable the bound,
** specify INT_MAX.
*/
int __strto_int(
struct __scanf_input *__input,
int __base,
long *__outl,
long long *__outll,
bool __use_unsigned,
int __N);
/*
** 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(
struct __scanf_input *__input,
double *__out,
float *__outf,
long double *__outl,
int __N);
#endif /*__STDLIB_P_H__*/