xref: /freebsd/lib/libc/powerpc64/gen/fpgetmask.c (revision 840b91cc52085d26c112e99d733f71eb92c3ff54)
1*840b91ccSNathan Whitehorn /*	$NetBSD: fpgetmask.c,v 1.3 2002/01/13 21:45:47 thorpej Exp $	*/
2*840b91ccSNathan Whitehorn 
3*840b91ccSNathan Whitehorn /*
4*840b91ccSNathan Whitehorn  * Copyright (c) 1999 The NetBSD Foundation, Inc.
5*840b91ccSNathan Whitehorn  * All rights reserved.
6*840b91ccSNathan Whitehorn  *
7*840b91ccSNathan Whitehorn  * This code is derived from software contributed to The NetBSD Foundation
8*840b91ccSNathan Whitehorn  * by Dan Winship.
9*840b91ccSNathan Whitehorn  *
10*840b91ccSNathan Whitehorn  * Redistribution and use in source and binary forms, with or without
11*840b91ccSNathan Whitehorn  * modification, are permitted provided that the following conditions
12*840b91ccSNathan Whitehorn  * are met:
13*840b91ccSNathan Whitehorn  * 1. Redistributions of source code must retain the above copyright
14*840b91ccSNathan Whitehorn  *    notice, this list of conditions and the following disclaimer.
15*840b91ccSNathan Whitehorn  * 2. Redistributions in binary form must reproduce the above copyright
16*840b91ccSNathan Whitehorn  *    notice, this list of conditions and the following disclaimer in the
17*840b91ccSNathan Whitehorn  *    documentation and/or other materials provided with the distribution.
18*840b91ccSNathan Whitehorn  * 3. All advertising materials mentioning features or use of this software
19*840b91ccSNathan Whitehorn  *    must display the following acknowledgement:
20*840b91ccSNathan Whitehorn  *	This product includes software developed by the NetBSD
21*840b91ccSNathan Whitehorn  *	Foundation, Inc. and its contributors.
22*840b91ccSNathan Whitehorn  * 4. Neither the name of The NetBSD Foundation nor the names of its
23*840b91ccSNathan Whitehorn  *    contributors may be used to endorse or promote products derived
24*840b91ccSNathan Whitehorn  *    from this software without specific prior written permission.
25*840b91ccSNathan Whitehorn  *
26*840b91ccSNathan Whitehorn  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27*840b91ccSNathan Whitehorn  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28*840b91ccSNathan Whitehorn  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29*840b91ccSNathan Whitehorn  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30*840b91ccSNathan Whitehorn  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31*840b91ccSNathan Whitehorn  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32*840b91ccSNathan Whitehorn  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33*840b91ccSNathan Whitehorn  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34*840b91ccSNathan Whitehorn  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35*840b91ccSNathan Whitehorn  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36*840b91ccSNathan Whitehorn  * POSSIBILITY OF SUCH DAMAGE.
37*840b91ccSNathan Whitehorn  *
38*840b91ccSNathan Whitehorn  */
39*840b91ccSNathan Whitehorn 
40*840b91ccSNathan Whitehorn #include <sys/cdefs.h>
41*840b91ccSNathan Whitehorn __FBSDID("$FreeBSD$");
42*840b91ccSNathan Whitehorn 
43*840b91ccSNathan Whitehorn #include <sys/types.h>
44*840b91ccSNathan Whitehorn #include <ieeefp.h>
45*840b91ccSNathan Whitehorn 
46*840b91ccSNathan Whitehorn #ifndef _SOFT_FLOAT
47*840b91ccSNathan Whitehorn fp_except_t
48*840b91ccSNathan Whitehorn fpgetmask()
49*840b91ccSNathan Whitehorn {
50*840b91ccSNathan Whitehorn 	u_int64_t fpscr;
51*840b91ccSNathan Whitehorn 
52*840b91ccSNathan Whitehorn 	__asm__("mffs %0" : "=f"(fpscr));
53*840b91ccSNathan Whitehorn 	return ((fp_except_t)((fpscr >> 3) & 0x1f));
54*840b91ccSNathan Whitehorn }
55*840b91ccSNathan Whitehorn #endif
56