125c28e83SPiotr Jasiukajtis /*
225c28e83SPiotr Jasiukajtis  * CDDL HEADER START
325c28e83SPiotr Jasiukajtis  *
425c28e83SPiotr Jasiukajtis  * The contents of this file are subject to the terms of the
525c28e83SPiotr Jasiukajtis  * Common Development and Distribution License (the "License").
625c28e83SPiotr Jasiukajtis  * You may not use this file except in compliance with the License.
725c28e83SPiotr Jasiukajtis  *
825c28e83SPiotr Jasiukajtis  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
925c28e83SPiotr Jasiukajtis  * or http://www.opensolaris.org/os/licensing.
1025c28e83SPiotr Jasiukajtis  * See the License for the specific language governing permissions
1125c28e83SPiotr Jasiukajtis  * and limitations under the License.
1225c28e83SPiotr Jasiukajtis  *
1325c28e83SPiotr Jasiukajtis  * When distributing Covered Code, include this CDDL HEADER in each
1425c28e83SPiotr Jasiukajtis  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1525c28e83SPiotr Jasiukajtis  * If applicable, add the following below this CDDL HEADER, with the
1625c28e83SPiotr Jasiukajtis  * fields enclosed by brackets "[]" replaced with your own identifying
1725c28e83SPiotr Jasiukajtis  * information: Portions Copyright [yyyy] [name of copyright owner]
1825c28e83SPiotr Jasiukajtis  *
1925c28e83SPiotr Jasiukajtis  * CDDL HEADER END
2025c28e83SPiotr Jasiukajtis  */
2125c28e83SPiotr Jasiukajtis 
2225c28e83SPiotr Jasiukajtis /*
2325c28e83SPiotr Jasiukajtis  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
2425c28e83SPiotr Jasiukajtis  * Use is subject to license terms.
2525c28e83SPiotr Jasiukajtis  */
2625c28e83SPiotr Jasiukajtis 
2725c28e83SPiotr Jasiukajtis /*
2825c28e83SPiotr Jasiukajtis  * Copyright 2011, Richard Lowe
2925c28e83SPiotr Jasiukajtis  */
3025c28e83SPiotr Jasiukajtis 
3125c28e83SPiotr Jasiukajtis /* Functions in this file are duplicated in locallibm.il.  Keep them in sync */
3225c28e83SPiotr Jasiukajtis 
3325c28e83SPiotr Jasiukajtis #ifndef _LIBM_INLINES_H
3425c28e83SPiotr Jasiukajtis #define	_LIBM_INLINES_H
3525c28e83SPiotr Jasiukajtis 
3625c28e83SPiotr Jasiukajtis #ifdef __GNUC__
3725c28e83SPiotr Jasiukajtis 
3825c28e83SPiotr Jasiukajtis #ifdef __cplusplus
3925c28e83SPiotr Jasiukajtis extern "C" {
4025c28e83SPiotr Jasiukajtis #endif
4125c28e83SPiotr Jasiukajtis 
4225c28e83SPiotr Jasiukajtis #include <sys/types.h>
4325c28e83SPiotr Jasiukajtis #include <sys/ieeefp.h>
4425c28e83SPiotr Jasiukajtis 
4525c28e83SPiotr Jasiukajtis #define	_LO_WORD(x)	((uint32_t *)&x)[0]
4625c28e83SPiotr Jasiukajtis #define	_HI_WORD(x)	((uint32_t *)&x)[1]
4725c28e83SPiotr Jasiukajtis #define	_HIER_WORD(x)	((uint32_t *)&x)[2]
4825c28e83SPiotr Jasiukajtis 
49*7f11fd00SRichard Lowe extern __GNU_INLINE double
__inline_sqrt(double a)5025c28e83SPiotr Jasiukajtis __inline_sqrt(double a)
5125c28e83SPiotr Jasiukajtis {
5225c28e83SPiotr Jasiukajtis 	double ret;
5325c28e83SPiotr Jasiukajtis 
5425c28e83SPiotr Jasiukajtis 	__asm__ __volatile__("fsqrt\n\t" : "=t" (ret) : "0" (a) : "cc");
5525c28e83SPiotr Jasiukajtis 	return (ret);
5625c28e83SPiotr Jasiukajtis }
5725c28e83SPiotr Jasiukajtis 
58*7f11fd00SRichard Lowe extern __GNU_INLINE double
__ieee754_sqrt(double a)5925c28e83SPiotr Jasiukajtis __ieee754_sqrt(double a)
6025c28e83SPiotr Jasiukajtis {
6125c28e83SPiotr Jasiukajtis 	return (__inline_sqrt(a));
6225c28e83SPiotr Jasiukajtis }
6325c28e83SPiotr Jasiukajtis 
64*7f11fd00SRichard Lowe extern __GNU_INLINE float
__inline_sqrtf(float a)6525c28e83SPiotr Jasiukajtis __inline_sqrtf(float a)
6625c28e83SPiotr Jasiukajtis {
6725c28e83SPiotr Jasiukajtis 	float ret;
6825c28e83SPiotr Jasiukajtis 
6925c28e83SPiotr Jasiukajtis 	__asm__ __volatile__("fsqrt\n\t" : "=t" (ret) : "0" (a) : "cc");
7025c28e83SPiotr Jasiukajtis 	return (ret);
7125c28e83SPiotr Jasiukajtis }
7225c28e83SPiotr Jasiukajtis 
73*7f11fd00SRichard Lowe extern __GNU_INLINE double
__inline_rint(double a)7425c28e83SPiotr Jasiukajtis __inline_rint(double a)
7525c28e83SPiotr Jasiukajtis {
7625c28e83SPiotr Jasiukajtis 	__asm__ __volatile__(
7725c28e83SPiotr Jasiukajtis 	    "andl $0x7fffffff,%1\n\t"
7825c28e83SPiotr Jasiukajtis 	    "cmpl $0x43300000,%1\n\t"
7925c28e83SPiotr Jasiukajtis 	    "jae  1f\n\t"
8025c28e83SPiotr Jasiukajtis 	    "frndint\n\t"
8125c28e83SPiotr Jasiukajtis 	    "1: fwait\n\t"
8225c28e83SPiotr Jasiukajtis 	    : "+t" (a), "+&r" (_HI_WORD(a))
8325c28e83SPiotr Jasiukajtis 	    :
8425c28e83SPiotr Jasiukajtis 	    : "cc");
8525c28e83SPiotr Jasiukajtis 
8625c28e83SPiotr Jasiukajtis 	return (a);
8725c28e83SPiotr Jasiukajtis }
8825c28e83SPiotr Jasiukajtis 
8925c28e83SPiotr Jasiukajtis /*
9025c28e83SPiotr Jasiukajtis  * 00 - 24 bits
9125c28e83SPiotr Jasiukajtis  * 01 - reserved
9225c28e83SPiotr Jasiukajtis  * 10 - 53 bits
9325c28e83SPiotr Jasiukajtis  * 11 - 64 bits
9425c28e83SPiotr Jasiukajtis  */
95*7f11fd00SRichard Lowe extern __GNU_INLINE int
__swapRP(int i)9625c28e83SPiotr Jasiukajtis __swapRP(int i)
9725c28e83SPiotr Jasiukajtis {
9825c28e83SPiotr Jasiukajtis 	int ret;
9925c28e83SPiotr Jasiukajtis 	uint16_t cw;
10025c28e83SPiotr Jasiukajtis 
10125c28e83SPiotr Jasiukajtis 	__asm__ __volatile__("fstcw %0\n\t" : "=m" (cw));
10225c28e83SPiotr Jasiukajtis 
10325c28e83SPiotr Jasiukajtis 	ret = (cw >> 8) & 0x3;
10425c28e83SPiotr Jasiukajtis 	cw = (cw & 0xfcff) | ((i & 0x3) << 8);
10525c28e83SPiotr Jasiukajtis 
10625c28e83SPiotr Jasiukajtis 	__asm__ __volatile__("fldcw %0\n\t" : : "m" (cw));
10725c28e83SPiotr Jasiukajtis 
10825c28e83SPiotr Jasiukajtis 	return (ret);
10925c28e83SPiotr Jasiukajtis }
11025c28e83SPiotr Jasiukajtis 
11125c28e83SPiotr Jasiukajtis /*
11225c28e83SPiotr Jasiukajtis  * 00 - Round to nearest, with even preferred
11325c28e83SPiotr Jasiukajtis  * 01 - Round down
11425c28e83SPiotr Jasiukajtis  * 10 - Round up
11525c28e83SPiotr Jasiukajtis  * 11 - Chop
11625c28e83SPiotr Jasiukajtis  */
117*7f11fd00SRichard Lowe extern __GNU_INLINE enum fp_direction_type
__swap87RD(enum fp_direction_type i)11825c28e83SPiotr Jasiukajtis __swap87RD(enum fp_direction_type i)
11925c28e83SPiotr Jasiukajtis {
12025c28e83SPiotr Jasiukajtis 	int ret;
12125c28e83SPiotr Jasiukajtis 	uint16_t cw;
12225c28e83SPiotr Jasiukajtis 
12325c28e83SPiotr Jasiukajtis 	__asm__ __volatile__("fstcw %0\n\t" : "=m" (cw));
12425c28e83SPiotr Jasiukajtis 
12525c28e83SPiotr Jasiukajtis 	ret = (cw >> 10) & 0x3;
12625c28e83SPiotr Jasiukajtis 	cw = (cw & 0xf3ff) | ((i & 0x3) << 10);
12725c28e83SPiotr Jasiukajtis 
12825c28e83SPiotr Jasiukajtis 	__asm__ __volatile__("fldcw %0\n\t" : : "m" (cw));
12925c28e83SPiotr Jasiukajtis 
13025c28e83SPiotr Jasiukajtis 	return (ret);
13125c28e83SPiotr Jasiukajtis }
13225c28e83SPiotr Jasiukajtis 
133*7f11fd00SRichard Lowe extern __GNU_INLINE double
ceil(double d)13425c28e83SPiotr Jasiukajtis ceil(double d)
13525c28e83SPiotr Jasiukajtis {
13625c28e83SPiotr Jasiukajtis 	/*
13725c28e83SPiotr Jasiukajtis 	 * Let's set a Rounding Control (RC) bits from x87 FPU Control Word
13825c28e83SPiotr Jasiukajtis 	 * to fp_positive and save old bits in rd.
13925c28e83SPiotr Jasiukajtis 	 */
14025c28e83SPiotr Jasiukajtis 	short rd = __swap87RD(fp_positive);
14125c28e83SPiotr Jasiukajtis 
14225c28e83SPiotr Jasiukajtis 	/*
14325c28e83SPiotr Jasiukajtis 	 * The FRNDINT instruction returns a floating-point value that is the
14425c28e83SPiotr Jasiukajtis 	 * integral value closest to the source value in the direction of the
14525c28e83SPiotr Jasiukajtis 	 * rounding mode specified in the RC field of the x87 FPU control word.
14625c28e83SPiotr Jasiukajtis 	 *
14725c28e83SPiotr Jasiukajtis 	 * Rounds the source value in the ST(0) register to the nearest
14825c28e83SPiotr Jasiukajtis 	 * integral value, depending on the current rounding mode
14925c28e83SPiotr Jasiukajtis 	 * (setting of the RC field of the FPU control word),
15025c28e83SPiotr Jasiukajtis 	 * and stores the result in ST(0).
15125c28e83SPiotr Jasiukajtis 	 */
15225c28e83SPiotr Jasiukajtis 	__asm__ __volatile__("frndint" : "+t" (d) : : "cc");
15325c28e83SPiotr Jasiukajtis 
15425c28e83SPiotr Jasiukajtis 	/* restore old RC bits */
15525c28e83SPiotr Jasiukajtis 	__swap87RD(rd);
15625c28e83SPiotr Jasiukajtis 
15725c28e83SPiotr Jasiukajtis 	return (d);
15825c28e83SPiotr Jasiukajtis }
15925c28e83SPiotr Jasiukajtis 
160*7f11fd00SRichard Lowe extern __GNU_INLINE double
copysign(double d1,double d2)16125c28e83SPiotr Jasiukajtis copysign(double d1, double d2)
16225c28e83SPiotr Jasiukajtis {
16325c28e83SPiotr Jasiukajtis 	__asm__ __volatile__(
16425c28e83SPiotr Jasiukajtis 	    "andl $0x7fffffff,%0\n\t"	/* %0 <-- hi_32(abs(d)) */
16525c28e83SPiotr Jasiukajtis 	    "andl $0x80000000,%1\n\t"	/* %1[31] <-- sign_bit(d2) */
16625c28e83SPiotr Jasiukajtis 	    "orl  %1,%0\n\t"		/* %0 <-- hi_32(copysign(x,y)) */
16725c28e83SPiotr Jasiukajtis 	    : "+&r" (_HI_WORD(d1)), "+r" (_HI_WORD(d2))
16825c28e83SPiotr Jasiukajtis 	    :
16925c28e83SPiotr Jasiukajtis 	    : "cc");
17025c28e83SPiotr Jasiukajtis 
17125c28e83SPiotr Jasiukajtis 	return (d1);
17225c28e83SPiotr Jasiukajtis }
17325c28e83SPiotr Jasiukajtis 
174*7f11fd00SRichard Lowe extern __GNU_INLINE double
fabs(double d)17525c28e83SPiotr Jasiukajtis fabs(double d)
17625c28e83SPiotr Jasiukajtis {
17725c28e83SPiotr Jasiukajtis 	__asm__ __volatile__("fabs\n\t" : "+t" (d) : : "cc");
17825c28e83SPiotr Jasiukajtis 	return (d);
17925c28e83SPiotr Jasiukajtis }
18025c28e83SPiotr Jasiukajtis 
181*7f11fd00SRichard Lowe extern __GNU_INLINE float
fabsf(float d)18225c28e83SPiotr Jasiukajtis fabsf(float d)
18325c28e83SPiotr Jasiukajtis {
18425c28e83SPiotr Jasiukajtis 	__asm__ __volatile__("fabs\n\t" : "+t" (d) : : "cc");
18525c28e83SPiotr Jasiukajtis 	return (d);
18625c28e83SPiotr Jasiukajtis }
18725c28e83SPiotr Jasiukajtis 
188*7f11fd00SRichard Lowe extern __GNU_INLINE long double
fabsl(long double d)18925c28e83SPiotr Jasiukajtis fabsl(long double d)
19025c28e83SPiotr Jasiukajtis {
19125c28e83SPiotr Jasiukajtis 	__asm__ __volatile__("fabs\n\t" : "+t" (d) : : "cc");
19225c28e83SPiotr Jasiukajtis 	return (d);
19325c28e83SPiotr Jasiukajtis }
19425c28e83SPiotr Jasiukajtis 
195*7f11fd00SRichard Lowe extern __GNU_INLINE int
finite(double d)19625c28e83SPiotr Jasiukajtis finite(double d)
19725c28e83SPiotr Jasiukajtis {
19825c28e83SPiotr Jasiukajtis 	int ret = _HI_WORD(d);
19925c28e83SPiotr Jasiukajtis 
20025c28e83SPiotr Jasiukajtis 	__asm__ __volatile__(
20125c28e83SPiotr Jasiukajtis 	    "notl %0\n\t"
20225c28e83SPiotr Jasiukajtis 	    "andl $0x7ff00000,%0\n\t"
20325c28e83SPiotr Jasiukajtis 	    "negl %0\n\t"
20425c28e83SPiotr Jasiukajtis 	    "shrl $31,%0\n\t"
20525c28e83SPiotr Jasiukajtis 	    : "+r" (ret)
20625c28e83SPiotr Jasiukajtis 	    :
20725c28e83SPiotr Jasiukajtis 	    : "cc");
20825c28e83SPiotr Jasiukajtis 	return (ret);
20925c28e83SPiotr Jasiukajtis }
21025c28e83SPiotr Jasiukajtis 
211*7f11fd00SRichard Lowe extern __GNU_INLINE double
floor(double d)21225c28e83SPiotr Jasiukajtis floor(double d)
21325c28e83SPiotr Jasiukajtis {
21425c28e83SPiotr Jasiukajtis 	short rd = __swap87RD(fp_negative);
21525c28e83SPiotr Jasiukajtis 
21625c28e83SPiotr Jasiukajtis 	__asm__ __volatile__("frndint" : "+t" (d), "+r" (rd) : : "cc");
21725c28e83SPiotr Jasiukajtis 	__swap87RD(rd);
21825c28e83SPiotr Jasiukajtis 
21925c28e83SPiotr Jasiukajtis 	return (d);
22025c28e83SPiotr Jasiukajtis }
22125c28e83SPiotr Jasiukajtis 
22225c28e83SPiotr Jasiukajtis /*
22325c28e83SPiotr Jasiukajtis  *      branchless __isnan
22425c28e83SPiotr Jasiukajtis  *      ((0x7ff00000-[((lx|-lx)>>31)&1]|ahx)>>31)&1 = 1 iff x is NaN
22525c28e83SPiotr Jasiukajtis  */
226*7f11fd00SRichard Lowe extern __GNU_INLINE int
isnan(double d)22725c28e83SPiotr Jasiukajtis isnan(double d)
22825c28e83SPiotr Jasiukajtis {
22925c28e83SPiotr Jasiukajtis 	int ret;
23025c28e83SPiotr Jasiukajtis 
23125c28e83SPiotr Jasiukajtis 	__asm__ __volatile__(
232*7f11fd00SRichard Lowe 	    "movl %1,%%ecx\n\t"
233*7f11fd00SRichard Lowe 	    "negl %%ecx\n\t"			/* ecx <-- -lo_32(x) */
234*7f11fd00SRichard Lowe 	    "orl  %%ecx,%1\n\t"
235*7f11fd00SRichard Lowe 	    "shrl $31,%1\n\t"			/* 1 iff lx != 0 */
236*7f11fd00SRichard Lowe 	    "andl $0x7fffffff,%2\n\t"	/* ecx <-- hi_32(abs(x)) */
237*7f11fd00SRichard Lowe 	    "orl  %2,%1\n\t"
238*7f11fd00SRichard Lowe 	    "subl $0x7ff00000,%1\n\t"
239*7f11fd00SRichard Lowe 	    "negl %1\n\t"
240*7f11fd00SRichard Lowe 	    "shrl $31,%1\n\t"
241*7f11fd00SRichard Lowe 	    : "=r" (ret)
242*7f11fd00SRichard Lowe 	    : "0" (_HI_WORD(d)), "r" (_LO_WORD(d))
243*7f11fd00SRichard Lowe 	    : "ecx");
24425c28e83SPiotr Jasiukajtis 
24525c28e83SPiotr Jasiukajtis 	return (ret);
24625c28e83SPiotr Jasiukajtis }
24725c28e83SPiotr Jasiukajtis 
248*7f11fd00SRichard Lowe extern __GNU_INLINE int
isnanf(float f)24925c28e83SPiotr Jasiukajtis isnanf(float f)
25025c28e83SPiotr Jasiukajtis {
25125c28e83SPiotr Jasiukajtis 	__asm__ __volatile__(
25225c28e83SPiotr Jasiukajtis 	    "andl $0x7fffffff,%0\n\t"
25325c28e83SPiotr Jasiukajtis 	    "negl %0\n\t"
25425c28e83SPiotr Jasiukajtis 	    "addl $0x7f800000,%0\n\t"
25525c28e83SPiotr Jasiukajtis 	    "shrl $31,%0\n\t"
25625c28e83SPiotr Jasiukajtis 	    : "+r" (f)
25725c28e83SPiotr Jasiukajtis 	    :
25825c28e83SPiotr Jasiukajtis 	    : "cc");
25925c28e83SPiotr Jasiukajtis 
26025c28e83SPiotr Jasiukajtis 	return (f);
26125c28e83SPiotr Jasiukajtis }
26225c28e83SPiotr Jasiukajtis 
263*7f11fd00SRichard Lowe extern __GNU_INLINE double
rint(double a)26425c28e83SPiotr Jasiukajtis rint(double a) {
26525c28e83SPiotr Jasiukajtis     return (__inline_rint(a));
26625c28e83SPiotr Jasiukajtis }
26725c28e83SPiotr Jasiukajtis 
268*7f11fd00SRichard Lowe extern __GNU_INLINE double
scalbn(double d,int n)26925c28e83SPiotr Jasiukajtis scalbn(double d, int n)
27025c28e83SPiotr Jasiukajtis {
27125c28e83SPiotr Jasiukajtis 	double dummy;
27225c28e83SPiotr Jasiukajtis 
27325c28e83SPiotr Jasiukajtis 	__asm__ __volatile__(
27425c28e83SPiotr Jasiukajtis 	    "fildl %2\n\t"	/* Convert N to extended */
27525c28e83SPiotr Jasiukajtis 	    "fxch\n\t"
27625c28e83SPiotr Jasiukajtis 	    "fscale\n\t"
27725c28e83SPiotr Jasiukajtis 	    : "+t" (d), "=u" (dummy)
27825c28e83SPiotr Jasiukajtis 	    : "m" (n)
27925c28e83SPiotr Jasiukajtis 	    : "cc");
28025c28e83SPiotr Jasiukajtis 
28125c28e83SPiotr Jasiukajtis 	return (d);
28225c28e83SPiotr Jasiukajtis }
28325c28e83SPiotr Jasiukajtis 
284*7f11fd00SRichard Lowe extern __GNU_INLINE int
signbit(double d)28525c28e83SPiotr Jasiukajtis signbit(double d)
28625c28e83SPiotr Jasiukajtis {
28725c28e83SPiotr Jasiukajtis 	return (_HI_WORD(d) >> 31);
28825c28e83SPiotr Jasiukajtis }
28925c28e83SPiotr Jasiukajtis 
290*7f11fd00SRichard Lowe extern __GNU_INLINE int
signbitf(float f)29125c28e83SPiotr Jasiukajtis signbitf(float f)
29225c28e83SPiotr Jasiukajtis {
29325c28e83SPiotr Jasiukajtis 	return ((*(uint32_t *)&f) >> 31);
29425c28e83SPiotr Jasiukajtis }
29525c28e83SPiotr Jasiukajtis 
296*7f11fd00SRichard Lowe extern __GNU_INLINE double
sqrt(double d)29725c28e83SPiotr Jasiukajtis sqrt(double d)
29825c28e83SPiotr Jasiukajtis {
29925c28e83SPiotr Jasiukajtis 	return (__inline_sqrt(d));
30025c28e83SPiotr Jasiukajtis }
30125c28e83SPiotr Jasiukajtis 
302*7f11fd00SRichard Lowe extern __GNU_INLINE float
sqrtf(float f)30325c28e83SPiotr Jasiukajtis sqrtf(float f)
30425c28e83SPiotr Jasiukajtis {
30525c28e83SPiotr Jasiukajtis 	return (__inline_sqrtf(f));
30625c28e83SPiotr Jasiukajtis }
30725c28e83SPiotr Jasiukajtis 
308*7f11fd00SRichard Lowe extern __GNU_INLINE long double
sqrtl(long double ld)30925c28e83SPiotr Jasiukajtis sqrtl(long double ld)
31025c28e83SPiotr Jasiukajtis {
31125c28e83SPiotr Jasiukajtis 	__asm__ __volatile__("fsqrt" : "+t" (ld) : : "cc");
31225c28e83SPiotr Jasiukajtis 	return (ld);
31325c28e83SPiotr Jasiukajtis }
31425c28e83SPiotr Jasiukajtis 
315*7f11fd00SRichard Lowe extern __GNU_INLINE int
isnanl(long double ld)31625c28e83SPiotr Jasiukajtis isnanl(long double ld)
31725c28e83SPiotr Jasiukajtis {
31825c28e83SPiotr Jasiukajtis 	int ret = _HIER_WORD(ld);
31925c28e83SPiotr Jasiukajtis 
32025c28e83SPiotr Jasiukajtis 	__asm__ __volatile__(
32125c28e83SPiotr Jasiukajtis 	    "andl  $0x00007fff,%0\n\t"
32225c28e83SPiotr Jasiukajtis 	    "jz	   1f\n\t"		/* jump if exp is all 0 */
32325c28e83SPiotr Jasiukajtis 	    "xorl  $0x00007fff,%0\n\t"
32425c28e83SPiotr Jasiukajtis 	    "jz	   2f\n\t"		/* jump if exp is all 1 */
32525c28e83SPiotr Jasiukajtis 	    "testl $0x80000000,%1\n\t"
32625c28e83SPiotr Jasiukajtis 	    "jz	   3f\n\t"		/* jump if leading bit is 0 */
32725c28e83SPiotr Jasiukajtis 	    "xorl  %0,%0\n\t"
32825c28e83SPiotr Jasiukajtis 	    "jmp   1f\n\t"
32925c28e83SPiotr Jasiukajtis 	    "2:\n\t"			/* note that %0 = 0 from before */
33025c28e83SPiotr Jasiukajtis 	    "cmpl  $0x80000000,%1\n\t"	/* what is first half of significand? */
33125c28e83SPiotr Jasiukajtis 	    "jnz   3f\n\t"		/* jump if not equal to 0x80000000 */
33225c28e83SPiotr Jasiukajtis 	    "testl $0xffffffff,%2\n\t"	/* is second half of significand 0? */
33325c28e83SPiotr Jasiukajtis 	    "jnz   3f\n\t"		/* jump if not equal to 0 */
33425c28e83SPiotr Jasiukajtis 	    "jmp   1f\n\t"
33525c28e83SPiotr Jasiukajtis 	    "3:\n\t"
33625c28e83SPiotr Jasiukajtis 	    "movl  $1,%0\n\t"
33725c28e83SPiotr Jasiukajtis 	    "1:\n\t"
33825c28e83SPiotr Jasiukajtis 	    : "+&r" (ret)
33925c28e83SPiotr Jasiukajtis 	    : "r" (_HI_WORD(ld)), "r" (_LO_WORD(ld))
34025c28e83SPiotr Jasiukajtis 	    : "cc");
34125c28e83SPiotr Jasiukajtis 
34225c28e83SPiotr Jasiukajtis 	return (ret);
34325c28e83SPiotr Jasiukajtis }
34425c28e83SPiotr Jasiukajtis 
34525c28e83SPiotr Jasiukajtis #ifdef __cplusplus
34625c28e83SPiotr Jasiukajtis }
34725c28e83SPiotr Jasiukajtis #endif
34825c28e83SPiotr Jasiukajtis 
34925c28e83SPiotr Jasiukajtis #endif  /* __GNUC__ */
35025c28e83SPiotr Jasiukajtis 
35125c28e83SPiotr Jasiukajtis #endif /* _LIBM_INLINES_H */