| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
#if defined(LIBM_SCCS) && !defined(lint) |
| 16 |
static char rcsid[] = "$NetBSD: $"; |
| 17 |
#endif |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
#include <errno.h> |
| 27 |
#include <math.h> |
| 28 |
#include <math-barriers.h> |
| 29 |
#include <math_private.h> |
| 30 |
|
| 31 |
long double __nextafterl(long double x, long double y) |
| 32 |
{ |
| 33 |
int32_t ix,iy,esx,esy; |
| 34 |
uint32_t hx,hy,lx,ly; |
| 35 |
|
| 36 |
GET_LDOUBLE_WORDS(esx,hx,lx,x); |
| 37 |
GET_LDOUBLE_WORDS(esy,hy,ly,y); |
| 38 |
ix = esx&0x7fff; |
| 39 |
iy = esy&0x7fff; |
| 40 |
|
| 41 |
if(((ix==0x7fff)&&((hx&0x7fffffff)|lx)!=0) || |
| 42 |
((iy==0x7fff)&&((hy&0x7fffffff)|ly)!=0)) |
| 43 |
return x+y; |
| 44 |
if(x==y) return y; |
| 45 |
if((ix|hx|lx)==0) { |
| 46 |
SET_LDOUBLE_WORDS(x,esy&0x8000,0,1); |
| 47 |
y = x*x; |
| 48 |
math_force_eval (y); |
| 49 |
return x; |
| 50 |
} |
| 51 |
if(esx>=0) { |
| 52 |
if(esx>esy||((esx==esy) && (hx>hy||((hx==hy)&&(lx>ly))))) { |
| 53 |
|
| 54 |
if(lx==0) { |
| 55 |
if (ix != 0 && hx == 0x80000000) hx = 0; |
| 56 |
if (hx==0) esx -= 1; |
| 57 |
hx -= 1; |
| 58 |
} |
| 59 |
lx -= 1; |
| 60 |
} else { |
| 61 |
lx += 1; |
| 62 |
if(lx==0) { |
| 63 |
hx += 1; |
| 64 |
if (hx==0) { |
| 65 |
hx = 0x80000000; |
| 66 |
esx += 1; |
| 67 |
} |
| 68 |
} |
| 69 |
} |
| 70 |
} else { |
| 71 |
if(esy>=0||esx>esy||((esx==esy) && (hx>hy||((hx==hy)&&(lx>ly))))){ |
| 72 |
|
| 73 |
if(lx==0) { |
| 74 |
if (ix != 0 && hx == 0x80000000) hx = 0; |
| 75 |
if (hx==0) esx -= 1; |
| 76 |
hx -= 1; |
| 77 |
} |
| 78 |
lx -= 1; |
| 79 |
} else { |
| 80 |
lx += 1; |
| 81 |
if(lx==0) { |
| 82 |
hx += 1; |
| 83 |
if (hx==0) { |
| 84 |
hx = 0x80000000; |
| 85 |
esx += 1; |
| 86 |
} |
| 87 |
} |
| 88 |
} |
| 89 |
} |
| 90 |
esy = esx&0x7fff; |
| 91 |
if(esy==0x7fff) { |
| 92 |
long double u = x + x; |
| 93 |
math_force_eval (u); |
| 94 |
__set_errno (ERANGE); |
| 95 |
} |
| 96 |
if(esy==0 && (hx & 0x80000000) == 0) { |
| 97 |
y = x*x; |
| 98 |
math_force_eval (y); |
| 99 |
__set_errno (ERANGE); |
| 100 |
} |
| 101 |
SET_LDOUBLE_WORDS(x,esx,hx,lx); |
| 102 |
return x; |
| 103 |
} |
| 104 |
weak_alias (__nextafterl, nextafterl) |
| 105 |
strong_alias (__nextafterl, __nexttowardl) |
| 106 |
weak_alias (__nextafterl, nexttowardl) |