fpsetmask.c revision 1.6
11.6Smatt/* $NetBSD: fpsetmask.c,v 1.6 2012/03/19 22:23:10 matt Exp $ */ 21.2Sjonathan 31.1Sjtc/* 41.1Sjtc * Written by J.T. Conklin, Apr 11, 1995 51.1Sjtc * Public domain. 61.1Sjtc */ 71.1Sjtc 81.3Sthorpej#include <sys/cdefs.h> 91.4Slukem#if defined(LIBC_SCCS) && !defined(lint) 101.6Smatt__RCSID("$NetBSD: fpsetmask.c,v 1.6 2012/03/19 22:23:10 matt Exp $"); 111.4Slukem#endif /* LIBC_SCCS and not lint */ 121.3Sthorpej 131.3Sthorpej#include "namespace.h" 141.3Sthorpej 151.1Sjtc#include <ieeefp.h> 161.3Sthorpej 171.3Sthorpej#ifdef __weak_alias 181.3Sthorpej__weak_alias(fpsetmask,_fpsetmask) 191.3Sthorpej#endif 201.1Sjtc 211.1Sjtcfp_except 221.6Smattfpsetmask(fp_except mask) 231.1Sjtc{ 241.1Sjtc fp_except old; 251.1Sjtc fp_except new; 261.1Sjtc 271.5Sperry __asm("cfc1 %0,$31" : "=r" (old)); 281.1Sjtc 291.6Smatt new = old & ~(0x1f << 7); 301.1Sjtc new |= ((mask & 0x1f) << 7); 311.1Sjtc 321.5Sperry __asm("ctc1 %0,$31" : : "r" (new)); 331.1Sjtc 341.1Sjtc return (old >> 7) & 0x1f; 351.1Sjtc} 36