1*8d67ca89SAndroid Build Coastguard Worker /*- 2*8d67ca89SAndroid Build Coastguard Worker * Copyright (c) 2004-2005 David Schultz <das (at) FreeBSD.ORG> 3*8d67ca89SAndroid Build Coastguard Worker * All rights reserved. 4*8d67ca89SAndroid Build Coastguard Worker * 5*8d67ca89SAndroid Build Coastguard Worker * Redistribution and use in source and binary forms, with or without 6*8d67ca89SAndroid Build Coastguard Worker * modification, are permitted provided that the following conditions 7*8d67ca89SAndroid Build Coastguard Worker * are met: 8*8d67ca89SAndroid Build Coastguard Worker * 1. Redistributions of source code must retain the above copyright 9*8d67ca89SAndroid Build Coastguard Worker * notice, this list of conditions and the following disclaimer. 10*8d67ca89SAndroid Build Coastguard Worker * 2. Redistributions in binary form must reproduce the above copyright 11*8d67ca89SAndroid Build Coastguard Worker * notice, this list of conditions and the following disclaimer in the 12*8d67ca89SAndroid Build Coastguard Worker * documentation and/or other materials provided with the distribution. 13*8d67ca89SAndroid Build Coastguard Worker * 14*8d67ca89SAndroid Build Coastguard Worker * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15*8d67ca89SAndroid Build Coastguard Worker * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16*8d67ca89SAndroid Build Coastguard Worker * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17*8d67ca89SAndroid Build Coastguard Worker * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18*8d67ca89SAndroid Build Coastguard Worker * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19*8d67ca89SAndroid Build Coastguard Worker * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20*8d67ca89SAndroid Build Coastguard Worker * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21*8d67ca89SAndroid Build Coastguard Worker * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22*8d67ca89SAndroid Build Coastguard Worker * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23*8d67ca89SAndroid Build Coastguard Worker * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24*8d67ca89SAndroid Build Coastguard Worker * SUCH DAMAGE. 25*8d67ca89SAndroid Build Coastguard Worker */ 26*8d67ca89SAndroid Build Coastguard Worker 27*8d67ca89SAndroid Build Coastguard Worker #pragma once 28*8d67ca89SAndroid Build Coastguard Worker 29*8d67ca89SAndroid Build Coastguard Worker #include <sys/types.h> 30*8d67ca89SAndroid Build Coastguard Worker 31*8d67ca89SAndroid Build Coastguard Worker __BEGIN_DECLS 32*8d67ca89SAndroid Build Coastguard Worker 33*8d67ca89SAndroid Build Coastguard Worker /* 34*8d67ca89SAndroid Build Coastguard Worker * Each symbol representing a floating point exception expands to an integer 35*8d67ca89SAndroid Build Coastguard Worker * constant expression with values, such that bitwise-inclusive ORs of _all 36*8d67ca89SAndroid Build Coastguard Worker * combinations_ of the constants result in distinct values. 37*8d67ca89SAndroid Build Coastguard Worker * 38*8d67ca89SAndroid Build Coastguard Worker * We use such values that allow direct bitwise operations on FPU/SSE registers. 39*8d67ca89SAndroid Build Coastguard Worker */ 40*8d67ca89SAndroid Build Coastguard Worker #define FE_INVALID 0x01 41*8d67ca89SAndroid Build Coastguard Worker #define FE_DENORMAL 0x02 42*8d67ca89SAndroid Build Coastguard Worker #define FE_DIVBYZERO 0x04 43*8d67ca89SAndroid Build Coastguard Worker #define FE_OVERFLOW 0x08 44*8d67ca89SAndroid Build Coastguard Worker #define FE_UNDERFLOW 0x10 45*8d67ca89SAndroid Build Coastguard Worker #define FE_INEXACT 0x20 46*8d67ca89SAndroid Build Coastguard Worker 47*8d67ca89SAndroid Build Coastguard Worker /* 48*8d67ca89SAndroid Build Coastguard Worker * The following symbol is simply the bitwise-inclusive OR of all floating-point 49*8d67ca89SAndroid Build Coastguard Worker * exception constants defined above. 50*8d67ca89SAndroid Build Coastguard Worker */ 51*8d67ca89SAndroid Build Coastguard Worker #define FE_ALL_EXCEPT (FE_INVALID | FE_DENORMAL | FE_DIVBYZERO | \ 52*8d67ca89SAndroid Build Coastguard Worker FE_OVERFLOW | FE_UNDERFLOW | FE_INEXACT) 53*8d67ca89SAndroid Build Coastguard Worker 54*8d67ca89SAndroid Build Coastguard Worker /* 55*8d67ca89SAndroid Build Coastguard Worker * Each symbol representing the rounding direction, expands to an integer 56*8d67ca89SAndroid Build Coastguard Worker * constant expression whose value is distinct non-negative value. 57*8d67ca89SAndroid Build Coastguard Worker * 58*8d67ca89SAndroid Build Coastguard Worker * We use such values that allow direct bitwise operations on FPU/SSE registers. 59*8d67ca89SAndroid Build Coastguard Worker */ 60*8d67ca89SAndroid Build Coastguard Worker #define FE_TONEAREST 0x000 61*8d67ca89SAndroid Build Coastguard Worker #define FE_DOWNWARD 0x400 62*8d67ca89SAndroid Build Coastguard Worker #define FE_UPWARD 0x800 63*8d67ca89SAndroid Build Coastguard Worker #define FE_TOWARDZERO 0xc00 64*8d67ca89SAndroid Build Coastguard Worker 65*8d67ca89SAndroid Build Coastguard Worker /* 66*8d67ca89SAndroid Build Coastguard Worker * fenv_t represents the entire floating-point environment. 67*8d67ca89SAndroid Build Coastguard Worker */ 68*8d67ca89SAndroid Build Coastguard Worker typedef struct { 69*8d67ca89SAndroid Build Coastguard Worker struct { 70*8d67ca89SAndroid Build Coastguard Worker __uint32_t __control; /* Control word register */ 71*8d67ca89SAndroid Build Coastguard Worker __uint32_t __status; /* Status word register */ 72*8d67ca89SAndroid Build Coastguard Worker __uint32_t __tag; /* Tag word register */ 73*8d67ca89SAndroid Build Coastguard Worker __uint32_t __others[4]; /* EIP, Pointer Selector, etc */ 74*8d67ca89SAndroid Build Coastguard Worker } __x87; 75*8d67ca89SAndroid Build Coastguard Worker __uint32_t __mxcsr; /* Control, status register */ 76*8d67ca89SAndroid Build Coastguard Worker } fenv_t; 77*8d67ca89SAndroid Build Coastguard Worker 78*8d67ca89SAndroid Build Coastguard Worker /* 79*8d67ca89SAndroid Build Coastguard Worker * fexcept_t represents the floating-point status flags collectively, including 80*8d67ca89SAndroid Build Coastguard Worker * any status the implementation associates with the flags. 81*8d67ca89SAndroid Build Coastguard Worker * 82*8d67ca89SAndroid Build Coastguard Worker * A floating-point status flag is a system variable whose value is set (but 83*8d67ca89SAndroid Build Coastguard Worker * never cleared) when a floating-point exception is raised, which occurs as a 84*8d67ca89SAndroid Build Coastguard Worker * side effect of exceptional floating-point arithmetic to provide auxiliary 85*8d67ca89SAndroid Build Coastguard Worker * information. 86*8d67ca89SAndroid Build Coastguard Worker * 87*8d67ca89SAndroid Build Coastguard Worker * A floating-point control mode is a system variable whose value may be set by 88*8d67ca89SAndroid Build Coastguard Worker * the user to affect the subsequent behavior of floating-point arithmetic. 89*8d67ca89SAndroid Build Coastguard Worker */ 90*8d67ca89SAndroid Build Coastguard Worker typedef __uint32_t fexcept_t; 91*8d67ca89SAndroid Build Coastguard Worker 92*8d67ca89SAndroid Build Coastguard Worker __END_DECLS 93