/****************************************************************12The author of this software is David M. Gay.34Copyright (C) 1998, 2000 by Lucent Technologies5All Rights Reserved67Permission to use, copy, modify, and distribute this software and8its documentation for any purpose and without fee is hereby9granted, provided that the above copyright notice appear in all10copies and that both that the copyright notice and this11permission notice and warranty disclaimer appear in supporting12documentation, and that the name of Lucent or any of its entities13not be used in advertising or publicity pertaining to14distribution of the software without specific, written prior15permission.1617LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,18INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.19IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY20SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES21WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER22IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,23ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF24THIS SOFTWARE.2526****************************************************************/2728/* Please send bug reports to David M. Gay (dmg at acm dot org,29* with " at " changed at "@" and " dot " changed to "."). */3031/* $FreeBSD$ */3233#include "gdtoaimp.h"3435#undef _036#undef _13738/* one or the other of IEEE_MC68k or IEEE_8087 should be #defined */3940#ifdef IEEE_MC68k41#define _0 042#define _1 143#define _2 244#define _3 345#endif46#ifdef IEEE_808747#define _0 348#define _1 249#define _2 150#define _3 051#endif5253void54#ifdef KR_headers55ULtoQ(L, bits, exp, k) ULong *L; ULong *bits; Long exp; int k;56#else57ULtoQ(ULong *L, ULong *bits, Long exp, int k)58#endif59{60switch(k & STRTOG_Retmask) {61case STRTOG_NoNumber:62case STRTOG_Zero:63L[0] = L[1] = L[2] = L[3] = 0;64break;6566case STRTOG_Normal:67L[_3] = bits[0];68L[_2] = bits[1];69L[_1] = bits[2];70L[_0] = (bits[3] & ~0x10000) | ((exp + 0x3fff + 112) << 16);71break;7273case STRTOG_NaNbits:74L[_3] = bits[0];75L[_2] = bits[1];76L[_1] = bits[2];77L[_0] = (bits[3] & ~0x10000)78| (((exp + 0x3fff + 112) << 16) | (1 << 15));79break;8081case STRTOG_Denormal:82L[_3] = bits[0];83L[_2] = bits[1];84L[_1] = bits[2];85L[_0] = bits[3];86break;8788case STRTOG_Infinite:89L[_0] = 0x7fff0000;90L[_1] = L[_2] = L[_3] = 0;91break;9293case STRTOG_NaN:94L[0] = ld_QNAN0;95L[1] = ld_QNAN1;96L[2] = ld_QNAN2;97L[3] = ld_QNAN3;98}99if (k & STRTOG_Neg)100L[_0] |= 0x80000000L;101}102103int104#ifdef KR_headers105strtorQ_l(s, sp, rounding, L, locale) CONST char *s; char **sp; int rounding;106void *L; locale_t locale;107#else108strtorQ_l(CONST char *s, char **sp, int rounding, void *L, locale_t locale)109#endif110{111static FPI fpi0 = { 113, 1-16383-113+1, 32766-16383-113+1, 1, SI };112FPI *fpi, fpi1;113ULong bits[4];114Long exp;115int k;116117fpi = &fpi0;118if (rounding != FPI_Round_near) {119fpi1 = fpi0;120fpi1.rounding = rounding;121fpi = &fpi1;122}123k = strtodg_l(s, sp, fpi, &exp, bits, locale);124ULtoQ((ULong*)L, bits, exp, k);125return k;126}127128129