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