fpsetround.c revision 1.2
11.2Sthorpej/* $NetBSD: fpsetround.c,v 1.2 2002/01/13 21:45:51 thorpej 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.2Sthorpej 101.2Sthorpej#include "namespace.h" 111.2Sthorpej 121.1Seeh#include <ieeefp.h> 131.2Sthorpej 141.2Sthorpej#ifdef __weak_alias 151.2Sthorpej__weak_alias(fpsetround,_fpsetround) 161.2Sthorpej#endif 171.1Seeh 181.1Seehfp_rnd 191.1Seehfpsetround(rnd_dir) 201.1Seeh fp_rnd rnd_dir; 211.1Seeh{ 221.1Seeh fp_rnd old; 231.1Seeh fp_rnd new; 241.1Seeh 251.1Seeh __asm__("st %%fsr,%0" : "=m" (*&old)); 261.1Seeh 271.1Seeh new = old; 281.1Seeh new &= ~(0x03 << 30); 291.1Seeh new |= ((rnd_dir & 0x03) << 30); 301.1Seeh 311.1Seeh __asm__("ld %0,%%fsr" : : "m" (*&new)); 321.1Seeh 331.1Seeh return (old >> 30) & 0x03; 341.1Seeh} 35