1*a078c856Smrg /* $NetBSD: fpsetsticky.c,v 1.7 2013/10/28 01:06:36 mrg Exp $ */ 2cf009bccSeeh 3cf009bccSeeh /* 4cf009bccSeeh * Written by J.T. Conklin, Apr 10, 1995 5cf009bccSeeh * Public domain. 6cf009bccSeeh */ 7cf009bccSeeh 85d3e8294Sthorpej #include <sys/cdefs.h> 988c3eadbSlukem #if defined(LIBC_SCCS) && !defined(lint) 10*a078c856Smrg __RCSID("$NetBSD: fpsetsticky.c,v 1.7 2013/10/28 01:06:36 mrg Exp $"); 1188c3eadbSlukem #endif /* LIBC_SCCS and not lint */ 125d3e8294Sthorpej 135d3e8294Sthorpej #include "namespace.h" 145d3e8294Sthorpej 150abf123aSmartin #include <sys/types.h> 16cf009bccSeeh #include <ieeefp.h> 17cf009bccSeeh 185d3e8294Sthorpej #ifdef __weak_alias 195d3e8294Sthorpej __weak_alias(fpsetsticky,_fpsetsticky) 205d3e8294Sthorpej #endif 215d3e8294Sthorpej 2249f1dcc8Smartin #ifdef EXCEPTIONS_WITH_SOFTFLOAT 2349f1dcc8Smartin extern fp_except _softfloat_float_exception_flags; 2449f1dcc8Smartin #endif 2549f1dcc8Smartin 26cf009bccSeeh fp_except fpsetsticky(fp_except sticky)27*a078c856Smrgfpsetsticky(fp_except sticky) 28cf009bccSeeh { 29cf009bccSeeh fp_except old; 30cf009bccSeeh fp_except new; 31cf009bccSeeh 32ce666bb8Sperry __asm("st %%fsr,%0" : "=m" (*&old)); 33cf009bccSeeh 34cf009bccSeeh new = old; 35cf009bccSeeh new &= ~(0x1f << 5); 36cf009bccSeeh new |= ((sticky & 0x1f) << 5); 37cf009bccSeeh 38ce666bb8Sperry __asm("ld %0,%%fsr" : : "m" (*&new)); 39cf009bccSeeh 400abf123aSmartin old = ((uint32_t)old >> 5) & 0x1f; 4149f1dcc8Smartin 4249f1dcc8Smartin #ifdef EXCEPTIONS_WITH_SOFTFLOAT 4349f1dcc8Smartin old |= _softfloat_float_exception_flags; 4449f1dcc8Smartin _softfloat_float_exception_flags = sticky; 4549f1dcc8Smartin #endif 4649f1dcc8Smartin return old; 47cf009bccSeeh } 48