ad763de78215dec47ad669aeecae4bee7dd9bf31
[dragonfly.git] / lib / libc / amd64 / gen / fpsetsticky.S
1 /*
2  * Written by Frank van der Linden at Wasabi Systems for NetBSD
3  * Public domain.
4  *
5  * $NetBSD: fpsetsticky.S,v 1.5 2004/03/09 17:16:13 drochner Exp $
6  * $DragonFly: src/lib/libc/amd64/gen/fpsetsticky.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 status 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
19 #ifdef WEAK_ALIAS
20 WEAK_ALIAS(fpsetsticky, _fpsetsticky)
21 ENTRY(_fpsetsticky)
22 #else
23 ENTRY(fpsetsticky)
24 #endif
25         fnstenv -28(%rsp)
26         stmxcsr -32(%rsp)
27
28         andl    $63,%edi
29
30         movl    -24(%rsp),%eax
31         movl    %eax,%edx
32         andb    $0xc0,%dl
33
34         orl     %edi,%edx
35         movl    %edx,-24(%rsp)
36
37         movl    -32(%rsp),%edx
38         orl     %edx,%eax
39         andl    $63,%eax
40         andb    $0xc0,%dl
41         orl     %edi,%edx
42         movl    %edx,-32(%rsp)
43
44         ldmxcsr -32(%rsp)
45         fldenv  -28(%rsp)
46         ret