hurd: fix fcntl visibility
[glibc.git] / sysdeps / x86_64 / fpu / e_scalbl.S
blob2982dc3b9e7cb0d9b2bffaf6744eed42b8213738
1 /*
2  * Written by J.T. Conklin <jtc@netbsd.org>.
3  * Public domain.
4  *
5  * Adapted for `long double' by Ulrich Drepper <drepper@cygnus.com>.
6  * Adapted for x86-64 by Andreas Jaeger <aj@suse.de>
7  *
8  * Correct handling of y==-inf <drepper@gnu>
9  */
11 #include <machine/asm.h>
13         .section .rodata
15         .align ALIGNARG(4)
16         .type zero_nan,@object
17 zero_nan:
18         .double 0.0
19 nan:    .byte 0, 0, 0, 0, 0, 0, 0xff, 0x7f
20         .byte 0, 0, 0, 0, 0, 0, 0, 0x80
21         .byte 0, 0, 0, 0, 0, 0, 0xff, 0x7f
22         ASM_SIZE_DIRECTIVE(zero_nan)
25 #ifdef PIC
26 # define MO(op) op##(%rip)
27 #else
28 # define MO(op) op
29 #endif
31         .text
32 ENTRY(__ieee754_scalbl)
33         fldt    24(%rsp)
34         fxam
35         fnstsw
36         fldt    8(%rsp)
37         andl    $0x4700, %eax
38         cmpl    $0x0700, %eax
39         je      1f
40         andl    $0x4500, %eax
41         cmpl    $0x0100, %eax
42         je      2f
43         fxam
44         fnstsw
45         andl    $0x4500, %eax
46         cmpl    $0x0100, %eax
47         je      2f
48         fld     %st(1)
49         frndint
50         fcomip  %st(2), %st
51         jne     4f
52         fscale
53         fstp    %st(1)
54         ret
56         /* y is -inf */
57 1:      fxam
58         fnstsw
59         movl    16(%rsp), %edx
60         shrl    $5, %eax
61         fstp    %st
62         fstp    %st
63         andl    $0x8000, %edx
64         andl    $0x0228, %eax
65         cmpl    $0x0028, %eax
66         je      4f
67         andl    $8, %eax
68         shrl    $11, %edx
69         addl    %edx, %eax
70 #ifdef PIC
71         lea     zero_nan(%rip),%rdx
72         fldl    (%rdx,%rax,1)
73 #else
74         fldl    zero_nan(%rax, 1)
75 #endif
76         ret
78         /* The result is NaN; raise an exception for sNaN arguments.  */
79 2:      faddp
80         ret
82         /* Return NaN and raise the invalid exception.  */
83 4:      fstp    %st
84         fstp    %st
85         fldz
86         fdiv    %st
87         ret
88 END(__ieee754_scalbl)
89 strong_alias (__ieee754_scalbl, __scalbl_finite)