View | Details | Raw Unified | Return to bug 887 | Differences between
and this patch

Collapse All | Expand All

(-)glibc-20041219T2331/ChangeLog (+4 lines)
Lines 1-3 Link Here
1
2005-07-10  Uttam Pawar  <uttamp@us.ibm.com>
2
3
	* sysdeps/powerpc/fpu/s_nextafter.c: New file.
4
1
2004-12-19  Roland McGrath  <roland@redhat.com>
5
2004-12-19  Roland McGrath  <roland@redhat.com>
2
6
3
	* iconv/iconvconfig.c (nostdlib, output_file, output_file_len):
7
	* iconv/iconvconfig.c (nostdlib, output_file, output_file_len):
(-)glibc-20041219T2331/sysdeps/powerpc/fpu/s_nextafter.c (+131 lines)
Line 0 Link Here
1
/* @(#)s_nextafter.c 5.1 93/09/24 */
2
/*
3
 * ====================================================
4
 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * Developed at SunPro, a Sun Microsystems, Inc. business.
7
 * Permission to use, copy, modify, and distribute this
8
 * software is freely granted, provided that this notice
9
 * is preserved.
10
 * ====================================================
11
 */
12
/*
13
   Copyright (C) 2005 Free Software Foundation, Inc.
14
   This file is part of the GNU C Library.
15
16
   The GNU C Library is free software; you can redistribute it and/or
17
   modify it under the terms of the GNU Lesser General Public
18
   License as published by the Free Software Foundation; either
19
   version 2.1 of the License, or (at your option) any later version.
20
21
   The GNU C Library is distributed in the hope that it will be useful,
22
   but WITHOUT ANY WARRANTY; without even the implied warranty of
23
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
24
   Lesser General Public License for more details.
25
26
   You should have received a copy of the GNU Lesser General Public
27
   License along with the GNU C Library; if not, write to the Free
28
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
29
   02111-1307 USA.  */
30
31
#if defined(LIBM_SCCS) && !defined(lint)
32
static char rcsid[] = "$NetBSD: s_nextafter.c,v 1.8 1995/05/10 20:47:58 jtc Exp $";
33
#endif
34
35
/* IEEE functions
36
 *	nextafter(x,y)
37
 *	return the next machine floating-point number of x in the
38
 *	direction toward y.
39
 *   Special cases:
40
 */
41
42
/* Ugly hack so that the aliasing works.  */
43
#define __nexttoward __internal___nexttoward
44
#define nexttoward __internal_nexttoward
45
46
#include "math.h"
47
#include "math_private.h"
48
#include <float.h>
49
#include <fenv.h>
50
51
#ifdef __STDC__
52
	double __nextafter(double x, double y)
53
#else
54
	double __nextafter(x,y)
55
	double x,y;
56
#endif
57
{
58
	int32_t hx,hy,ix,iy;
59
	u_int32_t lx,ly;
60
61
	EXTRACT_WORDS(hx,lx,x);
62
	EXTRACT_WORDS(hy,ly,y);
63
	ix = hx&0x7fffffff;		/* |x| */
64
	iy = hy&0x7fffffff;		/* |y| */
65
66
	if(((ix>=0x7ff00000)&&((ix-0x7ff00000)|lx)!=0) ||   /* x is nan */
67
	   ((iy>=0x7ff00000)&&((iy-0x7ff00000)|ly)!=0)){    /* y is nan */
68
           return x+y;
69
        } else if(x==y) { 
70
           return y;		/* x=y, return y */
71
	} else if((ix|lx)==0) {			/* x == 0 */
72
	    INSERT_WORDS(x,hy&0x80000000,1);	/* return +-minsubnormal */
73
	    y = x*x;
74
	    if(y==x) 
75
                return y; 
76
            else 
77
                return x;	/* raise underflow flag */
78
	} else 
79
	if(hx>=0) {				/* x > 0 */
80
	    if(hx>hy||((hx==hy)&&(lx>ly))) {	/* x > y, x -= ulp */
81
		if(lx==0) hx -= 1;
82
		lx -= 1;
83
	    } else {				/* x < y, x += ulp */
84
		lx += 1;
85
		if(lx==0) hx += 1;
86
	    }
87
	} else {				/* x < 0 */
88
	    if(hy>=0||hx>hy||((hx==hy)&&(lx>ly))){/* x < y, x -= ulp */
89
		if(lx==0) hx -= 1;
90
		lx -= 1;
91
	    } else {				/* x > y, x += ulp */
92
		lx += 1;
93
		if(lx==0) hx += 1;
94
	    }
95
	}
96
        
97
        hy = hx&0x7ff00000;
98
        if(hy>=0x7ff00000) {
99
          int round_mode=fegetround();
100
          fesetround(FE_TONEAREST);
101
          asm ("" : : : "memory"); /* workaround to compiler (gcc) optimization 
102
                                   till #pragma is implemented */
103
	  x = x+x;	/* overflow  */
104
	  if (FLT_EVAL_METHOD != 0 && FLT_EVAL_METHOD != 1)
105
	    asm ("" : "=m"(x) : "m"(x));
106
	  asm ("" : : : "memory"); /* workaround to compiler (gcc) optimization 
107
                                   till #pragma is implemented */
108
	  fesetround(round_mode);
109
	  return x;	/* overflow  */
110
	}
111
	if(hy<0x00100000) {		/* underflow */
112
	    y = x*x;
113
	    if(y!=x) {		/* raise underflow flag */
114
	        INSERT_WORDS(y,hx,lx);
115
		return y;
116
	    }
117
	}
118
	INSERT_WORDS(x,hx,lx);
119
	return x;
120
}
121
weak_alias (__nextafter, nextafter)
122
#ifdef NO_LONG_DOUBLE
123
strong_alias (__nextafter, __nextafterl)
124
weak_alias (__nextafter, nextafterl)
125
strong_alias (__nextafter, __nexttowardl)
126
weak_alias (__nexttowardl, nexttowardl)
127
#undef __nexttoward
128
strong_alias (__nextafter, __nexttoward)
129
#undef nexttoward
130
weak_alias (__nextafter, nexttoward)
131
#endif

Return to bug 887