<iso646.h>: Avoid conflicts w/ C++ keywords.
[dragonfly.git] / lib / libm / arch / i386 / s_copysign.S
1 /*
2  * Written by J.T. Conklin <jtc@NetBSD.org>.
3  * Public domain.
4  *
5  * $NetBSD: s_copysign.S,v 1.7 2011/06/18 20:49:26 joerg Exp
6  */
7
8 /*
9  * XXXfvdl might as well split this file.
10  */
11
12 #include <machine/asm.h>
13
14 #ifdef __x86_64__
15 .Lpos:
16         .quad   0x8000000000000000
17 .Lneg:
18         .quad   0x7fffffffffffffff
19 #endif
20
21
22 ENTRY(copysign)
23 #ifdef __i386__
24         movl    16(%esp),%edx
25         andl    $0x80000000,%edx
26         movl    8(%esp),%eax
27         andl    $0x7fffffff,%eax
28         orl     %edx,%eax
29         movl    %eax,8(%esp)
30         fldl    4(%esp)
31 #else
32         movq    .Lpos(%rip),%xmm2
33         movq    .Lneg(%rip),%xmm3
34         pand    %xmm2,%xmm1
35         pand    %xmm3,%xmm0
36         por     %xmm1,%xmm0
37 #endif
38         ret
39 END(copysign)
40
41         .section .note.GNU-stack,"",%progbits