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