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