Home | History | Annotate | Line # | Download | only in gdtoa
strtold_subr.c revision 1.1.50.1
      1       1.1  kleink /* $NetBSD: strtold_subr.c,v 1.1.50.1 2013/06/23 06:21:05 tls 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.50.1 2013/06/23 06:21:05 tls 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.50.1     tls #include <locale.h>
     27  1.1.50.1     tls #include "setlocale_local.h"
     28  1.1.50.1     tls 
     29       1.1  kleink #ifdef __weak_alias
     30       1.1  kleink __weak_alias(strtold, _strtold)
     31  1.1.50.1     tls __weak_alias(strtold_l, _strtold_l)
     32       1.1  kleink #endif
     33       1.1  kleink 
     34       1.1  kleink #ifndef __HAVE_LONG_DOUBLE
     35       1.1  kleink #error no extended-precision long double type
     36       1.1  kleink #endif
     37       1.1  kleink 
     38       1.1  kleink #ifndef GDTOA_LD_FMT
     39       1.1  kleink #error GDTOA_LD_FMT must be defined by format-specific source file
     40       1.1  kleink #endif
     41       1.1  kleink 
     42       1.1  kleink #define	STRTOP(x)	__CONCAT(strtop, x)
     43       1.1  kleink 
     44  1.1.50.1     tls static long double
     45  1.1.50.1     tls _int_strtold_l(const char *nptr, char **endptr, locale_t loc)
     46       1.1  kleink {
     47       1.1  kleink 	long double ld;
     48       1.1  kleink 
     49  1.1.50.1     tls 	(void)STRTOP(GDTOA_LD_FMT)(nptr, endptr, &ld, loc);
     50       1.1  kleink 	return ld;
     51       1.1  kleink }
     52  1.1.50.1     tls 
     53  1.1.50.1     tls long double
     54  1.1.50.1     tls strtold(CONST char *s, char **sp)
     55  1.1.50.1     tls {
     56  1.1.50.1     tls 	return _int_strtold_l(s, sp, _current_locale());
     57  1.1.50.1     tls }
     58  1.1.50.1     tls 
     59  1.1.50.1     tls long double
     60  1.1.50.1     tls strtold_l(CONST char *s, char **sp, locale_t loc)
     61  1.1.50.1     tls {
     62  1.1.50.1     tls 	return _int_strtold_l(s, sp, loc);
     63  1.1.50.1     tls }
     64