xref: /freebsd/lib/libc/powerpc64/gen/fpgetsticky.c (revision d915a14ef094c8dfc1a5aee70e135abfec01d0f1)
1840b91ccSNathan Whitehorn /*	$NetBSD: fpgetsticky.c,v 1.3 2002/01/13 21:45:48 thorpej Exp $	*/
2840b91ccSNathan Whitehorn 
3*d915a14eSPedro F. Giffuni /*-
4*d915a14eSPedro F. Giffuni  * SPDX-License-Identifier: BSD-2-Clause-NetBSD
5*d915a14eSPedro F. Giffuni  *
6840b91ccSNathan Whitehorn  * Copyright (c) 1999 The NetBSD Foundation, Inc.
7840b91ccSNathan Whitehorn  * All rights reserved.
8840b91ccSNathan Whitehorn  *
9840b91ccSNathan Whitehorn  * This code is derived from software contributed to The NetBSD Foundation
10840b91ccSNathan Whitehorn  * by Dan Winship.
11840b91ccSNathan Whitehorn  *
12840b91ccSNathan Whitehorn  * Redistribution and use in source and binary forms, with or without
13840b91ccSNathan Whitehorn  * modification, are permitted provided that the following conditions
14840b91ccSNathan Whitehorn  * are met:
15840b91ccSNathan Whitehorn  * 1. Redistributions of source code must retain the above copyright
16840b91ccSNathan Whitehorn  *    notice, this list of conditions and the following disclaimer.
17840b91ccSNathan Whitehorn  * 2. Redistributions in binary form must reproduce the above copyright
18840b91ccSNathan Whitehorn  *    notice, this list of conditions and the following disclaimer in the
19840b91ccSNathan Whitehorn  *    documentation and/or other materials provided with the distribution.
20840b91ccSNathan Whitehorn  *
21840b91ccSNathan Whitehorn  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
22840b91ccSNathan Whitehorn  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23840b91ccSNathan Whitehorn  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24840b91ccSNathan Whitehorn  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
25840b91ccSNathan Whitehorn  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26840b91ccSNathan Whitehorn  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27840b91ccSNathan Whitehorn  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28840b91ccSNathan Whitehorn  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29840b91ccSNathan Whitehorn  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30840b91ccSNathan Whitehorn  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31840b91ccSNathan Whitehorn  * POSSIBILITY OF SUCH DAMAGE.
32840b91ccSNathan Whitehorn  *
33840b91ccSNathan Whitehorn  * $FreeBSD$
34840b91ccSNathan Whitehorn  */
35840b91ccSNathan Whitehorn 
36840b91ccSNathan Whitehorn #include <sys/cdefs.h>
37840b91ccSNathan Whitehorn 
38840b91ccSNathan Whitehorn #include "namespace.h"
39840b91ccSNathan Whitehorn 
40840b91ccSNathan Whitehorn #include <sys/types.h>
41840b91ccSNathan Whitehorn #include <ieeefp.h>
42840b91ccSNathan Whitehorn 
43840b91ccSNathan Whitehorn #ifndef _SOFT_FLOAT
44840b91ccSNathan Whitehorn #ifdef __weak_alias
45840b91ccSNathan Whitehorn __weak_alias(fpgetsticky,_fpgetsticky)
46840b91ccSNathan Whitehorn #endif
47840b91ccSNathan Whitehorn 
48840b91ccSNathan Whitehorn fp_except_t
49840b91ccSNathan Whitehorn fpgetsticky()
50840b91ccSNathan Whitehorn {
51840b91ccSNathan Whitehorn 	u_int64_t fpscr;
52840b91ccSNathan Whitehorn 
53840b91ccSNathan Whitehorn 	__asm__ __volatile("mffs %0" : "=f"(fpscr));
54840b91ccSNathan Whitehorn 	return ((fp_except_t)((fpscr >> 25) & 0x1f));
55840b91ccSNathan Whitehorn }
56840b91ccSNathan Whitehorn #endif
57