fpsetround.c revision 1.4
11.4Slukem/* $NetBSD: fpsetround.c,v 1.4 2005/06/12 05:21:26 lukem Exp $ */ 21.2Sperry 31.1Sjtc/* 41.1Sjtc * Written by J.T. Conklin, Apr 10, 1995 51.1Sjtc * Public domain. 61.1Sjtc */ 71.1Sjtc 81.3Sthorpej#include <sys/cdefs.h> 91.4Slukem#if defined(LIBC_SCCS) && !defined(lint) 101.4Slukem__RCSID("$NetBSD: fpsetround.c,v 1.4 2005/06/12 05:21:26 lukem 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(fpsetround,_fpsetround) 191.3Sthorpej#endif 201.1Sjtc 211.1Sjtcfp_rnd 221.1Sjtcfpsetround(rnd_dir) 231.1Sjtc fp_rnd rnd_dir; 241.1Sjtc{ 251.1Sjtc fp_rnd old; 261.1Sjtc fp_rnd new; 271.1Sjtc 281.1Sjtc __asm__("st %%fsr,%0" : "=m" (*&old)); 291.1Sjtc 301.1Sjtc new = old; 311.1Sjtc new &= ~(0x03 << 30); 321.1Sjtc new |= ((rnd_dir & 0x03) << 30); 331.1Sjtc 341.1Sjtc __asm__("ld %0,%%fsr" : : "m" (*&new)); 351.1Sjtc 361.1Sjtc return (old >> 30) & 0x03; 371.1Sjtc} 38