1130145Sdas/*- 2130145Sdas * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG> 3130145Sdas * All rights reserved. 4130145Sdas * 5130145Sdas * Redistribution and use in source and binary forms, with or without 6130145Sdas * modification, are permitted provided that the following conditions 7130145Sdas * are met: 8130145Sdas * 1. Redistributions of source code must retain the above copyright 9130145Sdas * notice, this list of conditions and the following disclaimer. 10130145Sdas * 2. Redistributions in binary form must reproduce the above copyright 11130145Sdas * notice, this list of conditions and the following disclaimer in the 12130145Sdas * documentation and/or other materials provided with the distribution. 13130145Sdas * 14130145Sdas * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15130145Sdas * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16130145Sdas * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17130145Sdas * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18130145Sdas * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19130145Sdas * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20130145Sdas * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21130145Sdas * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22130145Sdas * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23130145Sdas * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24130145Sdas * SUCH DAMAGE. 25130145Sdas * 26130145Sdas * $FreeBSD: releng/10.3/lib/msun/ia64/fenv.c 226415 2011-10-16 05:37:56Z das $ 27130145Sdas */ 28130145Sdas 29130145Sdas#include <sys/types.h> 30226218Sdas 31226218Sdas#define __fenv_static 32226415Sdas#include "fenv.h" 33130145Sdas 34226218Sdas#ifdef __GNUC_GNU_INLINE__ 35226218Sdas#error "This file must be compiled with C99 'inline' semantics" 36226218Sdas#endif 37226218Sdas 38130145Sdasconst fenv_t __fe_dfl_env = 0x0009804c8a70033fULL; 39130145Sdas 40226218Sdasextern inline int feclearexcept(int __excepts); 41226218Sdasextern inline int fegetexceptflag(fexcept_t *__flagp, int __excepts); 42226218Sdasextern inline int fesetexceptflag(const fexcept_t *__flagp, int __excepts); 43226218Sdasextern inline int feraiseexcept(int __excepts); 44226218Sdasextern inline int fetestexcept(int __excepts); 45226218Sdasextern inline int fegetround(void); 46226218Sdasextern inline int fesetround(int __round); 47226218Sdasextern inline int fegetenv(fenv_t *__envp); 48226218Sdasextern inline int feholdexcept(fenv_t *__envp); 49226218Sdasextern inline int fesetenv(const fenv_t *__envp); 50226218Sdas 51130145Sdas/* 52130145Sdas * It doesn't pay to inline feupdateenv() because it includes one of 53130145Sdas * the rare uses of feraiseexcept() where the argument is not a 54130145Sdas * constant. Thus, no dead code elimination can occur, resulting in 55130145Sdas * significant bloat. 56130145Sdas */ 57130145Sdasint 58130145Sdasfeupdateenv(const fenv_t *envp) 59130145Sdas{ 60130145Sdas fenv_t fpsr; 61130145Sdas 62130145Sdas __stfpsr(&fpsr); 63130145Sdas __ldfpsr(*envp); 64130329Sdas feraiseexcept((fpsr >> _FPUSW_SHIFT) & FE_ALL_EXCEPT); 65130145Sdas return (0); 66130145Sdas} 67