1*e415d488SLionel Sambuc /* $NetBSD: fpgetsticky.c,v 1.7 2012/06/24 15:26:02 christos Exp $ */ 22fe8fb19SBen Gras 32fe8fb19SBen Gras /* 42fe8fb19SBen Gras * Written by J.T. Conklin, Apr 10, 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: fpgetsticky.c,v 1.7 2012/06/24 15:26:02 christos Exp $"); 112fe8fb19SBen Gras #endif /* LIBC_SCCS and not lint */ 122fe8fb19SBen Gras 132fe8fb19SBen Gras #include "namespace.h" 142fe8fb19SBen Gras 15*e415d488SLionel Sambuc #include <sys/types.h> 162fe8fb19SBen Gras #include <ieeefp.h> 172fe8fb19SBen Gras 182fe8fb19SBen Gras #ifdef __weak_alias 192fe8fb19SBen Gras __weak_alias(fpgetsticky,_fpgetsticky) 202fe8fb19SBen Gras #endif 212fe8fb19SBen Gras 22*e415d488SLionel Sambuc #ifdef EXCEPTIONS_WITH_SOFTFLOAT 23*e415d488SLionel Sambuc extern fp_except _softfloat_float_exception_flags; 24*e415d488SLionel Sambuc #endif 25*e415d488SLionel Sambuc 262fe8fb19SBen Gras fp_except fpgetsticky(void)27*e415d488SLionel Sambucfpgetsticky(void) 282fe8fb19SBen Gras { 29*e415d488SLionel Sambuc uint32_t x; 30*e415d488SLionel Sambuc fp_except res; 312fe8fb19SBen Gras 322fe8fb19SBen Gras __asm("st %%fsr,%0" : "=m" (*&x)); 33*e415d488SLionel Sambuc res = (x >> 5) & 0x1f; 34*e415d488SLionel Sambuc 35*e415d488SLionel Sambuc #ifdef EXCEPTIONS_WITH_SOFTFLOAT 36*e415d488SLionel Sambuc res |= _softfloat_float_exception_flags; 37*e415d488SLionel Sambuc #endif 38*e415d488SLionel Sambuc 39*e415d488SLionel Sambuc return res; 402fe8fb19SBen Gras } 41