diff --git a/include/stdlib.h b/include/stdlib.h index 10ec6c2629..09eb2cf6c0 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -80,18 +80,11 @@ # define environ get_environ_ptr() #endif -/* The functions strtof() and strtold() are not currently implemented in - * NuttX. Ideally, custom implementations of these functions would be - * provided because: - * - * strtof() - Some MCUs, such as the Cortex-M4F, have built in 32-bit FPU. - * A true implementation could exploit the improved performance by the - * the FPU. - * strtold() - Of course, there is a loss of 32-bits of accuracy in this - * conversion. +/* The function strtold() is not currently implemented in NuttX. Ideally, a + * custom implementation should be provided because, of course, there is a + * loss of 32-bits of accuracy in this conversion. */ -#define strtof(a,b) (float)strtod(a,b) #define strtold(a,b) (long double)strtod(a,b) /**************************************************************************** @@ -205,6 +198,7 @@ unsigned long long strtoull(FAR const char *nptr, FAR char **endptr, int base); #endif double_t strtod(FAR const char *str, FAR char **endptr); +float strtof(FAR const char *str, FAR char **endptr); #define atoi(nptr) ((int)strtol((nptr), NULL, 10)) #define atol(nptr) strtol((nptr), NULL, 10) diff --git a/libc/stdlib/Make.defs b/libc/stdlib/Make.defs index 22509d22dd..d08a0bb434 100644 --- a/libc/stdlib/Make.defs +++ b/libc/stdlib/Make.defs @@ -39,7 +39,7 @@ CSRCS += lib_abs.c lib_abort.c lib_div.c lib_ldiv.c lib_lldiv.c CSRCS += lib_imaxabs.c lib_itoa.c lib_labs.c lib_llabs.c CSRCS += lib_bsearch.c lib_rand.c lib_qsort.c lib_srand.c CSRCS += lib_strtol.c lib_strtoll.c lib_strtoul.c lib_strtoull.c -CSRCS += lib_strtod.c lib_checkbase.c +CSRCS += lib_strtod.c lib_strtof.c lib_checkbase.c ifeq ($(CONFIG_FS_WRITABLE),y) CSRCS += lib_mktemp.c lib_mkstemp.c diff --git a/libc/stdlib/lib_strtod.c b/libc/stdlib/lib_strtod.c index bd2a55e996..7d8d08b532 100644 --- a/libc/stdlib/lib_strtod.c +++ b/libc/stdlib/lib_strtod.c @@ -92,7 +92,7 @@ double_t strtod(FAR const char *str, FAR char **endptr) double_t number; int exponent; int negative; - char *p = (char *) str; + FAR char *p = (FAR char *) str; double p10; int n; int num_digits;