Home | History | Annotate | Line # | Download | only in gen
fpsetround.c revision 1.2.16.1
      1  1.2.16.1   nathanw /*	$NetBSD: fpsetround.c,v 1.2.16.1 2002/01/28 20:49:57 nathanw Exp $	*/
      2       1.2  jonathan 
      3       1.1       jtc /*
      4       1.1       jtc  * Written by J.T. Conklin, Apr 11, 1995
      5       1.1       jtc  * Public domain.
      6       1.1       jtc  */
      7       1.1       jtc 
      8  1.2.16.1   nathanw #include <sys/cdefs.h>
      9  1.2.16.1   nathanw 
     10  1.2.16.1   nathanw #include "namespace.h"
     11  1.2.16.1   nathanw 
     12       1.1       jtc #include <ieeefp.h>
     13  1.2.16.1   nathanw 
     14  1.2.16.1   nathanw #ifdef __weak_alias
     15  1.2.16.1   nathanw __weak_alias(fpsetround,_fpsetround)
     16  1.2.16.1   nathanw #endif
     17       1.1       jtc 
     18       1.1       jtc fp_rnd
     19       1.1       jtc fpsetround(rnd_dir)
     20       1.1       jtc 	fp_rnd rnd_dir;
     21       1.1       jtc {
     22       1.1       jtc 	fp_rnd old;
     23       1.1       jtc 	fp_rnd new;
     24       1.1       jtc 
     25       1.1       jtc 	__asm__("cfc1 %0,$31" : "=r" (old));
     26       1.1       jtc 
     27       1.1       jtc 	new = old;
     28       1.1       jtc 	new &= ~0x03;
     29       1.1       jtc 	new |= (rnd_dir & 0x03);
     30       1.1       jtc 
     31       1.1       jtc 	__asm__("ctc1 %0,$31" : : "r" (new));
     32       1.1       jtc 
     33       1.1       jtc 	return old & 0x03;
     34       1.1       jtc }
     35