1 1.2.16.1 nathanw /* $NetBSD: fpsetsticky.c,v 1.2.16.1 2002/01/28 20:49:58 nathanw Exp $ */ 2 1.2 jonathan 3 1.1 jtc /* 4 1.1 jtc * Written by J.T. Conklin, Apr 11, 1995 5 1.1 jtc * Public domain. 6 1.1 jtc */ 7 1.1 jtc 8 1.2.16.1 nathanw #include <sys/cdefs.h> 9 1.2.16.1 nathanw 10 1.2.16.1 nathanw #include "namespace.h" 11 1.2.16.1 nathanw 12 1.1 jtc #include <ieeefp.h> 13 1.2.16.1 nathanw 14 1.2.16.1 nathanw #ifdef __weak_alias 15 1.2.16.1 nathanw __weak_alias(fpsetsticky,_fpsetsticky) 16 1.2.16.1 nathanw #endif 17 1.1 jtc 18 1.1 jtc fp_except 19 1.1 jtc fpsetsticky(sticky) 20 1.1 jtc fp_except sticky; 21 1.1 jtc { 22 1.1 jtc fp_except old; 23 1.1 jtc fp_except new; 24 1.1 jtc 25 1.1 jtc __asm__("cfc1 %0,$31" : "=r" (old)); 26 1.1 jtc 27 1.1 jtc new = old; 28 1.1 jtc new &= ~(0x1f << 2); 29 1.1 jtc new |= ((sticky & 0x1f) << 2); 30 1.1 jtc 31 1.1 jtc __asm__("ctc1 %0,$31" : : "r" (new)); 32 1.1 jtc 33 1.1 jtc return (old >> 2) & 0x1f; 34 1.1 jtc } 35