Improve documentation

The Cosmo API documentation page is pretty good now
https://justine.lol/cosmopolitan/documentation.html
This commit is contained in:
Justine Tunney 2020-12-27 07:02:35 -08:00
parent 13437dd19b
commit 1bc3a25505
367 changed files with 2542 additions and 26178 deletions

View file

@ -50,8 +50,8 @@ two letters:
and software emulations of Motorola 68xxx chips
that do not pad the way the 68xxx does, but
only store 80 bits
xL IEEE extended precision, as on Motorola 68xxx chips
Q quad precision, as on Sun Sparc chips
xL IEEE extended precision, as on Motorola 68xxx chips [jart: removed]
Q quad precision, as on Sun Sparc chips [jart: removed]
dd double double, pairs of IEEE double numbers
whose sum is the desired value

View file

@ -36,12 +36,8 @@ THIS SOFTWARE.
char *dtoa_result;
#endif
char *
#ifdef KR_headers
rv_alloc(i MTa) int i; MTk
#else
char *
rv_alloc(int i MTd)
#endif
{
int j, k, *r;
@ -59,12 +55,8 @@ rv_alloc(int i MTd)
(char *)(r+1);
}
char *
#ifdef KR_headers
nrv_alloc(s, rve, n MTa) char *s, **rve; int n; MTk
#else
char *
nrv_alloc(char *s, char **rve, int n MTd)
#endif
{
char *rv, *t;
@ -82,12 +74,8 @@ nrv_alloc(char *s, char **rve, int n MTd)
* when MULTIPLE_THREADS is not defined.
*/
void
#ifdef KR_headers
freedtoa(s) char *s;
#else
void
freedtoa(char *s)
#endif
{
#ifdef MULTIPLE_THREADS
ThInfo *TI = 0;
@ -101,13 +89,8 @@ freedtoa(char *s)
#endif
}
int
quorem
#ifdef KR_headers
(b, S) Bigint *b, *S;
#else
(Bigint *b, Bigint *S)
#endif
int
quorem(Bigint *b, Bigint *S)
{
int n;
ULong *bx, *bxe, q, *sx, *sxe;

View file

@ -73,14 +73,8 @@ THIS SOFTWARE.
#define Rounding Flt_Rounds
#endif
char *
dtoa
#ifdef KR_headers
(d0, mode, ndigits, decpt, sign, rve)
double d0; int mode, ndigits, *decpt, *sign; char **rve;
#else
(double d0, int mode, int ndigits, int *decpt, int *sign, char **rve)
#endif
char *
dtoa(double d0, int mode, int ndigits, int *decpt, int *sign, char **rve)
{
/* Arguments ndigits, decpt, sign are similar to those
of ecvt and fcvt; trailing zeros are suppressed from

View file

@ -1,120 +0,0 @@
#include "third_party/gdtoa/gdtoa.internal.h"
/* clang-format off */
/****************************************************************
The author of this software is David M. Gay.
Copyright (C) 1998, 2000 by Lucent Technologies
All Rights Reserved
Permission to use, copy, modify, and distribute this software and
its documentation for any purpose and without fee is hereby
granted, provided that the above copyright notice appear in all
copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of Lucent or any of its entities
not be used in advertising or publicity pertaining to
distribution of the software without specific, written prior
permission.
LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
****************************************************************/
/* Please send bug reports to David M. Gay (dmg at acm dot org,
* with " at " changed at "@" and " dot " changed to "."). */
#undef _0
#undef _1
/* one or the other of IEEE_MC68k or IEEE_8087 should be #defined */
#ifdef IEEE_MC68k
#define _0 0
#define _1 1
#define _2 2
#define _3 3
#endif
#ifdef IEEE_8087
#define _0 3
#define _1 2
#define _2 1
#define _3 0
#endif
char*
#ifdef KR_headers
g_Qfmt(buf, V, ndig, bufsize) char *buf; char *V; int ndig; size_t bufsize;
#else
g_Qfmt(char *buf, void *V, int ndig, size_t bufsize)
#endif
{
static const FPI fpi0 = { 113, 1-16383-113+1, 32766 - 16383 - 113 + 1, 1, 0, Int_max };
char *b, *s, *se;
ULong bits[4], *L, sign;
int decpt, ex, i, mode;
#ifdef Honor_FLT_ROUNDS
#include "third_party/gdtoa/gdtoa_fltrnds.inc"
#else
#define fpi &fpi0
#endif
if (ndig < 0)
ndig = 0;
if (bufsize < (size_t)(ndig + 10))
return 0;
L = (ULong*)V;
sign = L[_0] & 0x80000000L;
bits[3] = L[_0] & 0xffff;
bits[2] = L[_1];
bits[1] = L[_2];
bits[0] = L[_3];
b = buf;
if ( (ex = (L[_0] & 0x7fff0000L) >> 16) !=0) {
if (ex == 0x7fff) {
/* Infinity or NaN */
if (bits[0] | bits[1] | bits[2] | bits[3])
b = strcp(b, "NaN");
else {
b = buf;
if (sign)
*b++ = '-';
b = strcp(b, "Infinity");
}
return b;
}
i = STRTOG_Normal;
bits[3] |= 0x10000;
}
else if (bits[0] | bits[1] | bits[2] | bits[3]) {
i = STRTOG_Denormal;
ex = 1;
}
else {
#ifndef IGNORE_ZERO_SIGN
if (sign)
*b++ = '-';
#endif
*b++ = '0';
*b = 0;
return b;
}
ex -= 0x3fff + 112;
mode = 2;
if (ndig <= 0) {
if (bufsize < 48)
return 0;
mode = 0;
}
s = gdtoa(fpi, ex, bits, &i, mode, ndig, &decpt, &se);
return g__fmt(buf, s, se, decpt, sign, bufsize);
}

View file

@ -1,133 +0,0 @@
#include "third_party/gdtoa/gdtoa.internal.h"
/* clang-format off */
/****************************************************************
The author of this software is David M. Gay.
Copyright (C) 1998, 2000 by Lucent Technologies
All Rights Reserved
Permission to use, copy, modify, and distribute this software and
its documentation for any purpose and without fee is hereby
granted, provided that the above copyright notice appear in all
copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of Lucent or any of its entities
not be used in advertising or publicity pertaining to
distribution of the software without specific, written prior
permission.
LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
****************************************************************/
/* Please send bug reports to David M. Gay (dmg at acm dot org,
* with " at " changed at "@" and " dot " changed to "."). */
extern ULong NanDflt_Q_D2A[4];
#undef _0
#undef _1
/* one or the other of IEEE_MC68k or IEEE_8087 should be #defined */
#ifdef IEEE_MC68k
#define _0 0
#define _1 1
#define _2 2
#define _3 3
#endif
#ifdef IEEE_8087
#define _0 3
#define _1 2
#define _2 1
#define _3 0
#endif
char*
#ifdef KR_headers
g_Qfmt_p(buf, V, ndig, bufsize, nik) char *buf; char *V; int ndig; size_t bufsize; int nik;
#else
g_Qfmt_p(char *buf, void *V, int ndig, size_t bufsize, int nik)
#endif
{
static const FPI fpi0 = { 113, 1-16383-113+1, 32766 - 16383 - 113 + 1, 1, 0, Int_max };
char *b, *s, *se;
ULong bits[4], *L, sign;
int decpt, ex, i, mode;
#ifdef Honor_FLT_ROUNDS
#include "third_party/gdtoa/gdtoa_fltrnds.inc"
#else
#define fpi &fpi0
#endif
if (ndig < 0)
ndig = 0;
if (bufsize < (size_t)(ndig + 10))
return 0;
L = (ULong*)V;
sign = L[_0] & 0x80000000L;
bits[3] = L[_0] & 0xffff;
bits[2] = L[_1];
bits[1] = L[_2];
bits[0] = L[_3];
b = buf;
if ( (ex = (L[_0] & 0x7fff0000L) >> 16) !=0) {
if (ex == 0x7fff) {
/* Infinity or NaN */
if (nik < 0 || nik > 35)
nik = 0;
if (bits[0] | bits[1] | bits[2] | bits[3]) {
if (sign && nik < 18)
*b++ = '-';
b = strcp(b, NanName[nik%3]);
if (nik > 5 && (nik < 12
|| bits[0] != NanDflt_Q_D2A[0]
|| bits[1] != NanDflt_Q_D2A[1]
|| bits[2] != NanDflt_Q_D2A[2]
|| (bits[2] ^ NanDflt_Q_D2A[2]) & 0xffff))
b = add_nanbits(b, bufsize - (b-buf), bits, 4);
}
else {
b = buf;
if (sign)
*b++ = '-';
b = strcp(b, InfName[nik%6]);
}
return b;
}
i = STRTOG_Normal;
bits[3] |= 0x10000;
}
else if (bits[0] | bits[1] | bits[2] | bits[3]) {
i = STRTOG_Denormal;
ex = 1;
}
else {
#ifndef IGNORE_ZERO_SIGN
if (sign)
*b++ = '-';
#endif
*b++ = '0';
*b = 0;
return b;
}
ex -= 0x3fff + 112;
mode = 2;
if (ndig <= 0) {
if (bufsize < 48)
return 0;
mode = 0;
}
s = gdtoa(fpi, ex, bits, &i, mode, ndig, &decpt, &se);
return g__fmt(buf, s, se, decpt, sign, bufsize);
}

View file

@ -48,20 +48,16 @@ THIS SOFTWARE.
#define ldus_QNAN4 0
#endif
const char *const InfName[6] = { "Infinity", "infinity", "INFINITY", "Inf", "inf", "INF" };
const char *const NanName[3] = { "NaN", "nan", "NAN" };
const ULong NanDflt_Q_D2A[4] = { 0xffffffff, 0xffffffff, 0xffffffff, 0x7fffffff };
const ULong NanDflt_d_D2A[2] = { d_QNAN1, d_QNAN0 };
const ULong NanDflt_f_D2A[1] = { f_QNAN };
const ULong NanDflt_xL_D2A[3] = { 1, 0x80000000, 0x7fff0000 };
const UShort NanDflt_ldus_D2A[5] = { ldus_QNAN4, ldus_QNAN3, ldus_QNAN2, ldus_QNAN1, ldus_QNAN0 };
const char *const InfName[6] = { "Infinity", "infinity", "INFINITY", "Inf", "inf", "INF" };
const char *const NanName[3] = { "NaN", "nan", "NAN" };
const ULong __gdtoa_NanDflt_Q[4] = { 0xffffffff, 0xffffffff, 0xffffffff, 0x7fffffff };
const ULong __gdtoa_NanDflt_d[2] = { d_QNAN1, d_QNAN0 };
const ULong __gdtoa_NanDflt_f[1] = { f_QNAN };
const ULong __gdtoa_NanDflt_xL[3] = { 1, 0x80000000, 0x7fff0000 };
const UShort __gdtoa_NanDflt_ldus[5] = { ldus_QNAN4, ldus_QNAN3, ldus_QNAN2, ldus_QNAN1, ldus_QNAN0 };
char *
#ifdef KR_headers
g__fmt(b, s, se, decpt, sign, blen) char *b; char *s; char *se; int decpt; ULong sign; size_t blen;
#else
char *
g__fmt(char *b, char *s, char *se, int decpt, ULong sign, size_t blen)
#endif
{
int i, j, k;
char *be, *s0;
@ -168,7 +164,7 @@ g__fmt(char *b, char *s, char *se, int decpt, ULong sign, size_t blen)
}
char *
add_nanbits_D2A(char *b, size_t blen, ULong *bits, int nb)
__gdtoa_add_nanbits(char *b, size_t blen, ULong *bits, int nb)
{
ULong t;
char *rv;

View file

@ -31,12 +31,8 @@ THIS SOFTWARE.
/* Please send bug reports to David M. Gay (dmg@acm.org). */
char *
#ifdef KR_headers
g_ddfmt(buf, dd0, ndig, bufsize) char *buf; double *dd0; int ndig; size_t bufsize;
#else
char *
g_ddfmt(char *buf, double *dd0, int ndig, size_t bufsize)
#endif
{
FPI fpi;
char *b, *s, *se;

View file

@ -31,14 +31,10 @@ THIS SOFTWARE.
/* Please send bug reports to David M. Gay (dmg@acm.org). */
extern ULong NanDflt_d_D2A[2];
extern ULong __gdtoa_NanDflt_d[2];
char *
#ifdef KR_headers
g_ddfmt_p(buf, dd0, ndig, bufsize, nik) char *buf; double *dd0; int ndig; size_t bufsize; int nik;
#else
char *
g_ddfmt_p(char *buf, double *dd0, int ndig, size_t bufsize, int nik)
#endif
{
FPI fpi;
char *b, *s, *se;
@ -82,10 +78,10 @@ g_ddfmt_p(char *buf, double *dd0, int ndig, size_t bufsize, int nik)
*b++ = '-';
b = strcp(b, NanName[nik%3]);
if (nik > 5 && (nik < 12
|| L[_1] != NanDflt_d_D2A[0]
|| (L[_0] ^ NanDflt_d_D2A[1]) & 0xfffff
|| L[2+_1] != NanDflt_d_D2A[0]
|| (L[2+_0] ^ NanDflt_d_D2A[1]) & 0xfffff)) {
|| L[_1] != __gdtoa_NanDflt_d[0]
|| (L[_0] ^ __gdtoa_NanDflt_d[1]) & 0xfffff
|| L[2+_1] != __gdtoa_NanDflt_d[0]
|| (L[2+_0] ^ __gdtoa_NanDflt_d[1]) & 0xfffff)) {
bits0[0] = L[2+_1];
bits0[1] = (L[2+_0] & 0xfffff) | (L[_1] << 20);
bits0[2] = (L[_1] >> 12) | (L[_0] << 20);

View file

@ -32,12 +32,8 @@ THIS SOFTWARE.
/* Please send bug reports to David M. Gay (dmg at acm dot org,
* with " at " changed at "@" and " dot " changed to "."). */
char*
#ifdef KR_headers
g_dfmt(buf, d, ndig, bufsize) char *buf; double *d; int ndig; size_t bufsize;
#else
char*
g_dfmt(char *buf, double *d, int ndig, size_t bufsize)
#endif
{
static const FPI fpi0 = { 53, 1-1023-53+1, 2046-1023-53+1, 1, 0, Int_max };
char *b, *s, *se;

View file

@ -32,14 +32,10 @@ THIS SOFTWARE.
/* Please send bug reports to David M. Gay (dmg at acm dot org,
* with " at " changed at "@" and " dot " changed to "."). */
extern ULong NanDflt_d_D2A[2];
extern ULong __gdtoa_NanDflt_d[2];
char*
#ifdef KR_headers
g_dfmt_p(buf, d, ndig, bufsize, nik) char *buf; double *d; int ndig; size_t bufsize; int nik;
#else
char*
g_dfmt_p(char *buf, double *d, int ndig, size_t bufsize, int nik)
#endif
{
static const FPI fpi0 = { 53, 1-1023-53+1, 2046-1023-53+1, 1, 0, Int_max };
char *b, *s, *se;
@ -70,8 +66,8 @@ g_dfmt_p(char *buf, double *d, int ndig, size_t bufsize, int nik)
*b++ = '-';
b = strcp(b, NanName[nik%3]);
if (nik > 5 && (nik < 12
|| bits[0] != NanDflt_d_D2A[0]
|| (bits[1] ^ NanDflt_d_D2A[1]) & 0xfffff)) {
|| bits[0] != __gdtoa_NanDflt_d[0]
|| (bits[1] ^ __gdtoa_NanDflt_d[1]) & 0xfffff)) {
bits[0] = L[_1];
bits[1] = L[_0] & 0xfffff;
b = add_nanbits(b, bufsize - (b-buf), bits, 2);

View file

@ -32,12 +32,8 @@ THIS SOFTWARE.
/* Please send bug reports to David M. Gay (dmg at acm dot org,
* with " at " changed at "@" and " dot " changed to "."). */
char*
#ifdef KR_headers
g_ffmt(buf, f, ndig, bufsize) char *buf; float *f; int ndig; size_t bufsize;
#else
char*
g_ffmt(char *buf, float *f, int ndig, size_t bufsize)
#endif
{
static const FPI fpi0 = { 24, 1-127-24+1, 254-127-24+1, 1, 0, 6 };
char *b, *s, *se;

View file

@ -32,14 +32,10 @@ THIS SOFTWARE.
/* Please send bug reports to David M. Gay (dmg at acm dot org,
* with " at " changed at "@" and " dot " changed to "."). */
extern ULong NanDflt_f_D2A[1];
extern ULong __gdtoa_NanDflt_f[1];
char*
#ifdef KR_headers
g_ffmt_p(buf, f, ndig, bufsize, nik) char *buf; float *f; int ndig; size_t bufsize; int nik;
#else
char*
g_ffmt_p(char *buf, float *f, int ndig, size_t bufsize, int nik)
#endif
{
static const FPI fpi0 = { 24, 1-127-24+1, 254-127-24+1, 1, 0, 6 };
char *b, *s, *se;
@ -68,7 +64,7 @@ g_ffmt_p(char *buf, float *f, int ndig, size_t bufsize, int nik)
*b++ = '-';
b = strcp(b, NanName[nik%3]);
if (nik > 5 && (nik < 12
|| (bits[0] ^ NanDflt_f_D2A[0]) & 0x7fffff))
|| (bits[0] ^ __gdtoa_NanDflt_f[0]) & 0x7fffff))
b = add_nanbits(b, bufsize - (b-buf), bits, 1);
return b;
}

View file

@ -1,114 +0,0 @@
#include "third_party/gdtoa/gdtoa.internal.h"
/* clang-format off */
/****************************************************************
The author of this software is David M. Gay.
Copyright (C) 1998 by Lucent Technologies
All Rights Reserved
Permission to use, copy, modify, and distribute this software and
its documentation for any purpose and without fee is hereby
granted, provided that the above copyright notice appear in all
copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of Lucent or any of its entities
not be used in advertising or publicity pertaining to
distribution of the software without specific, written prior
permission.
LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
****************************************************************/
/* Please send bug reports to David M. Gay (dmg at acm dot org,
* with " at " changed at "@" and " dot " changed to "."). */
#undef _0
#undef _1
/* one or the other of IEEE_MC68k or IEEE_8087 should be #defined */
#ifdef IEEE_MC68k
#define _0 0
#define _1 1
#define _2 2
#endif
#ifdef IEEE_8087
#define _0 2
#define _1 1
#define _2 0
#endif
char*
#ifdef KR_headers
g_xLfmt(buf, V, ndig, bufsize) char *buf; char *V; int ndig; size_t bufsize;
#else
g_xLfmt(char *buf, void *V, int ndig, size_t bufsize)
#endif
{
static const FPI fpi0 = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, 0, Int_max };
char *b, *s, *se;
ULong bits[2], *L, sign;
int decpt, ex, i, mode;
#ifdef Honor_FLT_ROUNDS
#include "third_party/gdtoa/gdtoa_fltrnds.inc"
#else
#define fpi &fpi0
#endif
if (ndig < 0)
ndig = 0;
if (bufsize < (size_t)(ndig + 10))
return 0;
L = (ULong*)V;
sign = L[_0] & 0x80000000L;
bits[1] = L[_1];
bits[0] = L[_2];
if ( (ex = (L[_0] >> 16) & 0x7fff) !=0) {
if (ex == 0x7fff) {
/* Infinity or NaN */
if (bits[0] | bits[1])
b = strcp(buf, "NaN");
else {
b = buf;
if (sign)
*b++ = '-';
b = strcp(b, "Infinity");
}
return b;
}
i = STRTOG_Normal;
}
else if (bits[0] | bits[1]) {
i = STRTOG_Denormal;
}
else {
b = buf;
#ifndef IGNORE_ZERO_SIGN
if (sign)
*b++ = '-';
#endif
*b++ = '0';
*b = 0;
return b;
}
ex -= 0x3fff + 63;
mode = 2;
if (ndig <= 0) {
if (bufsize < 32)
return 0;
mode = 0;
}
s = gdtoa(fpi, ex, bits, &i, mode, ndig, &decpt, &se);
return g__fmt(buf, s, se, decpt, sign, bufsize);
}

View file

@ -1,126 +0,0 @@
#include "third_party/gdtoa/gdtoa.internal.h"
/* clang-format off */
/****************************************************************
The author of this software is David M. Gay.
Copyright (C) 1998 by Lucent Technologies
All Rights Reserved
Permission to use, copy, modify, and distribute this software and
its documentation for any purpose and without fee is hereby
granted, provided that the above copyright notice appear in all
copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of Lucent or any of its entities
not be used in advertising or publicity pertaining to
distribution of the software without specific, written prior
permission.
LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
****************************************************************/
/* Please send bug reports to David M. Gay (dmg at acm dot org,
* with " at " changed at "@" and " dot " changed to "."). */
extern ULong NanDflt_xL_D2A[3];
#undef _0
#undef _1
/* one or the other of IEEE_MC68k or IEEE_8087 should be #defined */
#ifdef IEEE_MC68k
#define _0 0
#define _1 1
#define _2 2
#endif
#ifdef IEEE_8087
#define _0 2
#define _1 1
#define _2 0
#endif
char*
#ifdef KR_headers
g_xLfmt_p(buf, V, ndig, bufsize, nik) char *buf; char *V; int ndig; size_t bufsize; int nik;
#else
g_xLfmt_p(char *buf, void *V, int ndig, size_t bufsize, int nik)
#endif
{
static const FPI fpi0 = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, 0, Int_max };
char *b, *s, *se;
ULong bits[2], *L, sign;
int decpt, ex, i, mode;
#ifdef Honor_FLT_ROUNDS
#include "third_party/gdtoa/gdtoa_fltrnds.inc"
#else
#define fpi &fpi0
#endif
if (ndig < 0)
ndig = 0;
if (bufsize < (size_t)(ndig + 10))
return 0;
L = (ULong*)V;
sign = L[_0] & 0x80000000L;
bits[1] = L[_1];
bits[0] = L[_2];
if ( (ex = (L[_0] >> 16) & 0x7fff) !=0) {
if (ex == 0x7fff) {
/* Infinity or NaN */
if (nik < 0 || nik > 35)
nik = 0;
if (!bits[0] && bits[1] == 0x80000000) {
b = buf;
if (sign)
*b++ = '-';
b = strcp(b, InfName[nik%6]);
}
else {
b = buf;
if (sign && nik < 18)
*b++ = '-';
b = strcp(b, NanName[nik%3]);
if (nik > 5 && (nik < 12
|| bits[0] != NanDflt_xL_D2A[0]
|| bits[1] != NanDflt_xL_D2A[1]))
b = add_nanbits(b, bufsize - (b-buf), bits, 2);
}
return b;
}
i = STRTOG_Normal;
}
else if (bits[0] | bits[1]) {
i = STRTOG_Denormal;
}
else {
b = buf;
#ifndef IGNORE_ZERO_SIGN
if (sign)
*b++ = '-';
#endif
*b++ = '0';
*b = 0;
return b;
}
ex -= 0x3fff + 63;
mode = 2;
if (ndig <= 0) {
if (bufsize < 32)
return 0;
mode = 0;
}
s = gdtoa(fpi, ex, bits, &i, mode, ndig, &decpt, &se);
return g__fmt(buf, s, se, decpt, sign, bufsize);
}

View file

@ -52,12 +52,8 @@ THIS SOFTWARE.
#define _4 0
#endif
char*
#ifdef KR_headers
g_xfmt(buf, V, ndig, bufsize) char *buf; char *V; int ndig; size_t bufsize;
#else
char*
g_xfmt(char *buf, void *V, int ndig, size_t bufsize)
#endif
{
static const FPI fpi0 = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, 0, Int_max };
char *b, *s, *se;

View file

@ -32,7 +32,7 @@ THIS SOFTWARE.
/* Please send bug reports to David M. Gay (dmg at acm dot org,
* with " at " changed at "@" and " dot " changed to "."). */
extern UShort NanDflt_ldus_D2A[5];
extern UShort __gdtoa_NanDflt_ldus[5];
#undef _0
#undef _1
@ -54,12 +54,8 @@ THIS SOFTWARE.
#define _4 0
#endif
char*
#ifdef KR_headers
g_xfmt_p(buf, V, ndig, bufsize, nik) char *buf; char *V; int ndig; size_t bufsize; int nik;
#else
char*
g_xfmt_p(char *buf, void *V, int ndig, size_t bufsize, int nik)
#endif
{
static const FPI fpi0 = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, 0, Int_max };
char *b, *s, *se;
@ -98,10 +94,10 @@ g_xfmt_p(char *buf, void *V, int ndig, size_t bufsize, int nik)
*b++ = '-';
b = strcp(b, NanName[nik%3]);
if (nik > 5 && (nik < 12
|| L[_1] != NanDflt_ldus_D2A[3]
|| L[_2] != NanDflt_ldus_D2A[2]
|| L[_3] != NanDflt_ldus_D2A[1]
|| L[_4] != NanDflt_ldus_D2A[0])) {
|| L[_1] != __gdtoa_NanDflt_ldus[3]
|| L[_2] != __gdtoa_NanDflt_ldus[2]
|| L[_3] != __gdtoa_NanDflt_ldus[1]
|| L[_4] != __gdtoa_NanDflt_ldus[0])) {
bits[1] &= 0x7fffffff;
b = add_nanbits(b, bufsize - (b-buf), bits, 2);
}

View file

@ -32,12 +32,8 @@ THIS SOFTWARE.
/* Please send bug reports to David M. Gay (dmg at acm dot org,
* with " at " changed at "@" and " dot " changed to "."). */
static Bigint *
#ifdef KR_headers
bitstob(bits, nbits, bbits MTa) ULong *bits; int nbits; int *bbits; MTk
#else
static Bigint *
bitstob(ULong *bits, int nbits, int *bbits MTd)
#endif
{
int i, k;
Bigint *b;
@ -109,15 +105,8 @@ bitstob(ULong *bits, int nbits, int *bbits MTd)
* calculation.
*/
char *
gdtoa
#ifdef KR_headers
(fpi, be, bits, kindp, mode, ndigits, decpt, rve)
CONST FPI *fpi; int be; ULong *bits;
int *kindp, mode, ndigits, *decpt; char **rve;
#else
(CONST FPI *fpi, int be, ULong *bits, int *kindp, int mode, int ndigits, int *decpt, char **rve)
#endif
char *
gdtoa(CONST FPI *fpi, int be, ULong *bits, int *kindp, int mode, int ndigits, int *decpt, char **rve)
{
/* Arguments ndigits and decpt are similar to the second and third
arguments of ecvt and fcvt; trailing zeros are suppressed from

View file

@ -137,7 +137,6 @@ THIS SOFTWARE.
* something other than "long long", #define Llong to be the name,
* and if "unsigned Llong" does not work as an unsigned version of
* Llong, #define #ULLong to be the corresponding unsigned type.
* #define KR_headers for old-style C function headers.
* #define Bad_float_h if your system lacks a float.h or if it does not
* define some or all of DBL_DIG, DBL_MAX_10_EXP, DBL_MAX_EXP,
* FLT_RADIX, FLT_ROUNDS, and DBL_MAX.
@ -220,16 +219,6 @@ THIS SOFTWARE.
* #define USE_LOCALE to use the current locale's decimal_point value.
*/
#ifndef ANSI
#ifdef KR_headers
#define ANSI(x) ()
#define Void /*nothing*/
#else
#define ANSI(x) x
#define Void void
#endif
#endif /* ANSI */
#ifndef Long
#define Long int
#endif
@ -241,11 +230,7 @@ typedef unsigned short UShort;
#endif
#ifndef CONST
#ifdef KR_headers
#define CONST /* blank */
#else
#define CONST const
#endif
#endif /* CONST */
#ifdef DEBUG
@ -256,20 +241,20 @@ typedef unsigned short UShort;
}
#endif
#ifdef KR_headers
#define Char char
#else
/* #ifdef KR_headers */
/* #define Char char */
/* #else */
#define Char void
#endif
/* #endif */
#ifdef MALLOC
extern Char *MALLOC ANSI((size_t));
extern Char *MALLOC(size_t);
#else
#define MALLOC malloc
#endif
#ifdef REALLOC
extern Char *REALLOC ANSI((Char *, size_t));
extern Char *REALLOC(Char *, size_t);
#else
#define REALLOC realloc
#endif
@ -476,11 +461,7 @@ Exactly one of IEEE_8087, IEEE_MC68k, VAX, or IBM should be defined.
#ifdef RND_PRODQUOT
#define rounded_product(a, b) a = rnd_prod(a, b)
#define rounded_quotient(a, b) a = rnd_quot(a, b)
#ifdef KR_headers
extern double rnd_prod(), rnd_quot();
#else
extern double rnd_prod(double, double), rnd_quot(double, double);
#endif
#else
#define rounded_product(a, b) a *= b
#define rounded_quotient(a, b) a /= b
@ -531,9 +512,9 @@ extern double rnd_prod(double, double), rnd_quot(double, double);
#define MTb , &TI
#define MTd , ThInfo **PTI
#define MTk ThInfo **PTI;
extern void ACQUIRE_DTOA_LOCK ANSI((unsigned int));
extern void FREE_DTOA_LOCK ANSI((unsigned int));
extern unsigned int dtoa_get_threadno ANSI((void));
extern void ACQUIRE_DTOA_LOCK(unsigned int);
extern void FREE_DTOA_LOCK(unsigned int);
extern unsigned int dtoa_get_threadno(void);
#else /*}{*/
#define ACQUIRE_DTOA_LOCK(n) /*nothing*/
#define FREE_DTOA_LOCK(n) /*nothing*/
@ -562,111 +543,114 @@ typedef struct ThInfo {
#ifdef DECLARE_SIZE_T
typedef unsigned int size_t;
#endif
extern void memcpy_D2A ANSI((void *, const void *, size_t));
extern void __gdtoa_memcpy(void *, const void *, size_t);
#define Bcopy(x, y) \
memcpy_D2A(&x->sign, &y->sign, y->wds * sizeof(ULong) + 2 * sizeof(int))
__gdtoa_memcpy(&x->sign, &y->sign, y->wds * sizeof(ULong) + 2 * sizeof(int))
#else /* !NO_STRING_H */
#define Bcopy(x, y) \
memcpy(&x->sign, &y->sign, y->wds * sizeof(ULong) + 2 * sizeof(int))
#endif /* NO_STRING_H */
#define Balloc Balloc_D2A
#define Bfree Bfree_D2A
#define InfName InfName_D2A
#define NanName NanName_D2A
#define ULtoQ ULtoQ_D2A
#define ULtof ULtof_D2A
#define ULtod ULtod_D2A
#define ULtodd ULtodd_D2A
#define ULtox ULtox_D2A
#define ULtoxL ULtoxL_D2A
#define add_nanbits add_nanbits_D2A
#define any_on any_on_D2A
#define b2d b2d_D2A
#define bigtens bigtens_D2A
#define cmp cmp_D2A
#define copybits copybits_D2A
#define d2b d2b_D2A
#define decrement decrement_D2A
#define diff diff_D2A
#define dtoa_result dtoa_result_D2A
#define g__fmt g__fmt_D2A
#define gethex gethex_D2A
#define hexdig hexdig_D2A
#define hexnan hexnan_D2A
#define hi0bits(x) hi0bits_D2A((ULong)(x))
#define i2b i2b_D2A
#define increment increment_D2A
#define lo0bits lo0bits_D2A
#define lshift lshift_D2A
#define match match_D2A
#define mult mult_D2A
#define multadd multadd_D2A
#define nrv_alloc nrv_alloc_D2A
#define pow5mult pow5mult_D2A
#define quorem quorem_D2A
#define ratio ratio_D2A
#define rshift rshift_D2A
#define rv_alloc rv_alloc_D2A
#define s2b s2b_D2A
#define set_ones set_ones_D2A
#define strcp strcp_D2A
#define strtoIg strtoIg_D2A
#define sum sum_D2A
#define tens tens_D2A
#define tinytens tinytens_D2A
#define tinytens tinytens_D2A
#define trailz trailz_D2A
#define ulp ulp_D2A
#define Balloc __gdtoa_Balloc
#define Bfree __gdtoa_Bfree
#define InfName __gdtoa_InfName
#define NanName __gdtoa_NanName
#define ULtoQ __gdtoa_ULtoQ
#define ULtof __gdtoa_ULtof
#define ULtod __gdtoa_ULtod
#define ULtodd __gdtoa_ULtodd
#define ULtox __gdtoa_ULtox
#define ULtoxL __gdtoa_ULtoxL
#define add_nanbits __gdtoa_add_nanbits
#define any_on __gdtoa_any_on
#define b2d __gdtoa_b2d
#define bigtens __gdtoa_bigtens
#define cmp __gdtoa_cmp
#define copybits __gdtoa_copybits
#define d2b __gdtoa_d2b
#define decrement __gdtoa_decrement
#define diff __gdtoa_diff
#define dtoa_result __gdtoa_dtoa_result
#define g__fmt __gdtoa_g__fmt
#define gethex __gdtoa_gethex
#define hexdig __gdtoa_hexdig
#define hexnan __gdtoa_hexnan
#define hi0bits(x) __gdtoa_hi0bits((ULong)(x))
#define i2b __gdtoa_i2b
#define increment __gdtoa_increment
#define lo0bits __gdtoa_lo0bits
#define lshift __gdtoa_lshift
#define match __gdtoa_match
#define mult __gdtoa_mult
#define multadd __gdtoa_multadd
#define nrv_alloc __gdtoa_nrv_alloc
#define pow5mult __gdtoa_pow5mult
#define quorem __gdtoa_quorem
#define ratio __gdtoa_ratio
#define rshift __gdtoa_rshift
#define rv_alloc __gdtoa_rv_alloc
#define s2b __gdtoa_s2b
#define set_ones __gdtoa_set_ones
#define strcp __gdtoa_strcp
#define strtoIg __gdtoa_strtoIg
#define sum __gdtoa_sum
#define tens __gdtoa_tens
#define tinytens __gdtoa_tinytens
#define tinytens __gdtoa_tinytens
#define trailz __gdtoa_trailz
#define ulp __gdtoa_ulp
extern char *add_nanbits ANSI((char *, size_t, ULong *, int));
extern char *dtoa_result;
extern CONST double bigtens[], tens[], tinytens[];
extern const unsigned char hexdig[];
extern const char *const InfName[6], *const NanName[3];
extern char *add_nanbits(char *, size_t, ULong *, int);
extern Bigint *Balloc ANSI((int MTd));
extern void Bfree ANSI((Bigint * MTd));
extern void ULtof ANSI((ULong *, ULong *, Long, int));
extern void ULtod ANSI((ULong *, ULong *, Long, int));
extern void ULtodd ANSI((ULong *, ULong *, Long, int));
extern void ULtoQ ANSI((ULong *, ULong *, Long, int));
extern void ULtox ANSI((UShort *, ULong *, Long, int));
extern void ULtoxL ANSI((ULong *, ULong *, Long, int));
extern ULong any_on ANSI((Bigint *, int));
extern double b2d ANSI((Bigint *, int *));
extern int cmp ANSI((Bigint *, Bigint *));
extern void copybits ANSI((ULong *, int, Bigint *));
extern Bigint *d2b ANSI((double, int *, int *MTd));
extern void decrement ANSI((Bigint *));
extern Bigint *diff ANSI((Bigint *, Bigint *MTd));
extern char *g__fmt ANSI((char *, char *, char *, int, ULong, size_t));
extern int gethex ANSI((CONST char **, CONST FPI *, Long *, Bigint **,
int MTd));
extern void hexdig_init_D2A(Void);
extern int hexnan ANSI((CONST char **, CONST FPI *, ULong *));
extern int hi0bits_D2A ANSI((ULong));
extern Bigint *i2b ANSI((int MTd));
extern Bigint *increment ANSI((Bigint * MTd));
extern int lo0bits ANSI((ULong *));
extern Bigint *lshift ANSI((Bigint *, int MTd));
extern int match ANSI((CONST char **, char *));
extern Bigint *mult ANSI((Bigint *, Bigint *MTd));
extern Bigint *multadd ANSI((Bigint *, int, int MTd));
extern char *nrv_alloc ANSI((char *, char **, int MTd));
extern Bigint *pow5mult ANSI((Bigint *, int MTd));
extern int quorem ANSI((Bigint *, Bigint *));
extern double ratio ANSI((Bigint *, Bigint *));
extern void rshift ANSI((Bigint *, int));
extern char *rv_alloc ANSI((int MTd));
extern Bigint *s2b ANSI((CONST char *, int, int, ULong, int MTd));
extern Bigint *set_ones ANSI((Bigint *, int MTd));
extern char *strcp ANSI((char *, const char *));
extern int strtoIg ANSI((CONST char *, char **, CONST FPI *, Long *, Bigint **,
int *));
extern Bigint *sum ANSI((Bigint *, Bigint *MTd));
extern int trailz ANSI((Bigint *));
extern double ulp ANSI((U *));
hidden extern char *dtoa_result;
hidden extern CONST double bigtens[];
hidden extern CONST double tens[];
hidden extern CONST double tinytens[];
hidden extern const unsigned char hexdig[];
hidden extern const char *const InfName[6];
hidden extern const char *const NanName[3];
extern Bigint *Balloc(int MTd);
extern void Bfree(Bigint *MTd);
extern void ULtof(ULong *, ULong *, Long, int);
extern void ULtod(ULong *, ULong *, Long, int);
extern void ULtodd(ULong *, ULong *, Long, int);
extern void ULtoQ(ULong *, ULong *, Long, int);
extern void ULtox(UShort *, ULong *, Long, int);
extern void ULtoxL(ULong *, ULong *, Long, int);
extern ULong any_on(Bigint *, int);
extern double b2d(Bigint *, int *);
extern int cmp(Bigint *, Bigint *);
extern void copybits(ULong *, int, Bigint *);
extern Bigint *d2b(double, int *, int *MTd);
extern void decrement(Bigint *);
extern Bigint *diff(Bigint *, Bigint *MTd);
extern char *g__fmt(char *, char *, char *, int, ULong, size_t);
extern int gethex(CONST char **, CONST FPI *, Long *, Bigint **, int MTd);
extern void __gdtoa_hexdig_init(void);
extern int hexnan(CONST char **, CONST FPI *, ULong *);
extern int __gdtoa_hi0bits(ULong);
extern Bigint *i2b(int MTd);
extern Bigint *increment(Bigint *MTd);
extern int lo0bits(ULong *);
extern Bigint *lshift(Bigint *, int MTd);
extern int match(CONST char **, char *);
extern Bigint *mult(Bigint *, Bigint *MTd);
extern Bigint *multadd(Bigint *, int, int MTd);
extern char *nrv_alloc(char *, char **, int MTd);
extern Bigint *pow5mult(Bigint *, int MTd);
extern int quorem(Bigint *, Bigint *);
extern double ratio(Bigint *, Bigint *);
extern void rshift(Bigint *, int);
extern char *rv_alloc(int MTd);
extern Bigint *s2b(CONST char *, int, int, ULong, int MTd);
extern Bigint *set_ones(Bigint *, int MTd);
extern char *strcp(char *, const char *);
extern int strtoIg(CONST char *, char **, CONST FPI *, Long *, Bigint **,
int *);
extern Bigint *sum(Bigint *, Bigint *MTd);
extern int trailz(Bigint *);
extern double ulp(U *);
#ifdef __cplusplus
}

View file

@ -33,13 +33,8 @@ THIS SOFTWARE.
/* Please send bug reports to David M. Gay (dmg at acm dot org,
* with " at " changed at "@" and " dot " changed to "."). */
int
#ifdef KR_headers
gethex(sp, fpi, exp, bp, sign MTa)
CONST char **sp; CONST FPI *fpi; Long *exp; Bigint **bp; int sign; MTk
#else
int
gethex( CONST char **sp, CONST FPI *fpi, Long *exp, Bigint **bp, int sign MTd)
#endif
{
Bigint *b;
CONST unsigned char *decpt, *s0, *s, *s1;
@ -64,7 +59,7 @@ gethex( CONST char **sp, CONST FPI *fpi, Long *exp, Bigint **bp, int sign MTd)
#endif
#endif
/**** if (!hexdig['0']) hexdig_init_D2A(); ****/
/**** if (!hexdig['0']) __gdtoa_hexdig_init(); ****/
*bp = 0;
havedig = 0;
s0 = *(CONST unsigned char **)sp + 2;

View file

@ -32,12 +32,8 @@ THIS SOFTWARE.
/* Please send bug reports to David M. Gay (dmg at acm dot org,
* with " at " changed at "@" and " dot " changed to "."). */
void
#ifdef KR_headers
rshift(b, k) Bigint *b; int k;
#else
void
rshift(Bigint *b, int k)
#endif
{
ULong *x, *x1, *xe, y;
int n;
@ -65,12 +61,8 @@ rshift(Bigint *b, int k)
b->x[0] = 0;
}
int
#ifdef KR_headers
trailz(b) Bigint *b;
#else
int
trailz(Bigint *b)
#endif
{
ULong L, *x, *xe;
int n = 0;

View file

@ -33,23 +33,19 @@ THIS SOFTWARE.
* with " at " changed at "@" and " dot " changed to "."). */
#if 0
unsigned char hexdig[256];
unsigned char hexdig[256];
static void
#ifdef KR_headers
htinit(h, s, inc) unsigned char *h; unsigned char *s; int inc;
#else
static void
htinit(unsigned char *h, unsigned char *s, int inc)
#endif
{
int i, j;
for(i = 0; (j = s[i]) !=0; i++)
h[j] = i + inc;
}
void
hexdig_init_D2A(Void) /* Use of hexdig_init omitted 20121220 to avoid a */
/* race condition when multiple threads are used. */
void
__gdtoa_hexdig_init(Void) /* Use of hexdig_init omitted 20121220 to avoid a */
/* race condition when multiple threads are used. */
{
#define USC (unsigned char *)
htinit(hexdig, USC "0123456789", 0x10);
@ -57,7 +53,7 @@ hexdig_init_D2A(Void) /* Use of hexdig_init omitted 20121220 to avoid a */
htinit(hexdig, USC "ABCDEF", 0x10 + 10);
}
#else
const unsigned char hexdig[256] = {
const unsigned char hexdig[256] = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,

View file

@ -32,12 +32,8 @@ THIS SOFTWARE.
/* Please send bug reports to David M. Gay (dmg at acm dot org,
* with " at " changed at "@" and " dot " changed to "."). */
static void
#ifdef KR_headers
L_shift(x, x1, i) ULong *x; ULong *x1; int i;
#else
static void
L_shift(ULong *x, ULong *x1, int i)
#endif
{
int j;
@ -50,19 +46,14 @@ L_shift(ULong *x, ULong *x1, int i)
} while(++x < x1);
}
int
#ifdef KR_headers
hexnan(sp, fpi, x0)
CONST char **sp; CONST FPI *fpi; ULong *x0;
#else
int
hexnan( CONST char **sp, CONST FPI *fpi, ULong *x0)
#endif
{
ULong c, h, *x, *x1, *xe;
CONST char *s;
int havedig, hd0, i, nbits;
/**** if (!hexdig['0']) hexdig_init_D2A(); ****/
/**** if (!hexdig['0']) __gdtoa_hexdig_init(); ****/
nbits = fpi->nbits;
x = x0 + (nbits >> kshift);
if (nbits & kmask)

View file

@ -90,13 +90,8 @@ get_TI(void)
#define p5s TI0.P5s
#endif /*}}*/
Bigint *
Balloc
#ifdef KR_headers
(k MTa) int k; MTk
#else
(int k MTd)
#endif
Bigint *
Balloc(int k MTd)
{
int x;
Bigint *rv;
@ -152,13 +147,8 @@ Balloc
return rv;
}
void
Bfree
#ifdef KR_headers
(v MTa) Bigint *v; MTk
#else
(Bigint *v MTd)
#endif
void
Bfree(Bigint *v MTd)
{
#ifdef MULTIPLE_THREADS
ThInfo *TI;
@ -187,13 +177,8 @@ Bfree
}
}
int
lo0bits
#ifdef KR_headers
(y) ULong *y;
#else
(ULong *y)
#endif
int
lo0bits(ULong *y)
{
int k;
ULong x = *y;
@ -235,13 +220,8 @@ lo0bits
return k;
}
Bigint *
multadd
#ifdef KR_headers
(b, m, a MTa) Bigint *b; int m, a; MTk
#else
(Bigint *b, int m, int a MTd) /* multiply by m and add a */
#endif
Bigint *
multadd(Bigint *b, int m, int a MTd) /* multiply by m and add a */
{
int i, wds;
#ifdef ULLong
@ -292,13 +272,8 @@ multadd
return b;
}
int
hi0bits_D2A
#ifdef KR_headers
(x) ULong x;
#else
(ULong x)
#endif
int
__gdtoa_hi0bits(ULong x)
{
int k = 0;
@ -326,13 +301,8 @@ hi0bits_D2A
return k;
}
Bigint *
i2b
#ifdef KR_headers
(i MTa) int i; MTk
#else
(int i MTd)
#endif
Bigint *
i2b(int i MTd)
{
Bigint *b;
@ -342,13 +312,8 @@ i2b
return b;
}
Bigint *
mult
#ifdef KR_headers
(a, b MTa) Bigint *a, *b; MTk
#else
(Bigint *a, Bigint *b MTd)
#endif
Bigint *
mult(Bigint *a, Bigint *b MTd)
{
Bigint *c;
int k, wa, wb, wc;
@ -452,13 +417,8 @@ mult
return c;
}
Bigint *
pow5mult
#ifdef KR_headers
(b, k MTa) Bigint *b; int k; MTk
#else
(Bigint *b, int k MTd)
#endif
Bigint *
pow5mult(Bigint *b, int k MTd)
{
Bigint *b1, *p5, *p51;
#ifdef MULTIPLE_THREADS
@ -524,13 +484,8 @@ pow5mult
return b;
}
Bigint *
lshift
#ifdef KR_headers
(b, k MTa) Bigint *b; int k; MTk
#else
(Bigint *b, int k MTd)
#endif
Bigint *
lshift(Bigint *b, int k MTd)
{
int i, k1, n, n1;
Bigint *b1;
@ -578,13 +533,8 @@ lshift
return b1;
}
int
cmp
#ifdef KR_headers
(a, b) Bigint *a, *b;
#else
(Bigint *a, Bigint *b)
#endif
int
cmp(Bigint *a, Bigint *b)
{
ULong *xa, *xa0, *xb, *xb0;
int i, j;
@ -612,13 +562,8 @@ cmp
return 0;
}
Bigint *
diff
#ifdef KR_headers
(a, b MTa) Bigint *a, *b; MTk
#else
(Bigint *a, Bigint *b MTd)
#endif
Bigint *
diff(Bigint *a, Bigint *b MTd)
{
Bigint *c;
int i, wa, wb;
@ -706,13 +651,8 @@ diff
return c;
}
double
b2d
#ifdef KR_headers
(a, e) Bigint *a; int *e;
#else
(Bigint *a, int *e)
#endif
double
b2d(Bigint *a, int *e)
{
ULong *xa, *xa0, w, y, z;
int k;
@ -775,13 +715,8 @@ b2d
#undef d0
#undef d1
Bigint *
d2b
#ifdef KR_headers
(dd, e, bits MTa) double dd; int *e, *bits; MTk
#else
(double dd, int *e, int *bits MTd)
#endif
Bigint *
d2b(double dd, int *e, int *bits MTd)
{
Bigint *b;
U d;
@ -913,7 +848,7 @@ d2b
#undef d0
#undef d1
CONST double
CONST double
#ifdef IEEE_Arith
bigtens[] = { 1e16, 1e32, 1e64, 1e128, 1e256 };
CONST double tinytens[] = { 1e-16, 1e-32, 1e-64, 1e-128, 1e-256
@ -928,7 +863,7 @@ CONST double tinytens[] = { 1e-16, 1e-32 };
#endif
#endif
CONST double
CONST double
tens[] = {
1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9,
1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19,
@ -938,12 +873,8 @@ tens[] = {
#endif
};
char *
#ifdef KR_headers
strcp_D2A(a, b) char *a; char *b;
#else
strcp_D2A(char *a, CONST char *b)
#endif
char *
__gdtoa_strcp(char *a, CONST char *b)
{
while((*a = *b++))
a++;
@ -952,12 +883,8 @@ strcp_D2A(char *a, CONST char *b)
#ifdef NO_STRING_H
Char *
#ifdef KR_headers
memcpy_D2A(a, b, len) Char *a; Char *b; size_t len;
#else
memcpy_D2A(void *a1, void *b1, size_t len)
#endif
Char *
__gdtoa_memcpy(void *a1, void *b1, size_t len)
{
char *a = (char*)a1, *ae = a + len;
char *b = (char*)b1, *a0 = a;

View file

@ -1,10 +0,0 @@
/* clang-format off */
#ifdef __sun
#define Use_GDTOA_Qtype
#else
#if defined(__i386) || defined(__x86_64)
#define Use_GDTOA_for_i386_long_double
#endif
#endif
#include "third_party/gdtoa/printf.c0"

File diff suppressed because it is too large Load diff

View file

@ -32,13 +32,8 @@ THIS SOFTWARE.
/* Please send bug reports to David M. Gay (dmg at acm dot org,
* with " at " changed at "@" and " dot " changed to "."). */
Bigint *
s2b
#ifdef KR_headers
(s, nd0, nd, y9, dplen MTa) CONST char *s; int dplen, nd0, nd; ULong y9; MTk
#else
(CONST char *s, int nd0, int nd, ULong y9, int dplen MTd)
#endif
Bigint *
s2b(CONST char *s, int nd0, int nd, ULong y9, int dplen MTd)
{
Bigint *b;
int i, k;
@ -70,13 +65,8 @@ s2b
return b;
}
double
ratio
#ifdef KR_headers
(a, b) Bigint *a, *b;
#else
(Bigint *a, Bigint *b)
#endif
double
ratio(Bigint *a, Bigint *b)
{
U da, db;
int k, ka, kb;
@ -109,13 +99,8 @@ ratio
#ifdef INFNAN_CHECK
int
match
#ifdef KR_headers
(sp, t) char **sp, *t;
#else
(CONST char **sp, char *t)
#endif
int
match(CONST char **sp, char *t)
{
int c, d;
CONST char *s = *sp;
@ -131,12 +116,8 @@ match
}
#endif /* INFNAN_CHECK */
void
#ifdef KR_headers
copybits(c, n, b) ULong *c; int n; Bigint *b;
#else
void
copybits(ULong *c, int n, Bigint *b)
#endif
{
ULong *ce, *x, *xe;
#ifdef Pack_16
@ -161,12 +142,8 @@ copybits(ULong *c, int n, Bigint *b)
*c++ = 0;
}
ULong
#ifdef KR_headers
any_on(b, k) Bigint *b; int k;
#else
ULong
any_on(Bigint *b, int k)
#endif
{
int n, nwds;
ULong *x, *x0, x1, x2;

View file

@ -1,106 +0,0 @@
#include "libc/stdio/stdio.h"
/****************************************************************
Copyright (C) 1997-1999 Lucent Technologies
All Rights Reserved
Permission to use, copy, modify, and distribute this software and
its documentation for any purpose and without fee is hereby
granted, provided that the above copyright notice appear in all
copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of Lucent or any of its entities
not be used in advertising or publicity pertaining to
distribution of the software without specific, written prior
permission.
LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
****************************************************************/
/* stdio1.h -- for using Printf, Fprintf, Sprintf while
* retaining the system-supplied printf, fprintf, sprintf.
*/
#ifndef STDIO1_H_included
#define STDIO1_H_included
#ifndef STDIO_H_included /* allow suppressing stdio.h */
#endif /* e.g., by cplex.h */
#ifdef KR_headers
#ifndef _SIZE_T
#define _SIZE_T
typedef unsigned int size_t;
#endif
#define ANSI(x) ()
#ifndef Char
#define Char char
#endif
#else
#define ANSI(x) x
#ifndef Char
#define Char void
#endif
#endif
#ifndef NO_STDIO1
#ifdef _WIN32
/* Avoid Microsoft bug that perrror may appear in stdlib.h. */
/* It should only be declared in stdio.h. */
#endif
#ifdef __cplusplus
extern "C" {
#endif
extern int Fprintf ANSI((FILE *, const char *, ...));
extern int Printf ANSI((const char *, ...));
extern int Sprintf ANSI((char *, const char *, ...));
extern int Snprintf ANSI((char *, size_t, const char *, ...));
extern void Perror ANSI((const char *));
extern int Vfprintf ANSI((FILE *, const char *, va_list));
extern int Vsprintf ANSI((char *, const char *, va_list));
extern int Vsnprintf ANSI((char *, size_t, const char *, va_list));
#ifdef PF_BUF
extern FILE *stderr_ASL;
extern void(*pfbuf_print_ASL) ANSI((char *));
extern char *pfbuf_ASL;
extern void fflush_ASL ANSI((FILE *));
#ifdef fflush
#define old_fflush_ASL fflush
#undef fflush
#endif
#define fflush fflush_ASL
#endif
#ifdef __cplusplus
}
#endif
#undef printf
#undef fprintf
#undef sprintf
#undef perror
#undef vfprintf
#undef vsprintf
#define printf Printf
#define fprintf Fprintf
#undef snprintf /* for MacOSX */
#undef vsnprintf /* for MacOSX */
#define snprintf Snprintf
#define sprintf Sprintf
#define perror Perror
#define vfprintf Vfprintf
#define vsnprintf Vsnprintf
#define vsprintf Vsprintf
#endif /* NO_STDIO1 */
#endif /* STDIO1_H_included */

View file

@ -1,67 +0,0 @@
#include "third_party/gdtoa/gdtoa.internal.h"
/* clang-format off */
/****************************************************************
The author of this software is David M. Gay.
Copyright (C) 1998 by Lucent Technologies
All Rights Reserved
Permission to use, copy, modify, and distribute this software and
its documentation for any purpose and without fee is hereby
granted, provided that the above copyright notice appear in all
copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of Lucent or any of its entities
not be used in advertising or publicity pertaining to
distribution of the software without specific, written prior
permission.
LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
****************************************************************/
/* Please send bug reports to David M. Gay (dmg at acm dot org,
* with " at " changed at "@" and " dot " changed to "."). */
int
#ifdef KR_headers
strtoIQ(s, sp, a, b) CONST char *s; char **sp; void *a; void *b;
#else
strtoIQ(CONST char *s, char **sp, void *a, void *b)
#endif
{
static const FPI fpi = { 113, 1-16383-113+1, 32766-16383-113+1, 1, SI, 0 /*unused*/ };
Long exp[2];
Bigint *B[2];
int k, rv[2];
ULong *L = (ULong *)a, *M = (ULong *)b;
#ifdef MULTIPLE_THREADS
ThInfo *TI = 0;
#endif
B[0] = Balloc(2 MTb);
B[0]->wds = 4;
k = strtoIg(s, sp, &fpi, exp, B, rv);
ULtoQ(L, B[0]->x, exp[0], rv[0]);
Bfree(B[0] MTb);
if (B[1]) {
ULtoQ(M, B[1]->x, exp[1], rv[1]);
Bfree(B[1] MTb);
}
else {
M[0] = L[0];
M[1] = L[1];
M[2] = L[2];
M[3] = L[3];
}
return k;
}

View file

@ -32,12 +32,8 @@ THIS SOFTWARE.
/* Please send bug reports to David M. Gay (dmg at acm dot org,
* with " at " changed at "@" and " dot " changed to "."). */
int
#ifdef KR_headers
strtoId(s, sp, f0, f1) CONST char *s; char **sp; double *f0, *f1;
#else
int
strtoId(CONST char *s, char **sp, double *f0, double *f1)
#endif
{
static const FPI fpi = { 53, 1-1023-53+1, 2046-1023-53+1, 1, SI, 0 /*unused*/ };
Long exp[2];

View file

@ -32,12 +32,8 @@ THIS SOFTWARE.
/* Please send bug reports to David M. Gay (dmg at acm dot org,
* with " at " changed at "@" and " dot " changed to "."). */
int
#ifdef KR_headers
strtoIdd(s, sp, f0, f1) CONST char *s; char **sp; double *f0, *f1;
#else
int
strtoIdd(CONST char *s, char **sp, double *f0, double *f1)
#endif
{
#ifdef Sudden_Underflow
static const FPI fpi = { 106, 1-1023, 2046-1023-106+1, 1, 1, 0 /*unused*/ };

View file

@ -32,12 +32,8 @@ THIS SOFTWARE.
/* Please send bug reports to David M. Gay (dmg at acm dot org,
* with " at " changed at "@" and " dot " changed to "."). */
int
#ifdef KR_headers
strtoIf(s, sp, f0, f1) CONST char *s; char **sp; float *f0, *f1;
#else
int
strtoIf(CONST char *s, char **sp, float *f0, float *f1)
#endif
{
static const FPI fpi = { 24, 1-127-24+1, 254-127-24+1, 1, SI, 0 /*unused*/ };
Long exp[2];

View file

@ -32,12 +32,8 @@ THIS SOFTWARE.
/* Please send bug reports to David M. Gay (dmg at acm dot org,
* with " at " changed at "@" and " dot " changed to "."). */
int
#ifdef KR_headers
strtoIg(s00, se, fpi, exp, B, rvp) CONST char *s00; char **se; CONST FPI *fpi; Long *exp; Bigint **B; int *rvp;
#else
int
strtoIg(CONST char *s00, char **se, CONST FPI *fpi, Long *exp, Bigint **B, int *rvp)
#endif
{
Bigint *b, *b1;
int i, nb, nw, nw1, rv, rv1, swap;

View file

@ -32,12 +32,8 @@ THIS SOFTWARE.
/* Please send bug reports to David M. Gay (dmg at acm dot org,
* with " at " changed at "@" and " dot " changed to "."). */
int
#ifdef KR_headers
strtoIx(s, sp, a, b) CONST char *s; char **sp; void *a; void *b;
#else
int
strtoIx(CONST char *s, char **sp, void *a, void *b)
#endif
{
static const FPI fpi = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, SI, 0 /*unused*/ };
Long exp[2];

View file

@ -1,66 +0,0 @@
#include "third_party/gdtoa/gdtoa.internal.h"
/* clang-format off */
/****************************************************************
The author of this software is David M. Gay.
Copyright (C) 1998 by Lucent Technologies
All Rights Reserved
Permission to use, copy, modify, and distribute this software and
its documentation for any purpose and without fee is hereby
granted, provided that the above copyright notice appear in all
copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of Lucent or any of its entities
not be used in advertising or publicity pertaining to
distribution of the software without specific, written prior
permission.
LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
****************************************************************/
/* Please send bug reports to David M. Gay (dmg at acm dot org,
* with " at " changed at "@" and " dot " changed to "."). */
int
#ifdef KR_headers
strtoIxL(s, sp, a, b) CONST char *s; char **sp; void *a; void *b;
#else
strtoIxL(CONST char *s, char **sp, void *a, void *b)
#endif
{
static const FPI fpi = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, SI, 0 /*unused*/ };
Long exp[2];
Bigint *B[2];
int k, rv[2];
ULong *L = (ULong *)a, *M = (ULong *)b;
#ifdef MULTIPLE_THREADS
ThInfo *TI = 0;
#endif
B[0] = Balloc(1 MTb);
B[0]->wds = 2;
k = strtoIg(s, sp, &fpi, exp, B, rv);
ULtoxL(L, B[0]->x, exp[0], rv[0]);
Bfree(B[0] MTb);
if (B[1]) {
ULtoxL(M, B[1]->x, exp[1], rv[1]);
Bfree(B[1] MTb);
}
else {
M[0] = L[0];
M[1] = L[1];
M[2] = L[2];
}
return k;
}

View file

@ -50,13 +50,8 @@ static CONST double tinytens[] = { 1e-16, 1e-32, 1e-64, 1e-128,
#endif
#ifdef Avoid_Underflow /*{*/
static double
sulp
#ifdef KR_headers
(x, scale) U *x; int scale;
#else
(U *x, int scale)
#endif
static double
sulp(U *x, int scale)
{
U u;
double rv;
@ -71,13 +66,8 @@ sulp
}
#endif /*}*/
double
strtod
#ifdef KR_headers
(s00, se) CONST char *s00; char **se;
#else
(CONST char *s00, char **se)
#endif
double
strtod(CONST char *s00, char **se)
{
#ifdef Avoid_Underflow
int scale;

View file

@ -32,12 +32,8 @@ THIS SOFTWARE.
/* Please send bug reports to David M. Gay (dmg at acm dot org,
* with " at " changed at "@" and " dot " changed to "."). */
static double
#ifdef KR_headers
ulpdown(d) U *d;
#else
static double
ulpdown(U *d)
#endif
{
double u;
ULong *L = d->L;
@ -49,12 +45,8 @@ ulpdown(U *d)
return u;
}
int
#ifdef KR_headers
strtodI(s, sp, dd) CONST char *s; char **sp; double *dd;
#else
int
strtodI(CONST char *s, char **sp, double *dd)
#endif
{
static const FPI fpi = { 53, 1-1023-53+1, 2046-1023-53+1, 1, SI, 0 /*unused*/ };
ULong bits[2], sign;

View file

@ -42,12 +42,8 @@ fivesbits[] = { 0, 3, 5, 7, 10, 12, 14, 17, 19, 21,
#endif
};
Bigint *
#ifdef KR_headers
increment(b MTa) Bigint *b; MTk
#else
Bigint *
increment(Bigint *b MTd)
#endif
{
ULong *x, *xe;
Bigint *b1;
@ -87,12 +83,8 @@ increment(Bigint *b MTd)
return b;
}
void
#ifdef KR_headers
decrement(b) Bigint *b;
#else
void
decrement(Bigint *b)
#endif
{
ULong *x, *xe;
#ifdef Pack_16
@ -119,12 +111,8 @@ decrement(Bigint *b)
#endif
}
static int
#ifdef KR_headers
all_on(b, n) Bigint *b; int n;
#else
static int
all_on(Bigint *b, int n)
#endif
{
ULong *x, *xe;
@ -138,12 +126,8 @@ all_on(Bigint *b, int n)
return 1;
}
Bigint *
#ifdef KR_headers
set_ones(b, n MTa) Bigint *b; int n; MTk
#else
Bigint *
set_ones(Bigint *b, int n MTd)
#endif
{
int k;
ULong *x, *xe;
@ -166,14 +150,8 @@ set_ones(Bigint *b, int n MTd)
return b;
}
static int
rvOK
#ifdef KR_headers
(d, fpi, exp, bits, exact, rd, irv MTa)
U *d; CONST FPI *fpi; Long *exp; ULong *bits; int exact, rd, *irv; MTk
#else
(U *d, CONST FPI *fpi, Long *exp, ULong *bits, int exact, int rd, int *irv MTd)
#endif
static int
rvOK(U *d, CONST FPI *fpi, Long *exp, ULong *bits, int exact, int rd, int *irv MTd)
{
Bigint *b;
ULong carry, inex, lostbits;
@ -287,12 +265,8 @@ rvOK
return rv;
}
static int
#ifdef KR_headers
mantbits(d) U *d;
#else
static int
mantbits(U *d)
#endif
{
ULong L;
#ifdef VAX
@ -310,14 +284,8 @@ mantbits(U *d)
return P - 32 - lo0bits(&L);
}
int
strtodg
#ifdef KR_headers
(s00, se, fpi, exp, bits)
CONST char *s00; char **se; CONST FPI *fpi; Long *exp; ULong *bits;
#else
(CONST char *s00, char **se, CONST FPI *fpi, Long *exp, ULong *bits)
#endif
int
strtodg(CONST char *s00, char **se, CONST FPI *fpi, Long *exp, ULong *bits)
{
int abe, abits, asub;
int bb0, bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, decpt, denorm;

View file

@ -38,12 +38,8 @@ THIS SOFTWARE.
/* Please send bug reports to David M. Gay (dmg at acm dot org,
* with " at " changed at "@" and " dot " changed to "."). */
double
#ifdef KR_headers
strtod(s, sp) CONST char *s; char **sp;
#else
double
strtod(CONST char *s, char **sp)
#endif
{
static const FPI fpi = { 53, 1-1023-53+1, 2046-1023-53+1, 1, SI, 0 /*unused*/ };
ULong bits[2];

View file

@ -32,12 +32,8 @@ THIS SOFTWARE.
/* Please send bug reports to David M. Gay (dmg at acm dot org,
* with " at " changed at "@" and " dot " changed to "."). */
float
#ifdef KR_headers
strtof(s, sp) CONST char *s; char **sp;
#else
float
strtof(CONST char *s, char **sp)
#endif
{
static FPI fpi0 = { 24, 1-127-24+1, 254-127-24+1, 1, SI, 0 /*unused*/ };
ULong bits[1];

View file

@ -1,110 +0,0 @@
#include "third_party/gdtoa/gdtoa.internal.h"
/* clang-format off */
/****************************************************************
The author of this software is David M. Gay.
Copyright (C) 1998, 2000 by Lucent Technologies
All Rights Reserved
Permission to use, copy, modify, and distribute this software and
its documentation for any purpose and without fee is hereby
granted, provided that the above copyright notice appear in all
copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of Lucent or any of its entities
not be used in advertising or publicity pertaining to
distribution of the software without specific, written prior
permission.
LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
****************************************************************/
/* Please send bug reports to David M. Gay (dmg at acm dot org,
* with " at " changed at "@" and " dot " changed to "."). */
#undef _0
#undef _1
/* one or the other of IEEE_MC68k or IEEE_8087 should be #defined */
#ifdef IEEE_MC68k
#define _0 0
#define _1 1
#define _2 2
#define _3 3
#endif
#ifdef IEEE_8087
#define _0 3
#define _1 2
#define _2 1
#define _3 0
#endif
extern ULong NanDflt_Q_D2A[4];
int
#ifdef KR_headers
strtopQ(s, sp, V) CONST char *s; char **sp; void *V;
#else
strtopQ(CONST char *s, char **sp, void *V)
#endif
{
static const FPI fpi0 = { 113, 1-16383-113+1, 32766 - 16383 - 113 + 1, 1, SI, 0 /*unused*/ };
ULong bits[4];
Long exp;
int k;
ULong *L = (ULong*)V;
#ifdef Honor_FLT_ROUNDS
#include "third_party/gdtoa/gdtoa_fltrnds.inc"
#else
#define fpi &fpi0
#endif
k = strtodg(s, sp, fpi, &exp, bits);
switch(k & STRTOG_Retmask) {
case STRTOG_NoNumber:
case STRTOG_Zero:
L[0] = L[1] = L[2] = L[3] = 0;
break;
case STRTOG_Normal:
case STRTOG_NaNbits:
L[_3] = bits[0];
L[_2] = bits[1];
L[_1] = bits[2];
L[_0] = (bits[3] & ~0x10000) | ((exp + 0x3fff + 112) << 16);
break;
case STRTOG_Denormal:
L[_3] = bits[0];
L[_2] = bits[1];
L[_1] = bits[2];
L[_0] = bits[3];
break;
case STRTOG_Infinite:
L[_0] = 0x7fff0000;
L[_1] = L[_2] = L[_3] = 0;
break;
case STRTOG_NaN:
L[_0] = NanDflt_Q_D2A[3];
L[_1] = NanDflt_Q_D2A[2];
L[_2] = NanDflt_Q_D2A[1];
L[_3] = NanDflt_Q_D2A[0];
}
if (k & STRTOG_Neg)
L[_0] |= 0x80000000L;
return k;
}

View file

@ -32,12 +32,8 @@ THIS SOFTWARE.
/* Please send bug reports to David M. Gay (dmg at acm dot org,
* with " at " changed at "@" and " dot " changed to "."). */
int
#ifdef KR_headers
strtopd(s, sp, d) char *s; char **sp; double *d;
#else
int
strtopd(CONST char *s, char **sp, double *d)
#endif
{
static const FPI fpi0 = { 53, 1-1023-53+1, 2046-1023-53+1, 1, SI, 0 /*unused*/ };
ULong bits[2];

View file

@ -32,12 +32,8 @@ THIS SOFTWARE.
/* Please send bug reports to David M. Gay (dmg at acm dot org,
* with " at " changed at "@" and " dot " changed to "."). */
int
#ifdef KR_headers
strtopdd(s, sp, dd) CONST char *s; char **sp; double *dd;
#else
int
strtopdd(CONST char *s, char **sp, double *dd)
#endif
{
#ifdef Sudden_Underflow
static const FPI fpi0 = { 106, 1-1023, 2046-1023-106+1, 1, 1, 0 /*unused*/ };

View file

@ -32,12 +32,8 @@ THIS SOFTWARE.
/* Please send bug reports to David M. Gay (dmg at acm dot org,
* with " at " changed at "@" and " dot " changed to "."). */
int
#ifdef KR_headers
strtopf(s, sp, f) CONST char *s; char **sp; float *f;
#else
int
strtopf(CONST char *s, char **sp, float *f)
#endif
{
static const FPI fpi0 = { 24, 1-127-24+1, 254-127-24+1, 1, SI, 0 /*unused*/ };
ULong bits[1], *L;

View file

@ -32,7 +32,7 @@ THIS SOFTWARE.
/* Please send bug reports to David M. Gay (dmg at acm dot org,
* with " at " changed at "@" and " dot " changed to "."). */
extern UShort NanDflt_ldus_D2A[5];
extern UShort __gdtoa_NanDflt_ldus[5];
#undef _0
#undef _1
@ -54,12 +54,8 @@ THIS SOFTWARE.
#define _4 0
#endif
int
#ifdef KR_headers
strtopx(s, sp, V) CONST char *s; char **sp; void *V;
#else
int
strtopx(CONST char *s, char **sp, void *V)
#endif
{
const static FPI fpi0 = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, SI, 0 /*unused*/ };
ULong bits[2];
@ -100,11 +96,11 @@ strtopx(CONST char *s, char **sp, void *V)
break;
case STRTOG_NaN:
L[_4] = NanDflt_ldus_D2A[0];
L[_3] = NanDflt_ldus_D2A[1];
L[_2] = NanDflt_ldus_D2A[2];
L[_1] = NanDflt_ldus_D2A[3];
L[_0] = NanDflt_ldus_D2A[4];
L[_4] = __gdtoa_NanDflt_ldus[0];
L[_3] = __gdtoa_NanDflt_ldus[1];
L[_2] = __gdtoa_NanDflt_ldus[2];
L[_1] = __gdtoa_NanDflt_ldus[3];
L[_0] = __gdtoa_NanDflt_ldus[4];
}
if (k & STRTOG_Neg)
L[_0] |= 0x8000;

View file

@ -1,100 +0,0 @@
#include "third_party/gdtoa/gdtoa.internal.h"
/* clang-format off */
/****************************************************************
The author of this software is David M. Gay.
Copyright (C) 1998, 2000 by Lucent Technologies
All Rights Reserved
Permission to use, copy, modify, and distribute this software and
its documentation for any purpose and without fee is hereby
granted, provided that the above copyright notice appear in all
copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of Lucent or any of its entities
not be used in advertising or publicity pertaining to
distribution of the software without specific, written prior
permission.
LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
****************************************************************/
/* Please send bug reports to David M. Gay (dmg at acm dot org,
* with " at " changed at "@" and " dot " changed to "."). */
extern ULong NanDflt_xL_D2A[3];
#undef _0
#undef _1
/* one or the other of IEEE_MC68k or IEEE_8087 should be #defined */
#ifdef IEEE_MC68k
#define _0 0
#define _1 1
#define _2 2
#endif
#ifdef IEEE_8087
#define _0 2
#define _1 1
#define _2 0
#endif
int
#ifdef KR_headers
strtopxL(s, sp, V) CONST char *s; char **sp; void *V;
#else
strtopxL(CONST char *s, char **sp, void *V)
#endif
{
static const FPI fpi0 = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, SI, 0 /*unused*/ };
ULong bits[2];
Long exp;
int k;
ULong *L = (ULong*)V;
#ifdef Honor_FLT_ROUNDS
#include "third_party/gdtoa/gdtoa_fltrnds.inc"
#else
#define fpi &fpi0
#endif
k = strtodg(s, sp, fpi, &exp, bits);
switch(k & STRTOG_Retmask) {
case STRTOG_NoNumber:
case STRTOG_Zero:
L[0] = L[1] = L[2] = 0;
break;
case STRTOG_Normal:
case STRTOG_Denormal:
case STRTOG_NaNbits:
L[_2] = bits[0];
L[_1] = bits[1];
L[_0] = (exp + 0x3fff + 63) << 16;
break;
case STRTOG_Infinite:
L[_0] = 0x7fff << 16;
L[_1] = 0x80000000;
L[_2] = 0;
break;
case STRTOG_NaN:
L[_0] = NanDflt_xL_D2A[2];
L[_1] = NanDflt_xL_D2A[1];
L[_2] = NanDflt_xL_D2A[0];
}
if (k & STRTOG_Neg)
L[_0] |= 0x80000000L;
return k;
}

View file

@ -1,120 +0,0 @@
#include "third_party/gdtoa/gdtoa.internal.h"
/* clang-format off */
/****************************************************************
The author of this software is David M. Gay.
Copyright (C) 1998, 2000 by Lucent Technologies
All Rights Reserved
Permission to use, copy, modify, and distribute this software and
its documentation for any purpose and without fee is hereby
granted, provided that the above copyright notice appear in all
copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of Lucent or any of its entities
not be used in advertising or publicity pertaining to
distribution of the software without specific, written prior
permission.
LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
****************************************************************/
/* Please send bug reports to David M. Gay (dmg at acm dot org,
* with " at " changed at "@" and " dot " changed to "."). */
#undef _0
#undef _1
/* one or the other of IEEE_MC68k or IEEE_8087 should be #defined */
#ifdef IEEE_MC68k
#define _0 0
#define _1 1
#define _2 2
#define _3 3
#endif
#ifdef IEEE_8087
#define _0 3
#define _1 2
#define _2 1
#define _3 0
#endif
extern ULong NanDflt_Q_D2A[4];
void
#ifdef KR_headers
ULtoQ(L, bits, exp, k) ULong *L; ULong *bits; Long exp; int k;
#else
ULtoQ(ULong *L, ULong *bits, Long exp, int k)
#endif
{
switch(k & STRTOG_Retmask) {
case STRTOG_NoNumber:
case STRTOG_Zero:
L[0] = L[1] = L[2] = L[3] = 0;
break;
case STRTOG_Normal:
case STRTOG_NaNbits:
L[_3] = bits[0];
L[_2] = bits[1];
L[_1] = bits[2];
L[_0] = (bits[3] & ~0x10000) | ((exp + 0x3fff + 112) << 16);
break;
case STRTOG_Denormal:
L[_3] = bits[0];
L[_2] = bits[1];
L[_1] = bits[2];
L[_0] = bits[3];
break;
case STRTOG_Infinite:
L[_0] = 0x7fff0000;
L[_1] = L[_2] = L[_3] = 0;
break;
case STRTOG_NaN:
L[_0] = NanDflt_Q_D2A[3];
L[_1] = NanDflt_Q_D2A[2];
L[_2] = NanDflt_Q_D2A[1];
L[_3] = NanDflt_Q_D2A[0];
}
if (k & STRTOG_Neg)
L[_0] |= 0x80000000L;
}
int
#ifdef KR_headers
strtorQ(s, sp, rounding, L) CONST char *s; char **sp; int rounding; void *L;
#else
strtorQ(CONST char *s, char **sp, int rounding, void *L)
#endif
{
static const FPI fpi0 = { 113, 1-16383-113+1, 32766-16383-113+1, 1, SI, 0 /*unused*/ };
FPI *fpi, fpi1;
ULong bits[4];
Long exp;
int k;
fpi = &fpi0;
if (rounding != FPI_Round_near) {
fpi1 = fpi0;
fpi1.rounding = rounding;
fpi = &fpi1;
}
k = strtodg(s, sp, fpi, &exp, bits);
ULtoQ((ULong*)L, bits, exp, k);
return k;
}

View file

@ -32,14 +32,10 @@ THIS SOFTWARE.
/* Please send bug reports to David M. Gay (dmg at acm dot org,
* with " at " changed at "@" and " dot " changed to "."). */
extern ULong NanDflt_d_D2A[2];
extern ULong __gdtoa_NanDflt_d[2];
void
#ifdef KR_headers
ULtod(L, bits, exp, k) ULong *L; ULong *bits; Long exp; int k;
#else
void
ULtod(ULong *L, ULong *bits, Long exp, int k)
#endif
{
switch(k & STRTOG_Retmask) {
case STRTOG_NoNumber:
@ -64,19 +60,15 @@ ULtod(ULong *L, ULong *bits, Long exp, int k)
break;
case STRTOG_NaN:
L[_0] = NanDflt_d_D2A[1];
L[_1] = NanDflt_d_D2A[0];
L[_0] = __gdtoa_NanDflt_d[1];
L[_1] = __gdtoa_NanDflt_d[0];
}
if (k & STRTOG_Neg)
L[_0] |= 0x80000000L;
}
int
#ifdef KR_headers
strtord(s, sp, rounding, d) CONST char *s; char **sp; int rounding; double *d;
#else
int
strtord(CONST char *s, char **sp, int rounding, double *d)
#endif
{
static const FPI fpi0 = { 53, 1-1023-53+1, 2046-1023-53+1, 1, SI, 0 /*unused*/ };
FPI *fpi, fpi1;

View file

@ -32,14 +32,10 @@ THIS SOFTWARE.
/* Please send bug reports to David M. Gay (dmg at acm dot org,
* with " at " changed at "@" and " dot " changed to "."). */
extern ULong NanDflt_d_D2A[2];
extern ULong __gdtoa_NanDflt_d[2];
void
#ifdef KR_headers
ULtodd(L, bits, exp, k) ULong *L; ULong *bits; Long exp; int k;
#else
void
ULtodd(ULong *L, ULong *bits, Long exp, int k)
#endif
{
int i, j;
@ -156,8 +152,8 @@ ULtodd(ULong *L, ULong *bits, Long exp, int k)
break;
case STRTOG_NaN:
L[_0] = L[_0+2] = NanDflt_d_D2A[1];
L[_1] = L[_1+2] = NanDflt_d_D2A[0];
L[_0] = L[_0+2] = __gdtoa_NanDflt_d[1];
L[_1] = L[_1+2] = __gdtoa_NanDflt_d[0];
break;
case STRTOG_NaNbits:
@ -174,12 +170,8 @@ ULtodd(ULong *L, ULong *bits, Long exp, int k)
}
}
int
#ifdef KR_headers
strtordd(s, sp, rounding, dd) CONST char *s; char **sp; int rounding; double *dd;
#else
int
strtordd(CONST char *s, char **sp, int rounding, double *dd)
#endif
{
#ifdef Sudden_Underflow
static const FPI fpi0 = { 106, 1-1023, 2046-1023-106+1, 1, 1, 0 /*unused*/ };

View file

@ -32,14 +32,10 @@ THIS SOFTWARE.
/* Please send bug reports to David M. Gay (dmg at acm dot org,
* with " at " changed at "@" and " dot " changed to "."). */
extern ULong NanDflt_f_D2A[1];
extern ULong __gdtoa_NanDflt_f[1];
void
#ifdef KR_headers
ULtof(L, bits, exp, k) ULong *L; ULong *bits; Long exp; int k;
#else
void
ULtof(ULong *L, ULong *bits, Long exp, int k)
#endif
{
switch(k & STRTOG_Retmask) {
case STRTOG_NoNumber:
@ -61,18 +57,14 @@ ULtof(ULong *L, ULong *bits, Long exp, int k)
break;
case STRTOG_NaN:
L[0] = NanDflt_f_D2A[0];
L[0] = __gdtoa_NanDflt_f[0];
}
if (k & STRTOG_Neg)
L[0] |= 0x80000000L;
}
int
#ifdef KR_headers
strtorf(s, sp, rounding, f) CONST char *s; char **sp; int rounding; float *f;
#else
int
strtorf(CONST char *s, char **sp, int rounding, float *f)
#endif
{
static const FPI fpi0 = { 24, 1-127-24+1, 254-127-24+1, 1, SI, 0 /*unused*/ };
FPI *fpi, fpi1;

View file

@ -52,14 +52,10 @@ THIS SOFTWARE.
#define _4 0
#endif
extern UShort NanDflt_ldus_D2A[5];
extern UShort __gdtoa_NanDflt_ldus[5];
void
#ifdef KR_headers
ULtox(L, bits, exp, k) UShort *L; ULong *bits; Long exp; int k;
#else
void
ULtox(UShort *L, ULong *bits, Long exp, int k)
#endif
{
switch(k & STRTOG_Retmask) {
case STRTOG_NoNumber:
@ -88,22 +84,18 @@ ULtox(UShort *L, ULong *bits, Long exp, int k)
break;
case STRTOG_NaN:
L[_4] = NanDflt_ldus_D2A[0];
L[_3] = NanDflt_ldus_D2A[1];
L[_2] = NanDflt_ldus_D2A[2];
L[_1] = NanDflt_ldus_D2A[3];
L[_0] = NanDflt_ldus_D2A[4];
L[_4] = __gdtoa_NanDflt_ldus[0];
L[_3] = __gdtoa_NanDflt_ldus[1];
L[_2] = __gdtoa_NanDflt_ldus[2];
L[_1] = __gdtoa_NanDflt_ldus[3];
L[_0] = __gdtoa_NanDflt_ldus[4];
}
if (k & STRTOG_Neg)
L[_0] |= 0x8000;
}
int
#ifdef KR_headers
strtorx(s, sp, rounding, L) CONST char *s; char **sp; int rounding; void *L;
#else
int
strtorx(CONST char *s, char **sp, int rounding, void *L)
#endif
{
static const FPI fpi0 = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, SI, 0 /*unused*/ };
FPI *fpi, fpi1;

View file

@ -1,111 +0,0 @@
#include "third_party/gdtoa/gdtoa.internal.h"
/* clang-format off */
/****************************************************************
The author of this software is David M. Gay.
Copyright (C) 1998, 2000 by Lucent Technologies
All Rights Reserved
Permission to use, copy, modify, and distribute this software and
its documentation for any purpose and without fee is hereby
granted, provided that the above copyright notice appear in all
copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of Lucent or any of its entities
not be used in advertising or publicity pertaining to
distribution of the software without specific, written prior
permission.
LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
****************************************************************/
/* Please send bug reports to David M. Gay (dmg at acm dot org,
* with " at " changed at "@" and " dot " changed to "."). */
#undef _0
#undef _1
/* one or the other of IEEE_MC68k or IEEE_8087 should be #defined */
#ifdef IEEE_MC68k
#define _0 0
#define _1 1
#define _2 2
#endif
#ifdef IEEE_8087
#define _0 2
#define _1 1
#define _2 0
#endif
extern ULong NanDflt_xL_D2A[3];
void
#ifdef KR_headers
ULtoxL(L, bits, exp, k) ULong *L; ULong *bits; Long exp; int k;
#else
ULtoxL(ULong *L, ULong *bits, Long exp, int k)
#endif
{
switch(k & STRTOG_Retmask) {
case STRTOG_NoNumber:
case STRTOG_Zero:
L[0] = L[1] = L[2] = 0;
break;
case STRTOG_Normal:
case STRTOG_Denormal:
case STRTOG_NaNbits:
L[_0] = (exp + 0x3fff + 63) << 16;
L[_1] = bits[1];
L[_2] = bits[0];
break;
case STRTOG_Infinite:
L[_0] = 0x7fff0000;
L[_1] = 0x80000000;
L[_2] = 0;
break;
case STRTOG_NaN:
L[_0] = NanDflt_xL_D2A[2];
L[_1] = NanDflt_xL_D2A[1];
L[_2] = NanDflt_xL_D2A[0];
}
if (k & STRTOG_Neg)
L[_0] |= 0x80000000L;
}
int
#ifdef KR_headers
strtorxL(s, sp, rounding, L) CONST char *s; char **sp; int rounding; void *L;
#else
strtorxL(CONST char *s, char **sp, int rounding, void *L)
#endif
{
static const FPI fpi0 = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, SI, 0 /*unused*/ };
FPI *fpi, fpi1;
ULong bits[2];
Long exp;
int k;
fpi = &fpi0;
if (rounding != FPI_Round_near) {
fpi1 = fpi0;
fpi1.rounding = rounding;
fpi = &fpi1;
}
k = strtodg(s, sp, fpi, &exp, bits);
ULtoxL((ULong*)L, bits, exp, k);
return k;
}

View file

@ -32,12 +32,8 @@ THIS SOFTWARE.
/* Please send bug reports to David M. Gay (dmg at acm dot org,
* with " at " changed at "@" and " dot " changed to "."). */
Bigint *
#ifdef KR_headers
sum(a, b MTa) Bigint *a; Bigint *b; MTk
#else
Bigint *
sum(Bigint *a, Bigint *b MTd)
#endif
{
Bigint *c;
ULong carry, *xc, *xa, *xb, *xe, y;

View file

@ -32,13 +32,8 @@ THIS SOFTWARE.
/* Please send bug reports to David M. Gay (dmg at acm dot org,
* with " at " changed at "@" and " dot " changed to "."). */
double
ulp
#ifdef KR_headers
(x) U *x;
#else
(U *x)
#endif
double
ulp(U *x)
{
Long L;
U a;