Get rid of ASM_TYPE_DIRECTIVE{,_PREFIX}.
[platform/upstream/glibc.git] / sysdeps / i386 / fpu / s_nextafterl.c
1 /* s_nextafterl.c -- long double version of s_nextafter.c.
2  * Special version for i387.
3  * Conversion to long double by Ulrich Drepper,
4  * Cygnus Support, drepper@cygnus.com.
5  */
6
7 /*
8  * ====================================================
9  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
10  *
11  * Developed at SunPro, a Sun Microsystems, Inc. business.
12  * Permission to use, copy, modify, and distribute this
13  * software is freely granted, provided that this notice
14  * is preserved.
15  * ====================================================
16  */
17
18 #if defined(LIBM_SCCS) && !defined(lint)
19 static char rcsid[] = "$NetBSD: $";
20 #endif
21
22 /* IEEE functions
23  *      nextafterl(x,y)
24  *      return the next machine floating-point number of x in the
25  *      direction toward y.
26  *   Special cases:
27  */
28
29 #include <math.h>
30 #include <math_private.h>
31
32 long double __nextafterl(long double x, long double y)
33 {
34         u_int32_t hx,hy,ix,iy;
35         u_int32_t lx,ly;
36         int32_t esx,esy;
37
38         GET_LDOUBLE_WORDS(esx,hx,lx,x);
39         GET_LDOUBLE_WORDS(esy,hy,ly,y);
40         ix = esx&0x7fff;                /* |x| */
41         iy = esy&0x7fff;                /* |y| */
42
43         /* Intel's extended format has the normally implicit 1 explicit
44            present.  Sigh!  */
45         if(((ix==0x7fff)&&(((hx&0x7fffffff)|lx)!=0)) ||   /* x is nan */
46            ((iy==0x7fff)&&(((hy&0x7fffffff)|ly)!=0)))     /* y is nan */
47            return x+y;
48         if(x==y) return y;              /* x=y, return y */
49         if((ix|hx|lx)==0) {                     /* x == 0 */
50             long double u;
51             SET_LDOUBLE_WORDS(x,esy&0x8000,0,1);/* return +-minsubnormal */
52             u = math_opt_barrier (x);
53             u = u * u;
54             math_force_eval (u);                /* raise underflow flag */
55             return x;
56         }
57         if(esx>=0) {                    /* x > 0 */
58             if(esx>esy||((esx==esy) && (hx>hy||((hx==hy)&&(lx>ly))))) {
59               /* x > y, x -= ulp */
60                 if(lx==0) {
61                     if (hx <= 0x80000000) {
62                       if (esx == 0) {
63                         --hx;
64                       } else {
65                         esx -= 1;
66                         hx = hx - 1;
67                         if (esx > 0)
68                           hx |= 0x80000000;
69                       }
70                     } else
71                       hx -= 1;
72                 }
73                 lx -= 1;
74             } else {                            /* x < y, x += ulp */
75                 lx += 1;
76                 if(lx==0) {
77                     hx += 1;
78                     if (hx==0 || (esx == 0 && hx == 0x80000000)) {
79                         esx += 1;
80                         hx |= 0x80000000;
81                     }
82                 }
83             }
84         } else {                                /* x < 0 */
85             if(esy>=0||(esx>esy||((esx==esy)&&(hx>hy||((hx==hy)&&(lx>ly)))))){
86               /* x < y, x -= ulp */
87                 if(lx==0) {
88                     if (hx <= 0x80000000) {
89                         esx -= 1;
90                         hx = hx - 1;
91                         if ((esx&0x7fff) > 0)
92                           hx |= 0x80000000;
93                     } else
94                       hx -= 1;
95                 }
96                 lx -= 1;
97             } else {                            /* x > y, x += ulp */
98                 lx += 1;
99                 if(lx==0) {
100                     hx += 1;
101                     if (hx==0 || (esx == 0xffff8000 && hx == 0x80000000)) {
102                         esx += 1;
103                         hx |= 0x80000000;
104                     }
105                 }
106             }
107         }
108         esy = esx&0x7fff;
109         if(esy==0x7fff) return x+x;     /* overflow  */
110         if(esy==0) {
111             long double u = x*x;                /* underflow */
112             math_force_eval (u);                /* raise underflow flag */
113         }
114         SET_LDOUBLE_WORDS(x,esx,hx,lx);
115         return x;
116 }
117 weak_alias (__nextafterl, nextafterl)
118 strong_alias (__nextafterl, __nexttowardl)
119 weak_alias (__nextafterl, nexttowardl)