fpgetsticky.c revision 209878
1209878Snwhitehorn/* $NetBSD: fpgetsticky.c,v 1.3 2002/01/13 21:45:48 thorpej Exp $ */ 2209878Snwhitehorn 3209878Snwhitehorn/* 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 * 3. All advertising materials mentioning features or use of this software 19209878Snwhitehorn * must display the following acknowledgement: 20209878Snwhitehorn * This product includes software developed by the NetBSD 21209878Snwhitehorn * Foundation, Inc. and its contributors. 22209878Snwhitehorn * 4. Neither the name of The NetBSD Foundation nor the names of its 23209878Snwhitehorn * contributors may be used to endorse or promote products derived 24209878Snwhitehorn * from this software without specific prior written permission. 25209878Snwhitehorn * 26209878Snwhitehorn * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 27209878Snwhitehorn * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 28209878Snwhitehorn * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 29209878Snwhitehorn * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 30209878Snwhitehorn * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 31209878Snwhitehorn * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 32209878Snwhitehorn * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33209878Snwhitehorn * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 34209878Snwhitehorn * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 35209878Snwhitehorn * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36209878Snwhitehorn * POSSIBILITY OF SUCH DAMAGE. 37209878Snwhitehorn * 38209878Snwhitehorn * $FreeBSD: head/lib/libc/powerpc64/gen/fpgetsticky.c 209878 2010-07-10 14:45:03Z nwhitehorn $ 39209878Snwhitehorn */ 40209878Snwhitehorn 41209878Snwhitehorn#include <sys/cdefs.h> 42209878Snwhitehorn 43209878Snwhitehorn#include "namespace.h" 44209878Snwhitehorn 45209878Snwhitehorn#include <sys/types.h> 46209878Snwhitehorn#include <ieeefp.h> 47209878Snwhitehorn 48209878Snwhitehorn#ifndef _SOFT_FLOAT 49209878Snwhitehorn#ifdef __weak_alias 50209878Snwhitehorn__weak_alias(fpgetsticky,_fpgetsticky) 51209878Snwhitehorn#endif 52209878Snwhitehorn 53209878Snwhitehornfp_except_t 54209878Snwhitehornfpgetsticky() 55209878Snwhitehorn{ 56209878Snwhitehorn u_int64_t fpscr; 57209878Snwhitehorn 58209878Snwhitehorn __asm__ __volatile("mffs %0" : "=f"(fpscr)); 59209878Snwhitehorn return ((fp_except_t)((fpscr >> 25) & 0x1f)); 60209878Snwhitehorn} 61209878Snwhitehorn#endif 62