xref: /openbsd/lib/libc/arch/amd64/gdtoa/strtold.c (revision 7b36286a)
1*7b36286aSmartynas /*	$OpenBSD: strtold.c,v 1.1 2008/09/07 20:36:07 martynas Exp $	*/
2*7b36286aSmartynas /*-
3*7b36286aSmartynas  * Copyright (c) 2003 David Schultz <das@FreeBSD.ORG>
4*7b36286aSmartynas  * All rights reserved.
5*7b36286aSmartynas  *
6*7b36286aSmartynas  * Redistribution and use in source and binary forms, with or without
7*7b36286aSmartynas  * modification, are permitted provided that the following conditions
8*7b36286aSmartynas  * are met:
9*7b36286aSmartynas  * 1. Redistributions of source code must retain the above copyright
10*7b36286aSmartynas  *    notice, this list of conditions and the following disclaimer.
11*7b36286aSmartynas  * 2. Redistributions in binary form must reproduce the above copyright
12*7b36286aSmartynas  *    notice, this list of conditions and the following disclaimer in the
13*7b36286aSmartynas  *    documentation and/or other materials provided with the distribution.
14*7b36286aSmartynas  *
15*7b36286aSmartynas  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16*7b36286aSmartynas  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17*7b36286aSmartynas  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18*7b36286aSmartynas  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19*7b36286aSmartynas  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20*7b36286aSmartynas  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21*7b36286aSmartynas  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22*7b36286aSmartynas  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23*7b36286aSmartynas  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24*7b36286aSmartynas  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25*7b36286aSmartynas  * SUCH DAMAGE.
26*7b36286aSmartynas  */
27*7b36286aSmartynas 
28*7b36286aSmartynas /*
29*7b36286aSmartynas  * Machine-dependent glue to integrate David Gay's gdtoa
30*7b36286aSmartynas  * package into libc for architectures where a long double
31*7b36286aSmartynas  * is an IEEE extended precision number.
32*7b36286aSmartynas  */
33*7b36286aSmartynas 
34*7b36286aSmartynas #include <float.h>
35*7b36286aSmartynas 
36*7b36286aSmartynas #include "gdtoaimp.h"
37*7b36286aSmartynas 
38*7b36286aSmartynas long double
39*7b36286aSmartynas strtold(const char * __restrict s, char ** __restrict sp)
40*7b36286aSmartynas {
41*7b36286aSmartynas 	long double result;
42*7b36286aSmartynas 
43*7b36286aSmartynas 	strtorx(s, sp, FLT_ROUNDS, &result);
44*7b36286aSmartynas 	return result;
45*7b36286aSmartynas }
46