patches/glibc/2.9/270-ldbl-nexttowardf.patch
branchnewlib
changeset 1365 c4d124ed9f8e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/patches/glibc/2.9/270-ldbl-nexttowardf.patch	Sun Apr 19 16:17:11 2009 +0000
     1.3 @@ -0,0 +1,68 @@
     1.4 +Original patch from: gentoo/src/patchsets/glibc/2.9/1073_all_glibc-ldbl-nexttowardf.patch
     1.5 +
     1.6 +-= BEGIN original header =-
     1.7 +ripped from Debian
     1.8 +
     1.9 +this change was made to generic __nexttowardf, but not the long double version
    1.10 +
    1.11 +2008-05-05  Aurelien Jarno  <aurelien@aurel32.net>
    1.12 +
    1.13 +	* sysdeps/ieee754/ldbl-128/s_nexttowardf.c: Include float.h.
    1.14 +	(__nexttowardf): Use math_opt_barrier and
    1.15 +	math_force_eval macros.  If FLT_EVAL_METHOD is not 0, force
    1.16 +	x to float using asm.
    1.17 +
    1.18 +-= END original header =-
    1.19 +
    1.20 +diff -durN glibc-2_9.orig/sysdeps/ieee754/ldbl-128/s_nexttowardf.c glibc-2_9/sysdeps/ieee754/ldbl-128/s_nexttowardf.c
    1.21 +--- glibc-2_9.orig/sysdeps/ieee754/ldbl-128/s_nexttowardf.c	1999-07-14 02:09:42.000000000 +0200
    1.22 ++++ glibc-2_9/sysdeps/ieee754/ldbl-128/s_nexttowardf.c	2009-02-02 22:00:59.000000000 +0100
    1.23 +@@ -19,7 +19,8 @@
    1.24 + #endif
    1.25 + 
    1.26 + #include "math.h"
    1.27 +-#include "math_private.h"
    1.28 ++#include <math_private.h>
    1.29 ++#include <float.h>
    1.30 + 
    1.31 + #ifdef __STDC__
    1.32 + 	float __nexttowardf(float x, long double y)
    1.33 +@@ -44,10 +45,12 @@
    1.34 + 	   return x+y;
    1.35 + 	if((long double) x==y) return y;	/* x=y, return y */
    1.36 + 	if(ix==0) {				/* x == 0 */
    1.37 +-	    float x2;
    1.38 ++	    float u;
    1.39 + 	    SET_FLOAT_WORD(x,(u_int32_t)((hy>>32)&0x80000000)|1);/* return +-minsub*/
    1.40 +-	    x2 = x*x;
    1.41 +-	    if(x2==x) return x2; else return x;	/* raise underflow flag */
    1.42 ++	    u = math_opt_barrier (x);
    1.43 ++	    u = u * u;
    1.44 ++	    math_force_eval (u);		/* raise underflow flag */
    1.45 ++	    return x;
    1.46 + 	}
    1.47 + 	if(hx>=0) {				/* x > 0 */
    1.48 + 	    if(hy<0||(ix>>23)>(iy>>48)-0x3f80
    1.49 +@@ -67,13 +70,16 @@
    1.50 + 	    }
    1.51 + 	}
    1.52 + 	hy = hx&0x7f800000;
    1.53 +-	if(hy>=0x7f800000) return x+x;	/* overflow  */
    1.54 ++	if(hy>=0x7f800000) {
    1.55 ++	  x = x+x;	/* overflow  */
    1.56 ++	  if (FLT_EVAL_METHOD != 0)
    1.57 ++	    /* Force conversion to float.  */
    1.58 ++	    asm ("" : "+m"(x));
    1.59 ++	  return x;
    1.60 ++	}
    1.61 + 	if(hy<0x00800000) {		/* underflow */
    1.62 +-	    float x2 = x*x;
    1.63 +-	    if(x2!=x) {		/* raise underflow flag */
    1.64 +-	        SET_FLOAT_WORD(x2,hx);
    1.65 +-		return x2;
    1.66 +-	    }
    1.67 ++	    float u = x*x;
    1.68 ++	    math_force_eval (u);	/* raise underflow flag */
    1.69 + 	}
    1.70 + 	SET_FLOAT_WORD(x,hx);
    1.71 + 	return x;