fpsetround.c revision 1.5
11.5Smartin/* $NetBSD: fpsetround.c,v 1.5 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.5Smartin__RCSID("$NetBSD: fpsetround.c,v 1.5 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.5Smartin#include <sys/types.h> 161.1Seeh#include <ieeefp.h> 171.2Sthorpej 181.2Sthorpej#ifdef __weak_alias 191.2Sthorpej__weak_alias(fpsetround,_fpsetround) 201.2Sthorpej#endif 211.1Seeh 221.1Seehfp_rnd 231.1Seehfpsetround(rnd_dir) 241.1Seeh fp_rnd rnd_dir; 251.1Seeh{ 261.1Seeh fp_rnd old; 271.1Seeh fp_rnd new; 281.1Seeh 291.4Sperry __asm("st %%fsr,%0" : "=m" (*&old)); 301.1Seeh 311.1Seeh new = old; 321.1Seeh new &= ~(0x03 << 30); 331.1Seeh new |= ((rnd_dir & 0x03) << 30); 341.1Seeh 351.4Sperry __asm("ld %0,%%fsr" : : "m" (*&new)); 361.1Seeh 371.5Smartin return ((uint32_t)old >> 30) & 0x03; 381.1Seeh} 39