fpsetsticky.c revision 1.6
11.6Smartin/* $NetBSD: fpsetsticky.c,v 1.6 2012/03/17 21:35:06 martin Exp $ */ 21.1Seeh 31.1Seeh/* 41.1Seeh * Written by J.T. Conklin, Apr 10, 1995 51.1Seeh * Public domain. 61.1Seeh */ 71.1Seeh 81.2Sthorpej#include <sys/cdefs.h> 91.3Slukem#if defined(LIBC_SCCS) && !defined(lint) 101.6Smartin__RCSID("$NetBSD: fpsetsticky.c,v 1.6 2012/03/17 21:35:06 martin Exp $"); 111.3Slukem#endif /* LIBC_SCCS and not lint */ 121.2Sthorpej 131.2Sthorpej#include "namespace.h" 141.2Sthorpej 151.6Smartin#include <sys/types.h> 161.1Seeh#include <ieeefp.h> 171.2Sthorpej 181.2Sthorpej#ifdef __weak_alias 191.2Sthorpej__weak_alias(fpsetsticky,_fpsetsticky) 201.2Sthorpej#endif 211.1Seeh 221.5Smartin#ifdef EXCEPTIONS_WITH_SOFTFLOAT 231.5Smartinextern fp_except _softfloat_float_exception_flags; 241.5Smartin#endif 251.5Smartin 261.1Seehfp_except 271.1Seehfpsetsticky(sticky) 281.1Seeh fp_except sticky; 291.1Seeh{ 301.1Seeh fp_except old; 311.1Seeh fp_except new; 321.1Seeh 331.4Sperry __asm("st %%fsr,%0" : "=m" (*&old)); 341.1Seeh 351.1Seeh new = old; 361.1Seeh new &= ~(0x1f << 5); 371.1Seeh new |= ((sticky & 0x1f) << 5); 381.1Seeh 391.4Sperry __asm("ld %0,%%fsr" : : "m" (*&new)); 401.1Seeh 411.6Smartin old = ((uint32_t)old >> 5) & 0x1f; 421.5Smartin 431.5Smartin#ifdef EXCEPTIONS_WITH_SOFTFLOAT 441.5Smartin old |= _softfloat_float_exception_flags; 451.5Smartin _softfloat_float_exception_flags = sticky; 461.5Smartin#endif 471.5Smartin return old; 481.1Seeh} 49