+++ /dev/null
-/* $NetBSD: strtopx.c,v 1.3.14.1 2008/04/08 21:10:55 jdc Exp $ */\r
-\r
-/****************************************************************\r
-\r
-The author of this software is David M. Gay.\r
-\r
-Copyright (C) 1998, 2000 by Lucent Technologies\r
-All Rights Reserved\r
-\r
-Permission to use, copy, modify, and distribute this software and\r
-its documentation for any purpose and without fee is hereby\r
-granted, provided that the above copyright notice appear in all\r
-copies and that both that the copyright notice and this\r
-permission notice and warranty disclaimer appear in supporting\r
-documentation, and that the name of Lucent or any of its entities\r
-not be used in advertising or publicity pertaining to\r
-distribution of the software without specific, written prior\r
-permission.\r
-\r
-LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,\r
-INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.\r
-IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY\r
-SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\r
-WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER\r
-IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,\r
-ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF\r
-THIS SOFTWARE.\r
-\r
-****************************************************************/\r
-\r
-/* Please send bug reports to David M. Gay (dmg at acm dot org,\r
- * with " at " changed at "@" and " dot " changed to "."). */\r
-#include <LibConfig.h>\r
-\r
-#include "gdtoaimp.h"\r
-\r
-#undef _0\r
-#undef _1\r
-\r
-/* one or the other of IEEE_BIG_ENDIAN or IEEE_LITTLE_ENDIAN should be #defined */\r
-\r
-#ifdef IEEE_BIG_ENDIAN\r
-#define _0 0\r
-#define _1 1\r
-#define _2 2\r
-#define _3 3\r
-#define _4 4\r
-#endif\r
-#ifdef IEEE_LITTLE_ENDIAN\r
-#define _0 4\r
-#define _1 3\r
-#define _2 2\r
-#define _3 1\r
-#define _4 0\r
-#endif\r
-\r
- int\r
-#ifdef KR_headers\r
-strtopx(s, sp, V) CONST char *s; char **sp; void *V;\r
-#else\r
-strtopx(CONST char *s, char **sp, void *V)\r
-#endif\r
-{\r
- static CONST FPI fpi = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, SI };\r
- ULong bits[2];\r
- Long expt;\r
- int k;\r
- UShort *L = (UShort*)V;\r
-\r
- k = strtodg(s, sp, &fpi, &expt, bits);\r
- if (k == STRTOG_NoMemory)\r
- return k;\r
- switch(k & STRTOG_Retmask) {\r
- case STRTOG_NoNumber:\r
- case STRTOG_Zero:\r
- L[0] = L[1] = L[2] = L[3] = L[4] = 0;\r
- break;\r
-\r
- case STRTOG_Denormal:\r
- L[_0] = 0;\r
- goto normal_bits;\r
-\r
- case STRTOG_Normal:\r
- case STRTOG_NaNbits:\r
- L[_0] = (UShort)(expt + 0x3fff + 63);\r
- normal_bits:\r
- L[_4] = (UShort)bits[0];\r
- L[_3] = (UShort)(bits[0] >> 16);\r
- L[_2] = (UShort)bits[1];\r
- L[_1] = (UShort)(bits[1] >> 16);\r
- break;\r
-\r
- case STRTOG_Infinite:\r
- L[_0] = 0x7fff;\r
- L[_1] = L[_2] = L[_3] = L[_4] = 0;\r
- break;\r
-\r
- case STRTOG_NaN:\r
- L[0] = ldus_QNAN0;\r
- L[1] = ldus_QNAN1;\r
- L[2] = ldus_QNAN2;\r
- L[3] = ldus_QNAN3;\r
- L[4] = ldus_QNAN4;\r
- }\r
- if (k & STRTOG_Neg)\r
- L[_0] |= 0x8000;\r
- return k;\r
- }\r