1 1.26 christos /* $NetBSD: fenv.h,v 1.26 2017/04/09 15:29:07 christos Exp $ */ 2 1.1 joerg /* 3 1.1 joerg * Copyright (c) 2010 The NetBSD Foundation, Inc. 4 1.1 joerg * All rights reserved. 5 1.1 joerg * 6 1.1 joerg * Redistribution and use in source and binary forms, with or without 7 1.1 joerg * modification, are permitted provided that the following conditions 8 1.1 joerg * are met: 9 1.1 joerg * 1. Redistributions of source code must retain the above copyright 10 1.1 joerg * notice, this list of conditions and the following disclaimer. 11 1.1 joerg * 2. Redistributions in binary form must reproduce the above copyright 12 1.1 joerg * notice, this list of conditions and the following disclaimer in the 13 1.1 joerg * documentation and/or other materials provided with the distribution. 14 1.1 joerg * 15 1.1 joerg * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 16 1.1 joerg * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 17 1.1 joerg * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18 1.1 joerg * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 19 1.1 joerg * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 1.1 joerg * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 1.1 joerg * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 1.1 joerg * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 1.1 joerg * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 1.1 joerg * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 1.1 joerg * POSSIBILITY OF SUCH DAMAGE. 26 1.1 joerg */ 27 1.17 christos #ifndef _FENV_H_ 28 1.17 christos #define _FENV_H_ 29 1.17 christos 30 1.17 christos #include <sys/featuretest.h> 31 1.1 joerg 32 1.25 chs #if defined(__vax__) 33 1.17 christos # ifndef __TEST_FENV 34 1.17 christos # error "fenv.h is currently not supported for this architecture" 35 1.17 christos # endif 36 1.18 christos typedef int fexcept_t; 37 1.18 christos typedef int fenv_t; 38 1.16 christos #else 39 1.16 christos # define __HAVE_FENV 40 1.17 christos # include <machine/fenv.h> 41 1.16 christos #endif 42 1.1 joerg 43 1.25 chs #if \ 44 1.25 chs (defined(__arm__) && defined(__SOFTFP__)) || \ 45 1.25 chs (defined(__m68k__) && !defined(__HAVE_68881__)) || \ 46 1.25 chs defined(__mips_soft_float) || \ 47 1.25 chs (defined(__powerpc__) && defined(_SOFT_FLOAT)) || \ 48 1.25 chs (defined(__sh__) && !defined(__SH_FPU_ANY__)) || \ 49 1.25 chs 0 50 1.25 chs 51 1.25 chs /* 52 1.25 chs * Common definitions for softfloat. 53 1.25 chs */ 54 1.25 chs 55 1.26 christos #ifndef __HAVE_FENV_SOFTFLOAT_DEFS 56 1.26 christos 57 1.25 chs typedef int fexcept_t; 58 1.25 chs 59 1.25 chs typedef struct { 60 1.25 chs int __flags; 61 1.25 chs int __mask; 62 1.25 chs int __round; 63 1.25 chs } fenv_t; 64 1.25 chs 65 1.25 chs #define __FENV_GET_FLAGS(__envp) (__envp)->__flags 66 1.25 chs #define __FENV_GET_MASK(__envp) (__envp)->__mask 67 1.25 chs #define __FENV_GET_ROUND(__envp) (__envp)->__round 68 1.25 chs #define __FENV_SET_FLAGS(__envp, __val) \ 69 1.25 chs (__envp)->__flags = (__val) 70 1.25 chs #define __FENV_SET_MASK(__envp, __val) \ 71 1.25 chs (__envp)->__mask = (__val) 72 1.25 chs #define __FENV_SET_ROUND(__envp, __val) \ 73 1.25 chs (__envp)->__round = (__val) 74 1.25 chs 75 1.25 chs #endif /* __FENV_GET_FLAGS */ 76 1.25 chs 77 1.25 chs #endif /* softfloat */ 78 1.25 chs 79 1.1 joerg __BEGIN_DECLS 80 1.1 joerg 81 1.1 joerg /* Function prototypes */ 82 1.1 joerg int feclearexcept(int); 83 1.1 joerg int fegetexceptflag(fexcept_t *, int); 84 1.1 joerg int feraiseexcept(int); 85 1.1 joerg int fesetexceptflag(const fexcept_t *, int); 86 1.1 joerg int fetestexcept(int); 87 1.1 joerg int fegetround(void); 88 1.1 joerg int fesetround(int); 89 1.1 joerg int fegetenv(fenv_t *); 90 1.1 joerg int feholdexcept(fenv_t *); 91 1.1 joerg int fesetenv(const fenv_t *); 92 1.1 joerg int feupdateenv(const fenv_t *); 93 1.1 joerg 94 1.2 joerg #if defined(_NETBSD_SOURCE) || defined(_GNU_SOURCE) 95 1.1 joerg 96 1.18 christos int feenableexcept(int); 97 1.18 christos int fedisableexcept(int); 98 1.1 joerg int fegetexcept(void); 99 1.1 joerg 100 1.7 dholland #endif /* _NETBSD_SOURCE || _GNU_SOURCE */ 101 1.1 joerg 102 1.1 joerg __END_DECLS 103 1.1 joerg 104 1.1 joerg #endif /* ! _FENV_H_ */ 105