]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - lib/libc/mips/gen/flt_rounds.c
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / lib / libc / mips / gen / flt_rounds.c
1 /*      $NetBSD: flt_rounds.c,v 1.5 2005/12/24 23:10:08 perry Exp $     */
2
3 /*
4  * Written by J.T. Conklin, Apr 11, 1995
5  * Public domain.
6  */
7
8 #include <sys/cdefs.h>
9 __FBSDID("$FreeBSD$");
10 #if defined(LIBC_SCCS) && !defined(lint)
11 __RCSID("$NetBSD: flt_rounds.c,v 1.5 2005/12/24 23:10:08 perry Exp $");
12 #endif /* LIBC_SCCS and not lint */
13
14 #include <machine/float.h>
15
16 static const int map[] = {
17         1,      /* round to nearest */
18         0,      /* round to zero */
19         2,      /* round to positive infinity */
20         3       /* round to negative infinity */
21 };
22
23 int
24 __flt_rounds()
25 {
26         int x;
27
28         __asm("cfc1 %0,$31" : "=r" (x));
29         return map[x & 0x03];
30 }