1 /* $OpenBSD: fpgetround.c,v 1.3 2016/07/26 19:07:09 guenther Exp $ */
2 /*
3 * Copyright (c) 2006 Miodrag Vallat.
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice, this permission notice, and the disclaimer below
8 * appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19 #include <sys/types.h>
20 #include <ieeefp.h>
21
22 fp_rnd
fpgetround(void)23 fpgetround(void)
24 {
25 register_t fpscr;
26
27 __asm__ volatile ("sts fpscr, %0" : "=r" (fpscr));
28 return (fpscr & 0x3);
29 }
30 DEF_WEAK(fpgetround);
31