1125733Sgrehan/* $NetBSD: fpgetsticky.c,v 1.3 2002/01/13 21:45:48 thorpej Exp $ */ 2125733Sgrehan 3125733Sgrehan/* 4125733Sgrehan * Copyright (c) 1999 The NetBSD Foundation, Inc. 5125733Sgrehan * All rights reserved. 6125733Sgrehan * 7125733Sgrehan * This code is derived from software contributed to The NetBSD Foundation 8125733Sgrehan * by Dan Winship. 9125733Sgrehan * 10125733Sgrehan * Redistribution and use in source and binary forms, with or without 11125733Sgrehan * modification, are permitted provided that the following conditions 12125733Sgrehan * are met: 13125733Sgrehan * 1. Redistributions of source code must retain the above copyright 14125733Sgrehan * notice, this list of conditions and the following disclaimer. 15125733Sgrehan * 2. Redistributions in binary form must reproduce the above copyright 16125733Sgrehan * notice, this list of conditions and the following disclaimer in the 17125733Sgrehan * documentation and/or other materials provided with the distribution. 18125733Sgrehan * 19125733Sgrehan * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20125733Sgrehan * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21125733Sgrehan * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22125733Sgrehan * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23125733Sgrehan * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24125733Sgrehan * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25125733Sgrehan * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26125733Sgrehan * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27125733Sgrehan * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28125733Sgrehan * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29125733Sgrehan * POSSIBILITY OF SUCH DAMAGE. 30125733Sgrehan * 31125733Sgrehan * $FreeBSD$ 32125733Sgrehan */ 33125733Sgrehan 34125733Sgrehan#include <sys/cdefs.h> 35125733Sgrehan 36125733Sgrehan#include "namespace.h" 37125733Sgrehan 38125733Sgrehan#include <sys/types.h> 39125733Sgrehan#include <ieeefp.h> 40125733Sgrehan 41176530Sraj#ifndef _SOFT_FLOAT 42125733Sgrehan#ifdef __weak_alias 43125733Sgrehan__weak_alias(fpgetsticky,_fpgetsticky) 44125733Sgrehan#endif 45125733Sgrehan 46125733Sgrehanfp_except_t 47125733Sgrehanfpgetsticky() 48125733Sgrehan{ 49125733Sgrehan u_int64_t fpscr; 50125733Sgrehan 51125733Sgrehan __asm__ __volatile("mffs %0" : "=f"(fpscr)); 52125733Sgrehan return ((fp_except_t)((fpscr >> 25) & 0x1f)); 53125733Sgrehan} 54176530Sraj#endif 55