fenv.h revision 1.2
11.2Smartin/* $NetBSD: fenv.h,v 1.2 2017/01/14 12:00:13 martin Exp $ */ 21.1Snakayama 31.1Snakayama/*- 41.1Snakayama * Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG> 51.1Snakayama * All rights reserved. 61.1Snakayama * 71.1Snakayama * Redistribution and use in source and binary forms, with or without 81.1Snakayama * modification, are permitted provided that the following conditions 91.1Snakayama * are met: 101.1Snakayama * 1. Redistributions of source code must retain the above copyright 111.1Snakayama * notice, this list of conditions and the following disclaimer. 121.1Snakayama * 2. Redistributions in binary form must reproduce the above copyright 131.1Snakayama * notice, this list of conditions and the following disclaimer in the 141.1Snakayama * documentation and/or other materials provided with the distribution. 151.1Snakayama * 161.1Snakayama * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 171.1Snakayama * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 181.1Snakayama * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 191.1Snakayama * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 201.1Snakayama * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 211.1Snakayama * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 221.1Snakayama * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 231.1Snakayama * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 241.1Snakayama * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 251.1Snakayama * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 261.1Snakayama * SUCH DAMAGE. 271.1Snakayama * 281.1Snakayama * $FreeBSD$ 291.1Snakayama */ 301.1Snakayama 311.1Snakayama#ifndef _SPARC_FENV_H_ 321.1Snakayama#define _SPARC_FENV_H_ 331.1Snakayama 341.1Snakayama#include <sys/stdint.h> 351.1Snakayama 361.1Snakayama#ifdef __arch64__ 371.1Snakayamatypedef uint64_t fenv_t; 381.1Snakayamatypedef uint64_t fexcept_t; 391.1Snakayama#else 401.1Snakayamatypedef uint32_t fenv_t; 411.1Snakayamatypedef uint32_t fexcept_t; 421.1Snakayama#endif 431.1Snakayama 441.1Snakayama/* 451.1Snakayama * Exception flags 461.1Snakayama * 471.1Snakayama * Symbols are defined in such a way, to correspond to the accrued 481.1Snakayama * exception bits (aexc) fields of FSR. 491.1Snakayama */ 501.1Snakayama#define FE_INEXACT 0x00000020 /* 0000100000 */ 511.1Snakayama#define FE_DIVBYZERO 0x00000040 /* 0001000000 */ 521.1Snakayama#define FE_UNDERFLOW 0x00000080 /* 0010000000 */ 531.1Snakayama#define FE_OVERFLOW 0x00000100 /* 0100000000 */ 541.1Snakayama#define FE_INVALID 0x00000200 /* 1000000000 */ 551.1Snakayama 561.1Snakayama#define FE_ALL_EXCEPT (FE_DIVBYZERO | FE_INEXACT | \ 571.1Snakayama FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW) 581.1Snakayama 591.1Snakayama/* 601.1Snakayama * Rounding modes 611.1Snakayama * 621.1Snakayama * We can't just use the hardware bit values here, because that would 631.1Snakayama * make FE_UPWARD and FE_DOWNWARD negative, which is not allowed. 641.1Snakayama */ 651.2Smartin#define FE_TONEAREST 0 /* round to nearest representable number */ 661.2Smartin#define FE_TOWARDZERO 1 /* round to zero (truncate) */ 671.2Smartin#define FE_UPWARD 2 /* round toward positive infinity */ 681.2Smartin#define FE_DOWNWARD 3 /* round toward negative infinity */ 691.1Snakayama#define _ROUND_MASK (FE_TONEAREST | FE_DOWNWARD | \ 701.1Snakayama FE_UPWARD | FE_TOWARDZERO) 711.1Snakayama#define _ROUND_SHIFT 30 721.1Snakayama 731.1Snakayama__BEGIN_DECLS 741.1Snakayama 751.1Snakayama/* Default floating-point environment */ 761.1Snakayamaextern const fenv_t __fe_dfl_env; 771.1Snakayama#define FE_DFL_ENV (&__fe_dfl_env) 781.1Snakayama 791.1Snakayama/* We need to be able to map status flag positions to mask flag positions */ 801.1Snakayama#define _FPUSW_SHIFT 18 811.1Snakayama#define _ENABLE_MASK (FE_ALL_EXCEPT << _FPUSW_SHIFT) 821.1Snakayama 831.1Snakayama__END_DECLS 841.1Snakayama 851.1Snakayama#endif /* !_SPARC_FENV_H_ */ 86