1*2094e357Smartin /* $NetBSD: fenv.h,v 1.2 2017/01/14 12:00:13 martin Exp $ */ 26c6496b6Snakayama 36c6496b6Snakayama /*- 46c6496b6Snakayama * Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG> 56c6496b6Snakayama * All rights reserved. 66c6496b6Snakayama * 76c6496b6Snakayama * Redistribution and use in source and binary forms, with or without 86c6496b6Snakayama * modification, are permitted provided that the following conditions 96c6496b6Snakayama * are met: 106c6496b6Snakayama * 1. Redistributions of source code must retain the above copyright 116c6496b6Snakayama * notice, this list of conditions and the following disclaimer. 126c6496b6Snakayama * 2. Redistributions in binary form must reproduce the above copyright 136c6496b6Snakayama * notice, this list of conditions and the following disclaimer in the 146c6496b6Snakayama * documentation and/or other materials provided with the distribution. 156c6496b6Snakayama * 166c6496b6Snakayama * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 176c6496b6Snakayama * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 186c6496b6Snakayama * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 196c6496b6Snakayama * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 206c6496b6Snakayama * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 216c6496b6Snakayama * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 226c6496b6Snakayama * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 236c6496b6Snakayama * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 246c6496b6Snakayama * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 256c6496b6Snakayama * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 266c6496b6Snakayama * SUCH DAMAGE. 276c6496b6Snakayama * 286c6496b6Snakayama * $FreeBSD$ 296c6496b6Snakayama */ 306c6496b6Snakayama 316c6496b6Snakayama #ifndef _SPARC_FENV_H_ 326c6496b6Snakayama #define _SPARC_FENV_H_ 336c6496b6Snakayama 346c6496b6Snakayama #include <sys/stdint.h> 356c6496b6Snakayama 366c6496b6Snakayama #ifdef __arch64__ 376c6496b6Snakayama typedef uint64_t fenv_t; 386c6496b6Snakayama typedef uint64_t fexcept_t; 396c6496b6Snakayama #else 406c6496b6Snakayama typedef uint32_t fenv_t; 416c6496b6Snakayama typedef uint32_t fexcept_t; 426c6496b6Snakayama #endif 436c6496b6Snakayama 446c6496b6Snakayama /* 456c6496b6Snakayama * Exception flags 466c6496b6Snakayama * 476c6496b6Snakayama * Symbols are defined in such a way, to correspond to the accrued 486c6496b6Snakayama * exception bits (aexc) fields of FSR. 496c6496b6Snakayama */ 506c6496b6Snakayama #define FE_INEXACT 0x00000020 /* 0000100000 */ 516c6496b6Snakayama #define FE_DIVBYZERO 0x00000040 /* 0001000000 */ 526c6496b6Snakayama #define FE_UNDERFLOW 0x00000080 /* 0010000000 */ 536c6496b6Snakayama #define FE_OVERFLOW 0x00000100 /* 0100000000 */ 546c6496b6Snakayama #define FE_INVALID 0x00000200 /* 1000000000 */ 556c6496b6Snakayama 566c6496b6Snakayama #define FE_ALL_EXCEPT (FE_DIVBYZERO | FE_INEXACT | \ 576c6496b6Snakayama FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW) 586c6496b6Snakayama 596c6496b6Snakayama /* 606c6496b6Snakayama * Rounding modes 616c6496b6Snakayama * 626c6496b6Snakayama * We can't just use the hardware bit values here, because that would 636c6496b6Snakayama * make FE_UPWARD and FE_DOWNWARD negative, which is not allowed. 646c6496b6Snakayama */ 65*2094e357Smartin #define FE_TONEAREST 0 /* round to nearest representable number */ 66*2094e357Smartin #define FE_TOWARDZERO 1 /* round to zero (truncate) */ 67*2094e357Smartin #define FE_UPWARD 2 /* round toward positive infinity */ 68*2094e357Smartin #define FE_DOWNWARD 3 /* round toward negative infinity */ 696c6496b6Snakayama #define _ROUND_MASK (FE_TONEAREST | FE_DOWNWARD | \ 706c6496b6Snakayama FE_UPWARD | FE_TOWARDZERO) 716c6496b6Snakayama #define _ROUND_SHIFT 30 726c6496b6Snakayama 736c6496b6Snakayama __BEGIN_DECLS 746c6496b6Snakayama 756c6496b6Snakayama /* Default floating-point environment */ 766c6496b6Snakayama extern const fenv_t __fe_dfl_env; 776c6496b6Snakayama #define FE_DFL_ENV (&__fe_dfl_env) 786c6496b6Snakayama 796c6496b6Snakayama /* We need to be able to map status flag positions to mask flag positions */ 806c6496b6Snakayama #define _FPUSW_SHIFT 18 816c6496b6Snakayama #define _ENABLE_MASK (FE_ALL_EXCEPT << _FPUSW_SHIFT) 826c6496b6Snakayama 836c6496b6Snakayama __END_DECLS 846c6496b6Snakayama 856c6496b6Snakayama #endif /* !_SPARC_FENV_H_ */ 86