fpgetsticky.c revision 176530
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 * 3. All advertising materials mentioning features or use of this software 19125733Sgrehan * must display the following acknowledgement: 20125733Sgrehan * This product includes software developed by the NetBSD 21125733Sgrehan * Foundation, Inc. and its contributors. 22125733Sgrehan * 4. Neither the name of The NetBSD Foundation nor the names of its 23125733Sgrehan * contributors may be used to endorse or promote products derived 24125733Sgrehan * from this software without specific prior written permission. 25125733Sgrehan * 26125733Sgrehan * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 27125733Sgrehan * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 28125733Sgrehan * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 29125733Sgrehan * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 30125733Sgrehan * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 31125733Sgrehan * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 32125733Sgrehan * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33125733Sgrehan * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 34125733Sgrehan * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 35125733Sgrehan * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36125733Sgrehan * POSSIBILITY OF SUCH DAMAGE. 37125733Sgrehan * 38125733Sgrehan * $FreeBSD: head/lib/libc/powerpc/gen/fpgetsticky.c 176530 2008-02-24 19:22:53Z raj $ 39125733Sgrehan */ 40125733Sgrehan 41125733Sgrehan#include <sys/cdefs.h> 42125733Sgrehan 43125733Sgrehan#include "namespace.h" 44125733Sgrehan 45125733Sgrehan#include <sys/types.h> 46125733Sgrehan#include <ieeefp.h> 47125733Sgrehan 48176530Sraj#ifndef _SOFT_FLOAT 49125733Sgrehan#ifdef __weak_alias 50125733Sgrehan__weak_alias(fpgetsticky,_fpgetsticky) 51125733Sgrehan#endif 52125733Sgrehan 53125733Sgrehanfp_except_t 54125733Sgrehanfpgetsticky() 55125733Sgrehan{ 56125733Sgrehan u_int64_t fpscr; 57125733Sgrehan 58125733Sgrehan __asm__ __volatile("mffs %0" : "=f"(fpscr)); 59125733Sgrehan return ((fp_except_t)((fpscr >> 25) & 0x1f)); 60125733Sgrehan} 61176530Sraj#endif 62