| 1 | /** |
| 2 | * This file has no copyright assigned and is placed in the Public Domain. |
| 3 | * This file is part of the mingw-w64 runtime package. |
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. |
| 5 | */ |
| 6 | #include <_mingw_mac.h> |
| 7 | |
| 8 | 	.file	"ilogbl.S" |
| 9 | 	.text |
| 10 | #ifdef __x86_64__ |
| 11 | 	.align 8 |
| 12 | #else |
| 13 | 	.align 4 |
| 14 | #endif |
| 15 | .globl __MINGW_USYMBOL(ilogbl) |
| 16 | 	.def	__MINGW_USYMBOL(ilogbl);	.scl	2;	.type	32;	.endef |
| 17 | __MINGW_USYMBOL(ilogbl): |
| 18 | #ifdef __x86_64__ |
| 19 | 	fldt	(%rcx) |
| 20 | 	fxam			/* Is NaN or +-Inf? */ |
| 21 | 	fstsw %ax |
| 22 | 	movb $0x45, %dh |
| 23 | 	andb %ah, %dh |
| 24 | 	cmpb $0x05, %dh |
| 25 | 	je 1f		/* Is +-Inf, jump. */ |
| 26 | 	cmpb $0x01, %dh |
| 27 | 	je 1f		/* Is NaN, jump. */ |
| 28 | |
| 29 | 	fxtract |
| 30 | 	pushq	%rax |
| 31 | 	fstp	%st |
| 32 | |
| 33 | 	fistpl	(%rsp) |
| 34 | 	fwait |
| 35 | 	popq	%rax |
| 36 | |
| 37 | 	ret |
| 38 | |
| 39 | 1:	fstp	%st |
| 40 | 	movl	$0x7fffffff, %eax |
| 41 | 	ret |
| 42 | #else |
| 43 | 	fldt	4(%esp) |
| 44 | /* I added the following ugly construct because ilogb(+-Inf) is |
| 45 | required to return INT_MAX in ISO C99. |
| 46 | -- jakub@redhat.com. */ |
| 47 | 	fxam			/* Is NaN or +-Inf? */ |
| 48 | 	fstsw %ax |
| 49 | 	movb $0x45, %dh |
| 50 | 	andb %ah, %dh |
| 51 | 	cmpb $0x05, %dh |
| 52 | 	je 1f		/* Is +-Inf, jump. */ |
| 53 | 	cmpb $0x01, %dh |
| 54 | 	je 1f		/* Is NaN, jump. */ |
| 55 | |
| 56 | 	fxtract |
| 57 | 	pushl	%eax |
| 58 | 	fstp	%st |
| 59 | |
| 60 | 	fistpl	(%esp) |
| 61 | 	fwait |
| 62 | 	popl	%eax |
| 63 | |
| 64 | 	ret |
| 65 | |
| 66 | 1:	fstp	%st |
| 67 | 	movl	$0x7fffffff, %eax |
| 68 | 	ret |
| 69 | #endif |