1209878Snwhitehorn/*	$NetBSD: fpgetsticky.c,v 1.3 2002/01/13 21:45:48 thorpej Exp $	*/
2209878Snwhitehorn
3331722Seadler/*
4209878Snwhitehorn * Copyright (c) 1999 The NetBSD Foundation, Inc.
5209878Snwhitehorn * All rights reserved.
6209878Snwhitehorn *
7209878Snwhitehorn * This code is derived from software contributed to The NetBSD Foundation
8209878Snwhitehorn * by Dan Winship.
9209878Snwhitehorn *
10209878Snwhitehorn * Redistribution and use in source and binary forms, with or without
11209878Snwhitehorn * modification, are permitted provided that the following conditions
12209878Snwhitehorn * are met:
13209878Snwhitehorn * 1. Redistributions of source code must retain the above copyright
14209878Snwhitehorn *    notice, this list of conditions and the following disclaimer.
15209878Snwhitehorn * 2. Redistributions in binary form must reproduce the above copyright
16209878Snwhitehorn *    notice, this list of conditions and the following disclaimer in the
17209878Snwhitehorn *    documentation and/or other materials provided with the distribution.
18209878Snwhitehorn *
19209878Snwhitehorn * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20209878Snwhitehorn * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21209878Snwhitehorn * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22209878Snwhitehorn * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23209878Snwhitehorn * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24209878Snwhitehorn * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25209878Snwhitehorn * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26209878Snwhitehorn * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27209878Snwhitehorn * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28209878Snwhitehorn * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29209878Snwhitehorn * POSSIBILITY OF SUCH DAMAGE.
30209878Snwhitehorn *
31209878Snwhitehorn * $FreeBSD$
32209878Snwhitehorn */
33209878Snwhitehorn
34209878Snwhitehorn#include <sys/cdefs.h>
35209878Snwhitehorn
36209878Snwhitehorn#include "namespace.h"
37209878Snwhitehorn
38209878Snwhitehorn#include <sys/types.h>
39209878Snwhitehorn#include <ieeefp.h>
40209878Snwhitehorn
41209878Snwhitehorn#ifndef _SOFT_FLOAT
42209878Snwhitehorn#ifdef __weak_alias
43209878Snwhitehorn__weak_alias(fpgetsticky,_fpgetsticky)
44209878Snwhitehorn#endif
45209878Snwhitehorn
46209878Snwhitehornfp_except_t
47209878Snwhitehornfpgetsticky()
48209878Snwhitehorn{
49209878Snwhitehorn	u_int64_t fpscr;
50209878Snwhitehorn
51209878Snwhitehorn	__asm__ __volatile("mffs %0" : "=f"(fpscr));
52209878Snwhitehorn	return ((fp_except_t)((fpscr >> 25) & 0x1f));
53209878Snwhitehorn}
54209878Snwhitehorn#endif
55