strtopxL.c revision 1.3
11.3Skleink/* $NetBSD: strtopxL.c,v 1.3 2006/03/15 17:35:18 kleink Exp $ */ 21.1Skleink 31.1Skleink/**************************************************************** 41.1Skleink 51.1SkleinkThe author of this software is David M. Gay. 61.1Skleink 71.1SkleinkCopyright (C) 1998, 2000 by Lucent Technologies 81.1SkleinkAll Rights Reserved 91.1Skleink 101.1SkleinkPermission to use, copy, modify, and distribute this software and 111.1Skleinkits documentation for any purpose and without fee is hereby 121.1Skleinkgranted, provided that the above copyright notice appear in all 131.1Skleinkcopies and that both that the copyright notice and this 141.1Skleinkpermission notice and warranty disclaimer appear in supporting 151.1Skleinkdocumentation, and that the name of Lucent or any of its entities 161.1Skleinknot be used in advertising or publicity pertaining to 171.1Skleinkdistribution of the software without specific, written prior 181.1Skleinkpermission. 191.1Skleink 201.1SkleinkLUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 211.1SkleinkINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. 221.1SkleinkIN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY 231.1SkleinkSPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 241.1SkleinkWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER 251.1SkleinkIN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 261.1SkleinkARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF 271.1SkleinkTHIS SOFTWARE. 281.1Skleink 291.1Skleink****************************************************************/ 301.1Skleink 311.1Skleink/* Please send bug reports to David M. Gay (dmg at acm dot org, 321.1Skleink * with " at " changed at "@" and " dot " changed to "."). */ 331.1Skleink 341.1Skleink#include "gdtoaimp.h" 351.1Skleink 361.1Skleink#undef _0 371.1Skleink#undef _1 381.1Skleink 391.2Skleink/* one or the other of IEEE_BIG_ENDIAN or IEEE_LITTLE_ENDIAN should be #defined */ 401.1Skleink 411.2Skleink#ifdef IEEE_BIG_ENDIAN 421.1Skleink#define _0 0 431.1Skleink#define _1 1 441.1Skleink#define _2 2 451.1Skleink#endif 461.2Skleink#ifdef IEEE_LITTLE_ENDIAN 471.1Skleink#define _0 2 481.1Skleink#define _1 1 491.1Skleink#define _2 0 501.1Skleink#endif 511.1Skleink 521.1Skleink int 531.1Skleink#ifdef KR_headers 541.1SkleinkstrtopxL(s, sp, V) CONST char *s; char **sp; void *V; 551.1Skleink#else 561.1SkleinkstrtopxL(CONST char *s, char **sp, void *V) 571.1Skleink#endif 581.1Skleink{ 591.3Skleink static CONST FPI fpi = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, SI }; 601.1Skleink ULong bits[2]; 611.3Skleink Long expt; 621.1Skleink int k; 631.1Skleink ULong *L = (ULong*)V; 641.1Skleink 651.3Skleink k = strtodg(s, sp, &fpi, &expt, bits); 661.1Skleink switch(k & STRTOG_Retmask) { 671.1Skleink case STRTOG_NoNumber: 681.1Skleink case STRTOG_Zero: 691.1Skleink L[0] = L[1] = L[2] = 0; 701.1Skleink break; 711.1Skleink 721.1Skleink case STRTOG_Normal: 731.1Skleink case STRTOG_Denormal: 741.1Skleink case STRTOG_NaNbits: 751.1Skleink L[_2] = bits[0]; 761.1Skleink L[_1] = bits[1]; 771.3Skleink L[_0] = (expt + 0x3fff + 63) << 16; 781.1Skleink break; 791.1Skleink 801.1Skleink case STRTOG_Infinite: 811.1Skleink L[_0] = 0x7fff << 16; 821.1Skleink L[_1] = L[_2] = 0; 831.1Skleink break; 841.1Skleink 851.1Skleink case STRTOG_NaN: 861.1Skleink L[0] = ld_QNAN0; 871.1Skleink L[1] = ld_QNAN1; 881.1Skleink L[2] = ld_QNAN2; 891.1Skleink } 901.1Skleink if (k & STRTOG_Neg) 911.1Skleink L[_0] |= 0x80000000L; 921.1Skleink return k; 931.1Skleink } 94