475206fd1a829d22c06b8d879abf06af10d3c7f4
[dragonfly.git] / lib / libc / amd64 / gen / fpsetmask.S
1 /*
2  * Written by Frank van der Linden at Wasabi Systems for NetBSD.
3  * Public domain.
4  *
5  * $NetBSD: fpsetmask.S,v 1.3 2002/06/12 19:17:22 fvdl Exp $
6  * $DragonFly: src/lib/libc/amd64/gen/fpsetmask.S,v 1.1 2006/07/27 00:46:57 corecode Exp $
7  */
8
9 #include <machine/asm.h>
10
11 /*
12  * XXX set both the x87 control word and the SSE mxcsr register.
13  * Applications should only set exception and round flags
14  * via the fp*() interface, otherwise the status words
15  * will get our of sync.
16  */
17
18 #ifdef WEAK_ALIAS
19 WEAK_ALIAS(fpsetmask, _fpsetmask)
20 ENTRY(_fpsetmask)
21 #else
22 ENTRY(fpsetmask)
23 #endif
24         fnstcw  -4(%rsp)
25         stmxcsr -8(%rsp)
26         andl    $63,%edi
27         notl    %edi
28
29         movl    -4(%rsp),%edx
30         movl    %edx,%eax
31         andl    %edi,%edx
32         movl    %edx,-4(%rsp)
33
34         movl    -8(%rsp),%edx
35         roll    $7,%edi
36         andl    %edi,%edx
37         movl    %edx,-8(%rsp)
38
39         fldcw   -4(%rsp)
40         ldmxcsr -8(%rsp)
41         andl    $63,%eax
42         ret