1*b5aa3b33Sguenther /* $OpenBSD: fpgetmask.c,v 1.2 2014/04/18 15:09:52 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_except
fpgetmask()23cf252584Smiod fpgetmask()
24cf252584Smiod {
25cf252584Smiod register_t fpscr;
26cf252584Smiod
27*b5aa3b33Sguenther __asm__ volatile ("sts fpscr, %0" : "=r" (fpscr));
28cf252584Smiod return ((fpscr >> 7) & 0x1f);
29cf252584Smiod }
30