| 1 | /*	$OpenBSD: fenv.h,v 1.4 2011/05/25 21:46:49 martynas Exp $	*/ |
| 2 | /*	$NetBSD: fenv.h,v 1.1.2.2 2011/02/08 16:19:41 bouyer Exp $	*/ |
| 3 | |
| 4 | /*- |
| 5 | * Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG> |
| 6 | * All rights reserved. |
| 7 | * |
| 8 | * Redistribution and use in source and binary forms, with or without |
| 9 | * modification, are permitted provided that the following conditions |
| 10 | * are met: |
| 11 | * 1. Redistributions of source code must retain the above copyright |
| 12 | * notice, this list of conditions and the following disclaimer. |
| 13 | * 2. Redistributions in binary form must reproduce the above copyright |
| 14 | * notice, this list of conditions and the following disclaimer in the |
| 15 | * documentation and/or other materials provided with the distribution. |
| 16 | * |
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
| 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
| 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 27 | * SUCH DAMAGE. |
| 28 | * |
| 29 | * $FreeBSD$ |
| 30 | */ |
| 31 | |
| 32 | #ifndef	_SPARC64_FENV_H_ |
| 33 | #define	_SPARC64_FENV_H_ |
| 34 | |
| 35 | /* |
| 36 | * Each symbol representing a floating point exception expands to an integer |
| 37 | * constant expression with values, such that bitwise-inclusive ORs of _all |
| 38 | * combinations_ of the constants result in distinct values. |
| 39 | * |
| 40 | * We use such values that allow direct bitwise operations on FPU registers. |
| 41 | */ |
| 42 | #define	FE_INEXACT		0x020 |
| 43 | #define	FE_DIVBYZERO		0x040 |
| 44 | #define	FE_UNDERFLOW		0x080 |
| 45 | #define	FE_OVERFLOW		0x100 |
| 46 | #define	FE_INVALID		0x200 |
| 47 | |
| 48 | /* |
| 49 | * The following symbol is simply the bitwise-inclusive OR of all floating-point |
| 50 | * exception constants defined above. |
| 51 | */ |
| 52 | #define	FE_ALL_EXCEPT		(FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | \ |
| 53 | 				 FE_OVERFLOW | FE_INVALID) |
| 54 | #define	_MASK_SHIFT		18 |
| 55 | |
| 56 | /* |
| 57 | * Each symbol representing the rounding direction, expands to an integer |
| 58 | * constant expression whose value is distinct non-negative value. |
| 59 | * |
| 60 | * We use such values that allow direct bitwise operations on FPU registers. |
| 61 | */ |
| 62 | #define	FE_TONEAREST		0x0 |
| 63 | #define	FE_TOWARDZERO		0x1 |
| 64 | #define	FE_UPWARD		0x2 |
| 65 | #define	FE_DOWNWARD		0x3 |
| 66 | |
| 67 | /* |
| 68 | * The following symbol is simply the bitwise-inclusive OR of all floating-point |
| 69 | * rounding direction constants defined above. |
| 70 | */ |
| 71 | #define	_ROUND_MASK		(FE_TONEAREST | FE_TOWARDZERO | FE_UPWARD | \ |
| 72 | 				 FE_DOWNWARD) |
| 73 | #define	_ROUND_SHIFT		30 |
| 74 | |
| 75 | /* |
| 76 | * fenv_t represents the entire floating-point environment. |
| 77 | */ |
| 78 | typedef	unsigned long		fenv_t; |
| 79 | |
| 80 | /* |
| 81 | * The following constant represents the default floating-point environment |
| 82 | * (that is, the one installed at program startup) and has type pointer to |
| 83 | * const-qualified fenv_t. |
| 84 | * |
| 85 | * It can be used as an argument to the functions within the <fenv.h> header |
| 86 | * that manage the floating-point environment, namely fesetenv() and |
| 87 | * feupdateenv(). |
| 88 | */ |
| 89 | __BEGIN_DECLS |
| 90 | extern	fenv_t			__fe_dfl_env; |
| 91 | __END_DECLS |
| 92 | #define	FE_DFL_ENV		((const fenv_t *)&__fe_dfl_env) |
| 93 | |
| 94 | /* |
| 95 | * fexcept_t represents the floating-point status flags collectively, including |
| 96 | * any status the implementation associates with the flags. |
| 97 | * |
| 98 | * A floating-point status flag is a system variable whose value is set (but |
| 99 | * never cleared) when a floating-point exception is raised, which occurs as a |
| 100 | * side effect of exceptional floating-point arithmetic to provide auxiliary |
| 101 | * information. |
| 102 | * |
| 103 | * A floating-point control mode is a system variable whose value may be set by |
| 104 | * the user to affect the subsequent behavior of floating-point arithmetic. |
| 105 | */ |
| 106 | typedef	unsigned long		fexcept_t; |
| 107 | |
| 108 | #endif	/* !_SPARC64_FENV_H_ */ |