]>
git.proxmox.com Git - wasi-libc.git/blob - libc-top-half/musl/src/stdlib/strtod.c
2 #ifdef __wasilibc_unmodified_upstream
5 #define __NEED_locale_t
6 #include <bits/alltypes.h>
10 #include "stdio_impl.h"
12 #if defined(__wasilibc_printscan_no_long_double)
13 static long_double
strtox(const char *s
, char **p
, int prec
)
15 static long double strtox(const char *s
, char **p
, int prec
)
21 #if defined(__wasilibc_printscan_no_long_double)
22 long_double y
= __floatscan(&f
, prec
, 1);
24 long double y
= __floatscan(&f
, prec
, 1);
26 off_t cnt
= shcnt(&f
);
27 if (p
) *p
= cnt
? (char *)s
+ cnt
: (char *)s
;
31 float strtof(const char *restrict s
, char **restrict p
)
33 return strtox(s
, p
, 0);
36 double strtod(const char *restrict s
, char **restrict p
)
38 return strtox(s
, p
, 1);
41 long double strtold(const char *restrict s
, char **restrict p
)
43 #if defined(__wasilibc_printscan_no_long_double)
44 long_double_not_supported();
46 return strtox(s
, p
, 2);
50 #ifdef __wasilibc_unmodified_upstream
51 weak_alias(strtof
, strtof_l
);
52 weak_alias(strtod
, strtod_l
);
53 weak_alias(strtold
, strtold_l
);
54 weak_alias(strtof
, __strtof_l
);
55 weak_alias(strtod
, __strtod_l
);
56 weak_alias(strtold
, __strtold_l
);
58 // WebAssembly doesn't permit signature-changing aliases, so use wrapper
60 weak
float strtof_l(const char *restrict s
, char **restrict p
, locale_t loc
) {
63 weak
double strtod_l(const char *restrict s
, char **restrict p
, locale_t loc
) {
66 weak
long double strtold_l(const char *restrict s
, char **restrict p
, locale_t loc
) {