1 /* $OpenBSD: fenv.h,v 1.1 2011/04/23 22:39:14 martynas Exp $ */ 2 3 /* 4 * Copyright (c) 2011 Martynas Venckus <martynas@openbsd.org> 5 * 6 * Permission to use, copy, modify, and distribute this software for any 7 * purpose with or without fee is hereby granted, provided that the above 8 * copyright notice and this permission notice appear in all copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19 #ifndef _ALPHA_FENV_H_ 20 #define _ALPHA_FENV_H_ 21 22 /* 23 * Each symbol representing a floating point exception expands to an integer 24 * constant expression with values, such that bitwise-inclusive ORs of _all 25 * combinations_ of the constants result in distinct values. 26 * 27 * We use such values that allow direct bitwise operations on FPU registers. 28 */ 29 #define FE_INVALID 0x01 30 #define FE_DIVBYZERO 0x02 31 #define FE_OVERFLOW 0x04 32 #define FE_UNDERFLOW 0x08 33 #define FE_INEXACT 0x10 34 #define FE_INTOVERFLOW 0x20 35 36 /* 37 * The following symbol is simply the bitwise-inclusive OR of all floating-point 38 * exception constants defined above. 39 */ 40 #define FE_ALL_EXCEPT \ 41 (FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW | \ 42 FE_INTOVERFLOW) 43 44 /* 45 * Each symbol representing the rounding direction, expands to an integer 46 * constant expression whose value is distinct non-negative value. 47 * 48 * We use such values that allow direct bitwise operations on FPU registers. 49 */ 50 #define FE_TOWARDZERO 0x0 51 #define FE_DOWNWARD 0x1 52 #define FE_TONEAREST 0x2 53 #define FE_UPWARD 0x3 54 55 /* 56 * The following symbol is simply the bitwise-inclusive OR of all floating-point 57 * rounding direction constants defined above. 58 */ 59 #define _ROUND_MASK \ 60 (FE_TOWARDZERO | FE_DOWNWARD | FE_TONEAREST | FE_UPWARD) 61 #define _ROUND_SHIFT 58 62 63 /* 64 * fenv_t represents the entire floating-point environment 65 */ 66 typedef struct { 67 unsigned short __excepts; 68 unsigned short __mask; 69 unsigned short __round; 70 } fenv_t; 71 72 extern fenv_t __fe_dfl_env; 73 #define FE_DFL_ENV ((const fenv_t *) &__fe_dfl_env) 74 75 /* 76 * fexcept_t represents the floating-point status flags collectively, including 77 * any status the implementation associates with the flags. 78 * 79 * A floating-point status flag is a system variable whose value is set (but 80 * never cleared) when a floating-point exception is raised, which occurs as a 81 * side effect of exceptional floating-point arithmetic to provide auxiliary 82 * information. 83 * 84 * A floating-point control mode is a system variable whose value may be set by 85 * the user to affect the subsequent behavior of floating-point arithmetic. 86 */ 87 typedef unsigned short fexcept_t; 88 89 #endif /* ! _ALPHA_FENV_H_ */ 90