Home | History | Annotate | Line # | Download | only in gen
fpsetmask.c revision 1.3
      1  1.3    lukem /*	$NetBSD: fpsetmask.c,v 1.3 2005/06/12 05:21:27 lukem Exp $	*/
      2  1.1      eeh 
      3  1.1      eeh /*
      4  1.1      eeh  * Written by J.T. Conklin, Apr 10, 1995
      5  1.1      eeh  * Public domain.
      6  1.1      eeh  */
      7  1.1      eeh 
      8  1.2  thorpej #include <sys/cdefs.h>
      9  1.3    lukem #if defined(LIBC_SCCS) && !defined(lint)
     10  1.3    lukem __RCSID("$NetBSD: fpsetmask.c,v 1.3 2005/06/12 05:21:27 lukem Exp $");
     11  1.3    lukem #endif /* LIBC_SCCS and not lint */
     12  1.2  thorpej 
     13  1.2  thorpej #include "namespace.h"
     14  1.2  thorpej 
     15  1.1      eeh #include <ieeefp.h>
     16  1.2  thorpej 
     17  1.2  thorpej #ifdef __weak_alias
     18  1.2  thorpej __weak_alias(fpsetmask,_fpsetmask)
     19  1.2  thorpej #endif
     20  1.1      eeh 
     21  1.1      eeh fp_except
     22  1.1      eeh fpsetmask(mask)
     23  1.1      eeh 	fp_except mask;
     24  1.1      eeh {
     25  1.1      eeh 	fp_except old;
     26  1.1      eeh 	fp_except new;
     27  1.1      eeh 
     28  1.1      eeh 	__asm__("st %%fsr,%0" : "=m" (*&old));
     29  1.1      eeh 
     30  1.1      eeh 	new = old;
     31  1.1      eeh 	new &= ~(0x1f << 23);
     32  1.1      eeh 	new |= ((mask & 0x1f) << 23);
     33  1.1      eeh 
     34  1.1      eeh 	__asm__("ld %0,%%fsr" : : "m" (*&new));
     35  1.1      eeh 
     36  1.1      eeh 	return (old >> 23) & 0x1f;
     37  1.1      eeh }
     38