1/* $OpenBSD: fpsetmask.S,v 1.3 2018/07/03 23:14:05 mortimer Exp $ */ 2/* $NetBSD: fpsetmask.S,v 1.3 2002/06/12 19:17:22 fvdl Exp $ */ 3 4/* 5 * Written by Frank van der Linden at Wasabi Systems for NetBSD. 6 * Public domain. 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 19WEAK_ALIAS(fpsetmask, _fpsetmask) 20ENTRY(_fpsetmask) 21#else 22ENTRY(fpsetmask) 23#endif 24 RETGUARD_SETUP(fpsetmask, r11) 25 fnstcw -4(%rsp) 26 stmxcsr -8(%rsp) 27 andl $63,%edi 28 notl %edi 29 30 movl -4(%rsp),%edx 31 movl %edx,%eax 32 andl %edi,%edx 33 movl %edx,-4(%rsp) 34 35 movl -8(%rsp),%edx 36 roll $7,%edi 37 andl %edi,%edx 38 movl %edx,-8(%rsp) 39 40 fldcw -4(%rsp) 41 ldmxcsr -8(%rsp) 42 andl $63,%eax 43 RETGUARD_CHECK(fpsetmask, r11) 44 ret 45#ifdef WEAK_ALIAS 46END(_fpsetmask) 47#else 48END(fpsetmask) 49#endif 50