1 /* $NetBSD: strtold_subr.c,v 1.1 2006/03/15 17:35:18 kleink Exp $ */
2
3 /*
4 * Written by Klaus Klein <kleink@NetBSD.org>, November 16, 2005.
5 * Public domain.
6 */
7
8 /*
9 * NOTICE: This is not a standalone file. To use it, #include it in
10 * the format-specific strtold_*.c, like so:
11 *
12 * #define GDTOA_LD_FMT <gdtoa extended-precision format code>
13 * #include "strtold_subr.c"
14 */
15 #include <LibConfig.h>
16 #include <sys/EfiCdefs.h>
17
18 #include "namespace.h"
19 #include <math.h>
20 #include <sys/stdint.h>
21 #include <stdlib.h>
22 #include "gdtoa.h"
23
24 #ifdef __weak_alias
__weak_alias(strtold,_strtold)25 __weak_alias(strtold, _strtold)
26 #endif
27
28 #ifndef __HAVE_LONG_DOUBLE
29 #error no extended-precision long double type
30 #endif
31
32 #ifndef GDTOA_LD_FMT
33 #error GDTOA_LD_FMT must be defined by format-specific source file
34 #endif
35
36 #define STRTOP(x) __CONCAT(strtop, x)
37
38 long double
39 strtold(const char *nptr, char **endptr)
40 {
41 long double ld;
42
43 (void)STRTOP(GDTOA_LD_FMT)(nptr, endptr, &ld);
44 return ld;
45 }
46