188d2dd24SPeter Grehan /* $NetBSD: fpgetsticky.c,v 1.3 2002/01/13 21:45:48 thorpej Exp $ */ 288d2dd24SPeter Grehan 388d2dd24SPeter Grehan /* 488d2dd24SPeter Grehan * Copyright (c) 1999 The NetBSD Foundation, Inc. 588d2dd24SPeter Grehan * All rights reserved. 688d2dd24SPeter Grehan * 788d2dd24SPeter Grehan * This code is derived from software contributed to The NetBSD Foundation 888d2dd24SPeter Grehan * by Dan Winship. 988d2dd24SPeter Grehan * 1088d2dd24SPeter Grehan * Redistribution and use in source and binary forms, with or without 1188d2dd24SPeter Grehan * modification, are permitted provided that the following conditions 1288d2dd24SPeter Grehan * are met: 1388d2dd24SPeter Grehan * 1. Redistributions of source code must retain the above copyright 1488d2dd24SPeter Grehan * notice, this list of conditions and the following disclaimer. 1588d2dd24SPeter Grehan * 2. Redistributions in binary form must reproduce the above copyright 1688d2dd24SPeter Grehan * notice, this list of conditions and the following disclaimer in the 1788d2dd24SPeter Grehan * documentation and/or other materials provided with the distribution. 1888d2dd24SPeter Grehan * 3. All advertising materials mentioning features or use of this software 1988d2dd24SPeter Grehan * must display the following acknowledgement: 2088d2dd24SPeter Grehan * This product includes software developed by the NetBSD 2188d2dd24SPeter Grehan * Foundation, Inc. and its contributors. 2288d2dd24SPeter Grehan * 4. Neither the name of The NetBSD Foundation nor the names of its 2388d2dd24SPeter Grehan * contributors may be used to endorse or promote products derived 2488d2dd24SPeter Grehan * from this software without specific prior written permission. 2588d2dd24SPeter Grehan * 2688d2dd24SPeter Grehan * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 2788d2dd24SPeter Grehan * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 2888d2dd24SPeter Grehan * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 2988d2dd24SPeter Grehan * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 3088d2dd24SPeter Grehan * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 3188d2dd24SPeter Grehan * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 3288d2dd24SPeter Grehan * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 3388d2dd24SPeter Grehan * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 3488d2dd24SPeter Grehan * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 3588d2dd24SPeter Grehan * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 3688d2dd24SPeter Grehan * POSSIBILITY OF SUCH DAMAGE. 3788d2dd24SPeter Grehan * 3888d2dd24SPeter Grehan * $FreeBSD$ 3988d2dd24SPeter Grehan */ 4088d2dd24SPeter Grehan 4188d2dd24SPeter Grehan #include <sys/cdefs.h> 4288d2dd24SPeter Grehan 4388d2dd24SPeter Grehan #include "namespace.h" 4488d2dd24SPeter Grehan 4588d2dd24SPeter Grehan #include <sys/types.h> 4688d2dd24SPeter Grehan #include <ieeefp.h> 4788d2dd24SPeter Grehan 4856ae1bedSRafal Jaworowski #ifndef _SOFT_FLOAT 4988d2dd24SPeter Grehan #ifdef __weak_alias 5088d2dd24SPeter Grehan __weak_alias(fpgetsticky,_fpgetsticky) 5188d2dd24SPeter Grehan #endif 5288d2dd24SPeter Grehan 5388d2dd24SPeter Grehan fp_except_t 5488d2dd24SPeter Grehan fpgetsticky() 5588d2dd24SPeter Grehan { 5688d2dd24SPeter Grehan u_int64_t fpscr; 5788d2dd24SPeter Grehan 5888d2dd24SPeter Grehan __asm__ __volatile("mffs %0" : "=f"(fpscr)); 5988d2dd24SPeter Grehan return ((fp_except_t)((fpscr >> 25) & 0x1f)); 6088d2dd24SPeter Grehan } 6156ae1bedSRafal Jaworowski #endif 62