xref: /netbsd-src/lib/libc/arch/powerpc/gen/flt_rounds.c (revision 481fca6e59249d8ffcf24fef7cfbe7b131bfb080)
1 /*	$NetBSD: flt_rounds.c,v 1.4 1999/07/07 01:53:38 danw Exp $	*/
2 
3 #include <float.h>
4 
5 static const int map[] = {
6 	1,	/* round to nearest */
7 	0,	/* round to zero */
8 	2,	/* round to positive infinity */
9 	3	/* round to negative infinity */
10 };
11 
12 int
13 __flt_rounds()
14 {
15 	double tmp;
16 	int x;
17 
18 	__asm__ __volatile("mffs %0; stfiwx %0,0,%1" : "=f"(tmp): "b"(&x));
19 	return map[x & 0x03];
20 }
21