alpha: Don't symbol_version syscalls outside libc
[glibc.git] / sysdeps / i386 / fpu / s_nexttowardf.c
blob49651bed6ffc9c8b6577a003716e6026d67a5910
1 /* s_nexttowardf.c -- float version of s_nextafter.c.
2 * Special i387 version.
3 * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
4 */
6 /*
7 * ====================================================
8 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
10 * Developed at SunPro, a Sun Microsystems, Inc. business.
11 * Permission to use, copy, modify, and distribute this
12 * software is freely granted, provided that this notice
13 * is preserved.
14 * ====================================================
17 #if defined(LIBM_SCCS) && !defined(lint)
18 static char rcsid[] = "$NetBSD: $";
19 #endif
21 #include <math.h>
22 #include <math_private.h>
23 #include <float.h>
25 float __nexttowardf(float x, long double y)
27 int32_t hx,ix,iy;
28 u_int32_t hy,ly,esy;
30 GET_FLOAT_WORD(hx,x);
31 GET_LDOUBLE_WORDS(esy,hy,ly,y);
32 ix = hx&0x7fffffff; /* |x| */
33 iy = esy&0x7fff; /* |y| */
35 /* Intel's extended format has the normally implicit 1 explicit
36 present. Sigh! */
37 if((ix>0x7f800000) || /* x is nan */
38 (iy>=0x7fff&&(((hy&0x7fffffff)|ly)!=0))) /* y is nan */
39 return x+y;
40 if((long double) x==y) return y; /* x=y, return y */
41 if(ix==0) { /* x == 0 */
42 float u;
43 SET_FLOAT_WORD(x,((esy&0x8000)<<16)|1);/* return +-minsub*/
44 u = math_opt_barrier (x);
45 u = u * u;
46 math_force_eval (u); /* raise underflow flag */
47 return x;
49 if(hx>=0) { /* x > 0 */
50 if(x > y) { /* x -= ulp */
51 hx -= 1;
52 } else { /* x < y, x += ulp */
53 hx += 1;
55 } else { /* x < 0 */
56 if(x < y) { /* x -= ulp */
57 hx -= 1;
58 } else { /* x > y, x += ulp */
59 hx += 1;
62 hy = hx&0x7f800000;
63 if(hy>=0x7f800000) {
64 x = x+x; /* overflow */
65 if (FLT_EVAL_METHOD != 0)
66 /* Force conversion to float. */
67 asm ("" : "+m"(x));
68 return x;
70 if(hy<0x00800000) {
71 float u = x*x; /* underflow */
72 math_force_eval (u); /* raise underflow flag */
74 SET_FLOAT_WORD(x,hx);
75 return x;
77 weak_alias (__nexttowardf, nexttowardf)