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