1*e415d488SLionel Sambuc /* $NetBSD: fpsetsticky.c,v 1.8 2012/03/20 16:19:56 matt Exp $ */ 22fe8fb19SBen Gras 32fe8fb19SBen Gras /* 42fe8fb19SBen Gras * Written by J.T. Conklin, Apr 11, 1995 52fe8fb19SBen Gras * Public domain. 62fe8fb19SBen Gras */ 72fe8fb19SBen Gras 82fe8fb19SBen Gras #include <sys/cdefs.h> 92fe8fb19SBen Gras #if defined(LIBC_SCCS) && !defined(lint) 10*e415d488SLionel Sambuc __RCSID("$NetBSD: fpsetsticky.c,v 1.8 2012/03/20 16:19:56 matt Exp $"); 112fe8fb19SBen Gras #endif /* LIBC_SCCS and not lint */ 122fe8fb19SBen Gras 132fe8fb19SBen Gras #include "namespace.h" 142fe8fb19SBen Gras 152fe8fb19SBen Gras #include <ieeefp.h> 162fe8fb19SBen Gras 172fe8fb19SBen Gras #ifdef __weak_alias 182fe8fb19SBen Gras __weak_alias(fpsetsticky,_fpsetsticky) 192fe8fb19SBen Gras #endif 202fe8fb19SBen Gras 212fe8fb19SBen Gras fp_except 22*e415d488SLionel Sambuc fpsetsticky(fp_except sticky) 232fe8fb19SBen Gras { 242fe8fb19SBen Gras fp_except old; 252fe8fb19SBen Gras fp_except new; 262fe8fb19SBen Gras 272fe8fb19SBen Gras __asm("cfc1 %0,$31" : "=r" (old)); 282fe8fb19SBen Gras 29*e415d488SLionel Sambuc new = old & ~(0x1f << 2); 30*e415d488SLionel Sambuc new |= (sticky & 0x1f) << 2; 312fe8fb19SBen Gras 322fe8fb19SBen Gras __asm("ctc1 %0,$31" : : "r" (new)); 332fe8fb19SBen Gras 342fe8fb19SBen Gras return (old >> 2) & 0x1f; 352fe8fb19SBen Gras } 36