1/* $NetBSD: fpsetmask.S,v 1.6 2014/05/22 15:01:56 uebayasi Exp $ */ 2 3/* 4 * Written by Frank van der Linden at Wasabi Systems for NetBSD. 5 * Public domain. 6 */ 7 8#include <machine/asm.h> 9 10/* 11 * XXX set both the x87 control word and the SSE mxcsr register. 12 * Applications should only set exception and round flags 13 * via the fp*() interface, otherwise the status words 14 * will get our of sync. 15 */ 16 17#ifdef WEAK_ALIAS 18WEAK_ALIAS(fpsetmask, _fpsetmask) 19ENTRY(_fpsetmask) 20#else 21ENTRY(fpsetmask) 22#endif 23 notl %edi 24 andl $0x0000003f,%edi 25 26 fnstcw -4(%rsp) 27 movl -4(%rsp), %edx 28 movl %edx, %eax 29 andl $0xffffffc0, %edx 30 orl %edi, %edx 31 movl %edx,-4(%rsp) 32 fldcw -4(%rsp) 33 34 stmxcsr -4(%rsp) 35 movl -4(%rsp), %edx 36 andl $0xffffe07f, %edx 37 sall $7, %edi 38 orl %edi, %edx 39 movl %edx,-4(%rsp) 40 ldmxcsr -4(%rsp) 41 42 notl %eax 43 andl $0x0000003f, %eax 44 ret 45#ifdef WEAK_ALIAS 46END(_fpsetmask) 47#else 48END(fpsetmask) 49#endif 50