From owner-p4-projects@FreeBSD.ORG Fri Sep 5 18:43:11 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id CC2CA106567E; Fri, 5 Sep 2008 18:43:11 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8EAD91065678 for ; Fri, 5 Sep 2008 18:43:11 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 7A2868FC1F for ; Fri, 5 Sep 2008 18:43:11 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id m85IhB37079419 for ; Fri, 5 Sep 2008 18:43:11 GMT (envelope-from gonzo@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id m85IhBKo079375 for perforce@freebsd.org; Fri, 5 Sep 2008 18:43:11 GMT (envelope-from gonzo@FreeBSD.org) Date: Fri, 5 Sep 2008 18:43:11 GMT Message-Id: <200809051843.m85IhBKo079375@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko To: Perforce Change Reviews Cc: Subject: PERFORCE change 149271 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Sep 2008 18:43:12 -0000 http://perforce.freebsd.org/chv.cgi?CH=149271 Change 149271 by gonzo@gonzo_jeeves on 2008/09/05 18:42:52 IFC @149270 Affected files ... .. //depot/projects/mips2/src/UPDATING#19 integrate .. //depot/projects/mips2/src/contrib/gdtoa/README#3 integrate .. //depot/projects/mips2/src/contrib/gdtoa/dtoa.c#3 integrate .. //depot/projects/mips2/src/contrib/gdtoa/gdtoa.h#3 integrate .. //depot/projects/mips2/src/contrib/gdtoa/gdtoaimp.h#4 integrate .. //depot/projects/mips2/src/contrib/gdtoa/gethex.c#4 integrate .. //depot/projects/mips2/src/contrib/gdtoa/strtoIg.c#3 integrate .. //depot/projects/mips2/src/contrib/gdtoa/strtod.c#4 integrate .. //depot/projects/mips2/src/contrib/gdtoa/strtodg.c#3 integrate .. //depot/projects/mips2/src/contrib/gdtoa/strtof.c#4 integrate .. //depot/projects/mips2/src/contrib/gdtoa/test/README#2 integrate .. //depot/projects/mips2/src/contrib/gdtoa/test/f.out#2 integrate .. //depot/projects/mips2/src/contrib/gdtoa/test/getround.c#3 integrate .. //depot/projects/mips2/src/contrib/gdtoa/test/xsum0.out#3 integrate .. //depot/projects/mips2/src/contrib/gdtoa/xsum0.out#3 integrate .. //depot/projects/mips2/src/lib/libarchive/archive_entry_link_resolver.c#3 integrate .. //depot/projects/mips2/src/lib/libarchive/archive_write_disk.3#4 integrate .. //depot/projects/mips2/src/lib/libarchive/archive_write_disk.c#12 integrate .. //depot/projects/mips2/src/lib/libarchive/test/test_write_disk.c#8 integrate .. //depot/projects/mips2/src/lib/libarchive/test/test_write_disk_hardlink.c#5 integrate .. //depot/projects/mips2/src/lib/librpcsec_gss/svc_rpcsec_gss.c#2 integrate .. //depot/projects/mips2/src/lib/libstand/stand.h#3 integrate .. //depot/projects/mips2/src/lib/libstand/ufs.c#3 integrate .. //depot/projects/mips2/src/lib/libstand/zalloc_malloc.c#2 integrate .. //depot/projects/mips2/src/libexec/rtld-elf/rtld.c#9 integrate .. //depot/projects/mips2/src/share/man/man4/Makefile#21 integrate .. //depot/projects/mips2/src/share/man/man4/pts.4#2 integrate .. //depot/projects/mips2/src/share/man/man9/CTASSERT.9#2 integrate .. //depot/projects/mips2/src/sys/boot/common/dev_net.c#3 integrate .. //depot/projects/mips2/src/sys/boot/common/devopen.c#3 integrate .. //depot/projects/mips2/src/sys/boot/powerpc/uboot/Makefile#2 integrate .. //depot/projects/mips2/src/sys/boot/powerpc/uboot/metadata.c#3 delete .. //depot/projects/mips2/src/sys/boot/powerpc/uboot/start.S#2 integrate .. //depot/projects/mips2/src/sys/boot/sparc64/loader/main.c#5 integrate .. //depot/projects/mips2/src/sys/boot/uboot/common/Makefile.inc#2 integrate .. //depot/projects/mips2/src/sys/boot/uboot/common/main.c#3 integrate .. //depot/projects/mips2/src/sys/boot/uboot/common/metadata.c#1 branch .. //depot/projects/mips2/src/sys/boot/uboot/lib/Makefile#3 integrate .. //depot/projects/mips2/src/sys/boot/uboot/lib/console.c#3 integrate .. //depot/projects/mips2/src/sys/boot/uboot/lib/elf_freebsd.c#3 integrate .. //depot/projects/mips2/src/sys/boot/uboot/lib/glue.c#4 integrate .. //depot/projects/mips2/src/sys/boot/uboot/lib/glue.h#3 integrate .. //depot/projects/mips2/src/sys/boot/uboot/lib/net.c#4 integrate .. //depot/projects/mips2/src/sys/boot/uboot/lib/reboot.c#3 integrate .. //depot/projects/mips2/src/sys/boot/uboot/lib/time.c#3 integrate .. //depot/projects/mips2/src/sys/cddl/contrib/opensolaris/uts/common/fs/gfs.c#2 integrate .. //depot/projects/mips2/src/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c#3 integrate .. //depot/projects/mips2/src/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c#4 integrate .. //depot/projects/mips2/src/sys/conf/files.sun4v#6 integrate .. //depot/projects/mips2/src/sys/contrib/dev/ath/public/mipsisa32-be-elf.hal.o.uu#4 integrate .. //depot/projects/mips2/src/sys/dev/ata/ata-chipset.c#18 integrate .. //depot/projects/mips2/src/sys/dev/ata/ata-pci.h#13 integrate .. //depot/projects/mips2/src/sys/dev/cxgb/cxgb_main.c#17 integrate .. //depot/projects/mips2/src/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb.c#2 integrate .. //depot/projects/mips2/src/sys/dev/k8temp/k8temp.c#4 integrate .. //depot/projects/mips2/src/sys/dev/mii/e1000phy.c#6 integrate .. //depot/projects/mips2/src/sys/dev/mii/miidevs#12 integrate .. //depot/projects/mips2/src/sys/dev/pci/pci_pci.c#6 integrate .. //depot/projects/mips2/src/sys/dev/usb/if_zyd.c#8 integrate .. //depot/projects/mips2/src/sys/dev/usb/usbdevs#20 integrate .. //depot/projects/mips2/src/sys/fs/tmpfs/tmpfs.h#6 integrate .. //depot/projects/mips2/src/sys/fs/tmpfs/tmpfs_fifoops.c#2 integrate .. //depot/projects/mips2/src/sys/fs/tmpfs/tmpfs_fifoops.h#2 integrate .. //depot/projects/mips2/src/sys/fs/tmpfs/tmpfs_subr.c#9 integrate .. //depot/projects/mips2/src/sys/fs/tmpfs/tmpfs_vfsops.c#10 integrate .. //depot/projects/mips2/src/sys/fs/tmpfs/tmpfs_vnops.c#12 integrate .. //depot/projects/mips2/src/sys/fs/tmpfs/tmpfs_vnops.h#2 integrate .. //depot/projects/mips2/src/sys/geom/part/g_part.c#10 integrate .. //depot/projects/mips2/src/sys/geom/part/g_part.h#9 integrate .. //depot/projects/mips2/src/sys/geom/part/g_part_gpt.c#8 integrate .. //depot/projects/mips2/src/sys/i386/include/pmc_mdep.h#3 integrate .. //depot/projects/mips2/src/sys/i386/xen/locore.s#2 integrate .. //depot/projects/mips2/src/sys/kern/kern_proc.c#15 integrate .. //depot/projects/mips2/src/sys/kern/kern_resource.c#9 integrate .. //depot/projects/mips2/src/sys/kern/tty.c#10 integrate .. //depot/projects/mips2/src/sys/kern/tty_compat.c#3 integrate .. //depot/projects/mips2/src/sys/kern/tty_pts.c#6 integrate .. //depot/projects/mips2/src/sys/kern/uipc_mbuf.c#9 integrate .. //depot/projects/mips2/src/sys/kern/uipc_mqueue.c#8 integrate .. //depot/projects/mips2/src/sys/kern/vfs_mount.c#18 integrate .. //depot/projects/mips2/src/sys/mips/adm5120/std.adm5120#5 integrate .. //depot/projects/mips2/src/sys/mips/conf/ADM5120#7 integrate .. //depot/projects/mips2/src/sys/mips/conf/IDT#10 integrate .. //depot/projects/mips2/src/sys/mips/conf/MALTA#20 integrate .. //depot/projects/mips2/src/sys/mips/conf/SENTRY5#12 integrate .. //depot/projects/mips2/src/sys/mips/idt/std.idt#3 integrate .. //depot/projects/mips2/src/sys/mips/malta/files.malta#2 integrate .. //depot/projects/mips2/src/sys/mips/malta/std.malta#3 integrate .. //depot/projects/mips2/src/sys/mips/mips/in_cksum.c#3 integrate .. //depot/projects/mips2/src/sys/mips/mips/intr_machdep.c#6 integrate .. //depot/projects/mips2/src/sys/net80211/ieee80211.c#11 integrate .. //depot/projects/mips2/src/sys/netgraph/ng_pipe.c#1 branch .. //depot/projects/mips2/src/sys/netgraph/ng_pipe.h#1 branch .. //depot/projects/mips2/src/sys/netinet/if_ether.c#10 integrate .. //depot/projects/mips2/src/sys/netinet/ip_fw2.c#14 integrate .. //depot/projects/mips2/src/sys/netinet6/icmp6.c#10 integrate .. //depot/projects/mips2/src/sys/netinet6/mld6.c#7 integrate .. //depot/projects/mips2/src/sys/security/audit/audit_syscalls.c#11 integrate .. //depot/projects/mips2/src/sys/sparc64/conf/GENERIC#14 integrate .. //depot/projects/mips2/src/sys/sparc64/include/clock.h#4 integrate .. //depot/projects/mips2/src/sys/sparc64/include/cpu.h#2 integrate .. //depot/projects/mips2/src/sys/sparc64/include/cpufunc.h#3 integrate .. //depot/projects/mips2/src/sys/sparc64/include/dcr.h#1 branch .. //depot/projects/mips2/src/sys/sparc64/include/pcpu.h#6 integrate .. //depot/projects/mips2/src/sys/sparc64/include/smp.h#4 integrate .. //depot/projects/mips2/src/sys/sparc64/include/tick.h#2 integrate .. //depot/projects/mips2/src/sys/sparc64/include/trap.h#2 integrate .. //depot/projects/mips2/src/sys/sparc64/include/tte.h#3 integrate .. //depot/projects/mips2/src/sys/sparc64/include/ver.h#3 integrate .. //depot/projects/mips2/src/sys/sparc64/sparc64/cheetah.c#5 integrate .. //depot/projects/mips2/src/sys/sparc64/sparc64/clock.c#4 integrate .. //depot/projects/mips2/src/sys/sparc64/sparc64/exception.S#5 integrate .. //depot/projects/mips2/src/sys/sparc64/sparc64/genassym.c#5 integrate .. //depot/projects/mips2/src/sys/sparc64/sparc64/locore.S#3 integrate .. //depot/projects/mips2/src/sys/sparc64/sparc64/machdep.c#9 integrate .. //depot/projects/mips2/src/sys/sparc64/sparc64/mp_locore.S#4 integrate .. //depot/projects/mips2/src/sys/sparc64/sparc64/mp_machdep.c#9 integrate .. //depot/projects/mips2/src/sys/sparc64/sparc64/pmap.c#11 integrate .. //depot/projects/mips2/src/sys/sparc64/sparc64/tick.c#4 integrate .. //depot/projects/mips2/src/sys/sparc64/sparc64/trap.c#8 integrate .. //depot/projects/mips2/src/sys/sun4v/sun4v/clock.c#1 branch .. //depot/projects/mips2/src/sys/sys/gpt.h#3 integrate .. //depot/projects/mips2/src/sys/sys/tty.h#5 integrate .. //depot/projects/mips2/src/sys/sys/ttydevsw.h#2 integrate .. //depot/projects/mips2/src/sys/ufs/ffs/ffs_vnops.c#10 integrate .. //depot/projects/mips2/src/sys/ufs/ufs/ufs_extattr.c#6 integrate .. //depot/projects/mips2/src/tools/regression/lib/libc/stdio/test-scanfloat.c#6 integrate .. //depot/projects/mips2/src/tools/tools/nanobsd/nanobsd.sh#10 integrate .. //depot/projects/mips2/src/usr.bin/cpio/cpio.c#3 integrate .. //depot/projects/mips2/src/usr.sbin/crunch/crunchide/exec_elf32.c#2 integrate .. //depot/projects/mips2/src/usr.sbin/cxgbtool/reg_defs_t3c.c#1 branch .. //depot/projects/mips2/src/usr.sbin/pciconf/pciconf.c#4 integrate Differences ... ==== //depot/projects/mips2/src/UPDATING#19 (text+ko) ==== @@ -41,6 +41,9 @@ Adding these drivers to your kernel configuration file shall cause compilation to fail. +20080818: + ntpd has been upgraded to 4.2.4p5. + 20080801: OpenSSH has been upgraded to 5.1p1. @@ -1123,4 +1126,4 @@ Contact Warner Losh if you have any questions about your use of this document. -$FreeBSD: src/UPDATING,v 1.540 2008/09/01 23:50:56 des Exp $ +$FreeBSD: src/UPDATING,v 1.541 2008/09/03 08:30:17 roberto Exp $ ==== //depot/projects/mips2/src/contrib/gdtoa/README#3 (text+ko) ==== @@ -332,5 +332,15 @@ the decimal-point character to be taken from the current locale; otherwise it is '.'. +Source files dtoa.c and strtod.c in this directory are derived from +netlib's "dtoa.c from fp" and are meant to function equivalently. +When compiled with Honor_FLT_ROUNDS #defined (on systems that provide +FLT_ROUNDS and fegetround() as specified in the C99 standard), they +honor the current rounding mode. Because FLT_ROUNDS is buggy on some +(Linux) systems -- not reflecting calls on fesetround(), as the C99 +standard says it should -- when Honor_FLT_ROUNDS is #defined, the +current rounding mode is obtained from fegetround() rather than from +FLT_ROUNDS, unless Trust_FLT_ROUNDS is also #defined. + Please send comments to David M. Gay (dmg at acm dot org, with " at " changed at "@" and " dot " changed to "."). ==== //depot/projects/mips2/src/contrib/gdtoa/dtoa.c#3 (text+ko) ==== @@ -66,7 +66,6 @@ */ #ifdef Honor_FLT_ROUNDS -#define Rounding rounding #undef Check_FLT_ROUNDS #define Check_FLT_ROUNDS #else @@ -127,12 +126,22 @@ Bigint *b, *b1, *delta, *mlo, *mhi, *S; double d2, ds, eps; char *s, *s0; -#ifdef Honor_FLT_ROUNDS - int rounding; -#endif #ifdef SET_INEXACT int inexact, oldinexact; #endif +#ifdef Honor_FLT_ROUNDS /*{*/ + int Rounding; +#ifdef Trust_FLT_ROUNDS /*{{ only define this if FLT_ROUNDS really works! */ + Rounding = Flt_Rounds; +#else /*}{*/ + Rounding = 1; + switch(fegetround()) { + case FE_TOWARDZERO: Rounding = 0; break; + case FE_UPWARD: Rounding = 2; break; + case FE_DOWNWARD: Rounding = 3; + } +#endif /*}}*/ +#endif /*}*/ #ifndef MULTIPLE_THREADS if (dtoa_result) { @@ -178,12 +187,12 @@ inexact = 1; #endif #ifdef Honor_FLT_ROUNDS - if ((rounding = Flt_Rounds) >= 2) { + if (Rounding >= 2) { if (*sign) - rounding = rounding == 2 ? 0 : 2; + Rounding = Rounding == 2 ? 0 : 2; else - if (rounding != 2) - rounding = 0; + if (Rounding != 2) + Rounding = 0; } #endif @@ -316,7 +325,7 @@ s = s0 = rv_alloc(i); #ifdef Honor_FLT_ROUNDS - if (mode > 1 && rounding != 1) + if (mode > 1 && Rounding != 1) leftright = 0; #endif @@ -453,7 +462,7 @@ if (i == ilim) { #ifdef Honor_FLT_ROUNDS if (mode > 1) - switch(rounding) { + switch(Rounding) { case 0: goto ret1; case 2: goto bump_up; } @@ -521,7 +530,7 @@ spec_case = 0; if ((mode < 2 || leftright) #ifdef Honor_FLT_ROUNDS - && rounding == 1 + && Rounding == 1 #endif ) { if (!word1(d) && !(word0(d) & Bndry_mask) @@ -614,7 +623,7 @@ #ifndef ROUND_BIASED if (j1 == 0 && mode != 1 && !(word1(d) & 1) #ifdef Honor_FLT_ROUNDS - && rounding >= 1 + && Rounding >= 1 #endif ) { if (dig == '9') @@ -642,7 +651,7 @@ } #ifdef Honor_FLT_ROUNDS if (mode > 1) - switch(rounding) { + switch(Rounding) { case 0: goto accept_dig; case 2: goto keep_dig; } @@ -660,7 +669,7 @@ } if (j1 > 0) { #ifdef Honor_FLT_ROUNDS - if (!rounding) + if (!Rounding) goto accept_dig; #endif if (dig == '9') { /* possible if i == 1 */ @@ -703,7 +712,7 @@ /* Round off last digit */ #ifdef Honor_FLT_ROUNDS - switch(rounding) { + switch(Rounding) { case 0: goto trimzeros; case 2: goto roundoff; } ==== //depot/projects/mips2/src/contrib/gdtoa/gdtoa.h#3 (text+ko) ==== @@ -74,9 +74,9 @@ /* The following may be or-ed into one of the above values. */ - STRTOG_Neg = 0x08, - STRTOG_Inexlo = 0x10, - STRTOG_Inexhi = 0x20, + STRTOG_Neg = 0x08, /* does not affect STRTOG_Inexlo or STRTOG_Inexhi */ + STRTOG_Inexlo = 0x10, /* returned result rounded toward zero */ + STRTOG_Inexhi = 0x20, /* returned result rounded away from zero */ STRTOG_Inexact = 0x30, STRTOG_Underflow= 0x40, STRTOG_Overflow = 0x80 ==== //depot/projects/mips2/src/contrib/gdtoa/gdtoaimp.h#4 (text+ko) ==== @@ -26,7 +26,7 @@ ****************************************************************/ -/* $FreeBSD: src/contrib/gdtoa/gdtoaimp.h,v 1.9 2007/12/17 00:19:49 das Exp $ */ +/* $FreeBSD: src/contrib/gdtoa/gdtoaimp.h,v 1.10 2008/09/03 07:23:57 das Exp $ */ /* This is a variation on dtoa.c that converts arbitary binary floating-point formats to and from decimal notation. It uses @@ -132,13 +132,16 @@ * Infinity and NaN (case insensitively). * When INFNAN_CHECK is #defined and No_Hex_NaN is not #defined, * strtodg also accepts (case insensitively) strings of the form - * NaN(x), where x is a string of hexadecimal digits and spaces; - * if there is only one string of hexadecimal digits, it is taken - * for the fraction bits of the resulting NaN; if there are two or - * more strings of hexadecimal digits, each string is assigned - * to the next available sequence of 32-bit words of fractions - * bits (starting with the most significant), right-aligned in - * each sequence. + * NaN(x), where x is a string of hexadecimal digits (optionally + * preceded by 0x or 0X) and spaces; if there is only one string + * of hexadecimal digits, it is taken for the fraction bits of the + * resulting NaN; if there are two or more strings of hexadecimal + * digits, each string is assigned to the next available sequence + * of 32-bit words of fractions bits (starting with the most + * significant), right-aligned in each sequence. + * Unless GDTOA_NON_PEDANTIC_NANCHECK is #defined, input "NaN(...)" + * is consumed even when ... has the wrong form (in which case the + * "(...)" is consumed but ignored). * #define MULTIPLE_THREADS if the system offers preemptively scheduled * multiple threads. In this case, you must provide (or suitably * #define) two locks, acquired by ACQUIRE_DTOA_LOCK(n) and freed @@ -150,7 +153,7 @@ * dtoa. You may do so whether or not MULTIPLE_THREADS is #defined. * #define IMPRECISE_INEXACT if you do not care about the setting of * the STRTOG_Inexact bits in the special case of doing IEEE double - * precision conversions (which could also be done by the strtog in + * precision conversions (which could also be done by the strtod in * dtoa.c). * #define NO_HEX_FP to disable recognition of C9x's hexadecimal * floating-point constants. @@ -204,6 +207,7 @@ #define INFNAN_CHECK #define USE_LOCALE #define Honor_FLT_ROUNDS +#define Trust_FLT_ROUNDS #undef IEEE_Arith #undef Avoid_Underflow @@ -597,7 +601,7 @@ extern int cmp ANSI((Bigint*, Bigint*)); extern void copybits ANSI((ULong*, int, Bigint*)); extern Bigint *d2b ANSI((double, int*, int*)); - extern int decrement ANSI((Bigint*)); + extern void decrement ANSI((Bigint*)); extern Bigint *diff ANSI((Bigint*, Bigint*)); extern char *dtoa ANSI((double d, int mode, int ndigits, int *decpt, int *sign, char **rve)); ==== //depot/projects/mips2/src/contrib/gdtoa/gethex.c#4 (text+ko) ==== @@ -45,7 +45,7 @@ { Bigint *b; CONST unsigned char *decpt, *s0, *s, *s1; - int esign, havedig, irv, k, n, nbits, up, zret; + int big, esign, havedig, irv, j, k, n, n0, nbits, up, zret; ULong L, lostbits, *x; Long e, e1; #ifdef USE_LOCALE @@ -56,6 +56,7 @@ if (!hexdig['0']) hexdig_init_D2A(); + *bp = 0; havedig = 0; s0 = *(CONST unsigned char **)sp + 2; while(s0[havedig] == '0') @@ -90,10 +91,10 @@ e = -(((Long)(s-decpt)) << 2); pcheck: s1 = s; + big = esign = 0; switch(*s) { case 'p': case 'P': - esign = 0; switch(*++s) { case '-': esign = 1; @@ -106,17 +107,65 @@ break; } e1 = n - 0x10; - while((n = hexdig[*++s]) !=0 && n <= 0x19) + while((n = hexdig[*++s]) !=0 && n <= 0x19) { + if (e1 & 0xf8000000) + big = 1; e1 = 10*e1 + n - 0x10; + } if (esign) e1 = -e1; e += e1; } *sp = (char*)s; - if (zret) { - if (!havedig) - *sp = s0 - 1; + if (!havedig) + *sp = s0 - 1; + if (zret) return STRTOG_Zero; + if (big) { + if (esign) { + switch(fpi->rounding) { + case FPI_Round_up: + if (sign) + break; + goto ret_tiny; + case FPI_Round_down: + if (!sign) + break; + goto ret_tiny; + } + goto retz; + ret_tiny: + b = Balloc(0); + b->wds = 1; + b->x[0] = 1; + goto dret; + } + switch(fpi->rounding) { + case FPI_Round_near: + goto ovfl1; + case FPI_Round_up: + if (!sign) + goto ovfl1; + goto ret_big; + case FPI_Round_down: + if (sign) + goto ovfl1; + goto ret_big; + } + ret_big: + nbits = fpi->nbits; + n0 = n = nbits >> kshift; + if (nbits & kmask) + ++n; + for(j = n, k = 0; j >>= 1; ++k); + *bp = b = Balloc(k); + b->wds = n; + for(j = 0; j < n0; ++j) + b->x[j] = ALL_ON; + if (n > n0) + b->x[j] = ULbits >> (ULbits - (nbits & kmask)); + *exp = fpi->emin; + return STRTOG_Normal | STRTOG_Inexlo; } n = s1 - s0 - 1; for(k = 0; n > 7; n >>= 1) @@ -149,7 +198,7 @@ k = n - 1; if (x[k>>kshift] & 1 << (k & kmask)) { lostbits = 2; - if (k > 1 && any_on(b,k-1)) + if (k > 0 && any_on(b,k)) lostbits = 3; } } @@ -165,7 +214,10 @@ if (e > fpi->emax) { ovfl: Bfree(b); - *bp = 0; + ovfl1: +#ifndef NO_ERRNO + errno = ERANGE; +#endif return STRTOG_Infinite | STRTOG_Overflow | STRTOG_Inexhi; } irv = STRTOG_Normal; @@ -185,15 +237,22 @@ case FPI_Round_down: if (sign) { one_bit: - *exp = fpi->emin; x[0] = b->wds = 1; + dret: *bp = b; + *exp = fpi->emin; +#ifndef NO_ERRNO + errno = ERANGE; +#endif return STRTOG_Denormal | STRTOG_Inexhi | STRTOG_Underflow; } } Bfree(b); - *bp = 0; + retz: +#ifndef NO_ERRNO + errno = ERANGE; +#endif return STRTOG_Zero | STRTOG_Inexlo | STRTOG_Underflow; } k = n - 1; ==== //depot/projects/mips2/src/contrib/gdtoa/strtoIg.c#3 (text+ko) ==== @@ -61,12 +61,16 @@ if (rv & STRTOG_Inexlo) { swap = 0; b1 = increment(b1); - if (fpi->sudden_underflow - && (rv & STRTOG_Retmask) == STRTOG_Zero) { - b1->x[0] = 0; - b1->x[nw1] = 1L << nb11; - rv1 += STRTOG_Normal - STRTOG_Zero; - rv1 &= ~STRTOG_Underflow; + if ((rv & STRTOG_Retmask) == STRTOG_Zero) { + if (fpi->sudden_underflow) { + b1->x[0] = 0; + b1->x[nw1] = 1L << nb11; + rv1 += STRTOG_Normal - STRTOG_Zero; + rv1 &= ~STRTOG_Underflow; + goto swapcheck; + } + rv1 &= STRTOG_Inexlo | STRTOG_Underflow | STRTOG_Zero; + rv1 |= STRTOG_Inexhi | STRTOG_Denormal; goto swapcheck; } if (b1->wds > nw ==== //depot/projects/mips2/src/contrib/gdtoa/strtod.c#4 (text+ko) ==== @@ -29,7 +29,7 @@ /* Please send bug reports to David M. Gay (dmg at acm dot org, * with " at " changed at "@" and " dot " changed to "."). */ -/* $FreeBSD: src/contrib/gdtoa/strtod.c,v 1.2 2007/12/16 21:14:33 das Exp $ */ +/* $FreeBSD: src/contrib/gdtoa/strtod.c,v 1.3 2008/09/03 07:23:57 das Exp $ */ #include "gdtoaimp.h" #ifndef NO_FENV_H @@ -44,16 +44,15 @@ #ifndef NO_IEEE_Scale #define Avoid_Underflow #undef tinytens -/* The factor of 2^53 in tinytens[4] helps us avoid setting the underflow */ +/* The factor of 2^106 in tinytens[4] helps us avoid setting the underflow */ /* flag unnecessarily. It leads to a song and dance at the end of strtod. */ static CONST double tinytens[] = { 1e-16, 1e-32, 1e-64, 1e-128, - 9007199254740992.e-256 + 9007199254740992.*9007199254740992.e-256 }; #endif #endif #ifdef Honor_FLT_ROUNDS -#define Rounding rounding #undef Check_FLT_ROUNDS #define Check_FLT_ROUNDS #else @@ -81,9 +80,19 @@ #ifdef SET_INEXACT int inexact, oldinexact; #endif -#ifdef Honor_FLT_ROUNDS - int rounding; -#endif +#ifdef Honor_FLT_ROUNDS /*{*/ + int Rounding; +#ifdef Trust_FLT_ROUNDS /*{{ only define this if FLT_ROUNDS really works! */ + Rounding = Flt_Rounds; +#else /*}{*/ + Rounding = 1; + switch(fegetround()) { + case FE_TOWARDZERO: Rounding = 0; break; + case FE_UPWARD: Rounding = 2; break; + case FE_DOWNWARD: Rounding = 3; + } +#endif /*}}*/ +#endif /*}*/ sign = nz0 = nz = decpt = 0; dval(rv) = 0.; @@ -109,7 +118,7 @@ } break2: if (*s == '0') { -#ifndef NO_HEX_FP +#ifndef NO_HEX_FP /*{{*/ { static FPI fpi = { 53, 1-1023-53+1, 2046-1023-53+1, 1, SI }; Long exp; @@ -118,16 +127,20 @@ case 'x': case 'X': { -#if defined(FE_DOWNWARD) && defined(FE_TONEAREST) && defined(FE_TOWARDZERO) && defined(FE_UPWARD) +#if defined(FE_DOWNWARD) && defined(FE_TONEAREST) && defined(FE_TOWARDZERO) && defined(FE_UPWARD) /*{{*/ FPI fpi1 = fpi; +#ifdef Honor_FLT_ROUNDS /*{{*/ + fpi1.rounding = Rounding; +#else /*}{*/ switch(fegetround()) { case FE_TOWARDZERO: fpi1.rounding = 0; break; case FE_UPWARD: fpi1.rounding = 2; break; case FE_DOWNWARD: fpi1.rounding = 3; } -#else +#endif /*}}*/ +#else /*}{*/ #define fpi1 fpi -#endif +#endif /*}}*/ switch((i = gethex(&s, &fpi1, &exp, &bb, sign)) & STRTOG_Retmask) { case STRTOG_NoNumber: s = s00; @@ -381,12 +394,12 @@ scale = 0; #endif #ifdef Honor_FLT_ROUNDS - if ((rounding = Flt_Rounds) >= 2) { + if (Rounding >= 2) { if (sign) - rounding = rounding == 2 ? 0 : 2; + Rounding = Rounding == 2 ? 0 : 2; else - if (rounding != 2) - rounding = 0; + if (Rounding != 2) + Rounding = 0; } #endif #endif /*IEEE_Arith*/ @@ -405,7 +418,7 @@ /* Can't trust HUGE_VAL */ #ifdef IEEE_Arith #ifdef Honor_FLT_ROUNDS - switch(rounding) { + switch(Rounding) { case 0: /* toward 0 */ case 3: /* toward -infinity */ word0(rv) = Big0; @@ -536,7 +549,7 @@ bd2 -= bbe; bs2 = bb2; #ifdef Honor_FLT_ROUNDS - if (rounding != 1) + if (Rounding != 1) bs2++; #endif #ifdef Avoid_Underflow @@ -594,7 +607,7 @@ delta->sign = 0; i = cmp(delta, bs); #ifdef Honor_FLT_ROUNDS - if (rounding != 1) { + if (Rounding != 1) { if (i < 0) { /* Error is less than an ulp */ if (!delta->x[0] && delta->wds <= 1) { @@ -604,7 +617,7 @@ #endif break; } - if (rounding) { + if (Rounding) { if (dsign) { adj = 1.; goto apply_adj; @@ -650,10 +663,10 @@ if (adj < 1.) adj = 1.; if (adj <= 0x7ffffffe) { - /* adj = rounding ? ceil(adj) : floor(adj); */ + /* adj = Rounding ? ceil(adj) : floor(adj); */ y = adj; if (y != adj) { - if (!((rounding>>1) ^ dsign)) + if (!((Rounding>>1) ^ dsign)) y++; adj = y; } @@ -676,8 +689,11 @@ #endif /*Sudden_Underflow*/ #endif /*Avoid_Underflow*/ adj *= ulp(dval(rv)); - if (dsign) + if (dsign) { + if (word0(rv) == Big0 && word1(rv) == Big1) + goto ovfl; dval(rv) += adj; + } else dval(rv) -= adj; goto cont; @@ -770,7 +786,7 @@ } #endif /*Avoid_Underflow*/ L = (word0(rv) & Exp_mask) - Exp_msk1; -#endif /*Sudden_Underflow}*/ +#endif /*Sudden_Underflow}}*/ word0(rv) = L | Bndry_mask1; word1(rv) = 0xffffffff; #ifdef IBM ==== //depot/projects/mips2/src/contrib/gdtoa/strtodg.c#3 (text+ko) ==== @@ -89,7 +89,7 @@ return b; } - int + void #ifdef KR_headers decrement(b) Bigint *b; #else @@ -119,7 +119,6 @@ *x++ = y & 0xffff; } while(borrow && x < xe); #endif - return STRTOG_Inexlo; } static int @@ -206,9 +205,9 @@ goto ret; } switch(rd) { - case 1: + case 1: /* round down (toward -Infinity) */ goto trunc; - case 2: + case 2: /* round up (toward +Infinity) */ break; default: /* round near */ k = bdif - 1; @@ -330,7 +329,7 @@ CONST char *s, *s0, *s1; double adj, adj0, rv, tol; Long L; - ULong y, z; + ULong *b, *be, y, z; Bigint *ab, *bb, *bb1, *bd, *bd0, *bs, *delta, *rvb, *rvb0; irv = STRTOG_Zero; @@ -822,10 +821,8 @@ break; if (dsign) { rvb = increment(rvb); - if ( (j = rvbits & kmask) !=0) - j = ULbits - j; - if (hi0bits(rvb->x[(rvb->wds - 1) >> kshift]) - != j) + j = kmask & (ULbits - (rvbits & kmask)); + if (hi0bits(rvb->x[rvb->wds - 1]) != j) rvbits++; irv = STRTOG_Normal | STRTOG_Inexhi; } @@ -978,6 +975,29 @@ Bfree(bd0); Bfree(delta); if (rve > fpi->emax) { + switch(fpi->rounding & 3) { + case FPI_Round_near: + goto huge; + case FPI_Round_up: + if (!sign) + goto huge; + break; + case FPI_Round_down: + if (sign) + goto huge; + } + /* Round to largest representable magnitude */ + Bfree(rvb); + rvb = 0; + irv = STRTOG_Normal | STRTOG_Inexlo; + *exp = fpi->emax; + b = bits; + be = b + (fpi->nbits >> 5) + 1; + while(b < be) + *b++ = -1; + if ((j = fpi->nbits & 0x1f)) + *--be >>= (32 - j); + goto ret; huge: rvb->wds = 0; irv = STRTOG_Infinite | STRTOG_Overflow | STRTOG_Inexhi; @@ -992,12 +1012,19 @@ if (sudden_underflow) { rvb->wds = 0; irv = STRTOG_Underflow | STRTOG_Inexlo; +#ifndef NO_ERRNO + errno = ERANGE; +#endif } else { irv = (irv & ~STRTOG_Retmask) | (rvb->wds > 0 ? STRTOG_Denormal : STRTOG_Zero); - if (irv & STRTOG_Inexact) + if (irv & STRTOG_Inexact) { irv |= STRTOG_Underflow; +#ifndef NO_ERRNO + errno = ERANGE; +#endif + } } } if (se) ==== //depot/projects/mips2/src/contrib/gdtoa/strtof.c#4 (text+ko) ==== @@ -29,7 +29,7 @@ /* Please send bug reports to David M. Gay (dmg at acm dot org, * with " at " changed at "@" and " dot " changed to "."). */ -/* $FreeBSD: src/contrib/gdtoa/strtof.c,v 1.2 2007/12/16 21:14:33 das Exp $ */ +/* $FreeBSD: src/contrib/gdtoa/strtof.c,v 1.3 2008/09/03 07:32:06 das Exp $ */ #include "gdtoaimp.h" @@ -40,13 +40,21 @@ strtof(CONST char *s, char **sp) #endif { - static FPI fpi = { 24, 1-127-24+1, 254-127-24+1, 1, SI }; + static FPI fpi0 = { 24, 1-127-24+1, 254-127-24+1, 1, SI }; + FPI *fpi, fpi1; ULong bits[1]; Long exp; int k; + int Rounding = Flt_Rounds; union { ULong L[1]; float f; } u; - k = strtodg(s, sp, &fpi, &exp, bits); + fpi = &fpi0; + if (Rounding != FPI_Round_near) { + fpi1 = fpi0; + fpi1.rounding = Rounding; + fpi = &fpi1; + } + k = strtodg(s, sp, fpi, &exp, bits); switch(k & STRTOG_Retmask) { case STRTOG_NoNumber: case STRTOG_Zero: ==== //depot/projects/mips2/src/contrib/gdtoa/test/README#2 (text+ko) ==== @@ -55,7 +55,12 @@ Program strtodt tests strtod on some hard cases (in file testnos3) posted by Fred Tydeman to comp.arch.arithmetic on 26 Feb. 1996. +To get correct results on Intel (x86) systems, the rounding precision +must be set to 53 bits. This can be done, e.g., by invoking +fpinit_ASL(), whose source appears in +http://www.netlib.org/ampl/solvers/fpinit.c . These are simple test programs, not meant for exhaustive testing, but for manually testing "interesting" cases. Paxson's testbase is good for more exhaustive testing, in part with random inputs. +See ftp://ftp.ee.lbl.gov/testbase-report.ps.Z . ==== //depot/projects/mips2/src/contrib/gdtoa/test/f.out#2 (text+ko) ==== @@ -124,7 +124,9 @@ g_ffmt(0) gives 1 bytes: "0" strtoIf returns 80, consuming 9 bytes. -fI[0] == fI[1] == strtof +fI[0] = #0 = 0 +fI[1] = #1 = 1.4012985e-45 +fI[0] == strtof Input: 1.23e-320 @@ -132,7 +134,9 @@ g_ffmt(0) gives 1 bytes: "0" strtoIf returns 80, consuming 9 bytes. -fI[0] == fI[1] == strtof +fI[0] = #0 = 0 +fI[1] = #1 = 1.4012985e-45 +fI[0] == strtof Input: 1.23e-20 @@ -160,7 +164,9 @@ g_ffmt(0) gives 1 bytes: "0" strtoIf returns 80, consuming 15 bytes. -fI[0] == fI[1] == strtof +fI[0] = #0 = 0 +fI[1] = #1 = 1.4012985e-45 +fI[0] == strtof Input: 1.234567890123456789 @@ -188,7 +194,9 @@ g_ffmt(0) gives 1 bytes: "0" strtoIf returns 80, consuming 25 bytes. -fI[0] == fI[1] == strtof +fI[0] = #0 = 0 +fI[1] = #1 = 1.4012985e-45 +fI[0] == strtof Input: 1.234567890123456789e-321 @@ -196,7 +204,9 @@ g_ffmt(0) gives 1 bytes: "0" strtoIf returns 80, consuming 25 bytes. -fI[0] == fI[1] == strtof +fI[0] = #0 = 0 +fI[1] = #1 = 1.4012985e-45 +fI[0] == strtof Input: 1e23 @@ -224,7 +234,9 @@ g_ffmt(0) gives 1 bytes: "0" strtoIf returns 80, consuming 23 bytes. -fI[0] == fI[1] == strtof +fI[0] = #0 = 0 +fI[1] = #1 = 1.4012985e-45 +fI[0] == strtof Input: 9.025971879324147880346310405869e-277 @@ -232,7 +244,9 @@ g_ffmt(0) gives 1 bytes: "0" strtoIf returns 80, consuming 37 bytes. -fI[0] == fI[1] == strtof +fI[0] = #0 = 0 +fI[1] = #1 = 1.4012985e-45 +fI[0] == strtof Input: 9.025971879324147880346310405868e-277 @@ -240,7 +254,9 @@ g_ffmt(0) gives 1 bytes: "0" strtoIf returns 80, consuming 37 bytes. -fI[0] == fI[1] == strtof +fI[0] = #0 = 0 +fI[1] = #1 = 1.4012985e-45 +fI[0] == strtof Input: 2.2250738585072014e-308 @@ -248,7 +264,9 @@ g_ffmt(0) gives 1 bytes: "0" strtoIf returns 80, consuming 23 bytes. -fI[0] == fI[1] == strtof +fI[0] = #0 = 0 +fI[1] = #1 = 1.4012985e-45 +fI[0] == strtof Input: 2.2250738585072013e-308 @@ -256,7 +274,9 @@ g_ffmt(0) gives 1 bytes: "0" strtoIf returns 80, consuming 23 bytes. -fI[0] == fI[1] == strtof +fI[0] = #0 = 0 +fI[1] = #1 = 1.4012985e-45 +fI[0] == strtof Rounding mode for strtor... changed from 1 (nearest) to 0 (toward zero) ==== //depot/projects/mips2/src/contrib/gdtoa/test/getround.c#3 (text+ko) ==== @@ -44,7 +44,14 @@ { int i; - i = atoi(s+1); >>> TRUNCATED FOR MAIL (1000 lines) <<<