fenv.c (203441) | fenv.c (226218) |
---|---|
1/*- 2 * Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * | 1/*- 2 * Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * |
26 * $FreeBSD: head/lib/msun/amd64/fenv.c 203441 2010-02-03 20:23:47Z kib $ | 26 * $FreeBSD: head/lib/msun/amd64/fenv.c 226218 2011-10-10 15:43:09Z das $ |
27 */ 28 29#include <sys/cdefs.h> 30#include <sys/types.h> 31#include <machine/fpu.h> | 27 */ 28 29#include <sys/cdefs.h> 30#include <sys/types.h> 31#include <machine/fpu.h> |
32 33#define __fenv_static |
|
32#include <fenv.h> 33 | 34#include <fenv.h> 35 |
36#ifdef __GNUC_GNU_INLINE__ 37#error "This file must be compiled with C99 'inline' semantics" 38#endif 39 |
|
34const fenv_t __fe_dfl_env = { 35 { 0xffff0000 | __INITIAL_FPUCW__, 36 0xffff0000, 37 0xffffffff, 38 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 39 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff } 40 }, 41 __INITIAL_MXCSR__ 42}; 43 | 40const fenv_t __fe_dfl_env = { 41 { 0xffff0000 | __INITIAL_FPUCW__, 42 0xffff0000, 43 0xffffffff, 44 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 45 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff } 46 }, 47 __INITIAL_MXCSR__ 48}; 49 |
50extern inline int feclearexcept(int __excepts); 51extern inline int fegetexceptflag(fexcept_t *__flagp, int __excepts); 52 |
|
44int 45fesetexceptflag(const fexcept_t *flagp, int excepts) 46{ 47 fenv_t env; 48 49 __fnstenv(&env.__x87); 50 env.__x87.__status &= ~excepts; 51 env.__x87.__status |= *flagp & excepts; --- 12 unchanged lines hidden (view full) --- 64{ 65 fexcept_t ex = excepts; 66 67 fesetexceptflag(&ex, excepts); 68 __fwait(); 69 return (0); 70} 71 | 53int 54fesetexceptflag(const fexcept_t *flagp, int excepts) 55{ 56 fenv_t env; 57 58 __fnstenv(&env.__x87); 59 env.__x87.__status &= ~excepts; 60 env.__x87.__status |= *flagp & excepts; --- 12 unchanged lines hidden (view full) --- 73{ 74 fexcept_t ex = excepts; 75 76 fesetexceptflag(&ex, excepts); 77 __fwait(); 78 return (0); 79} 80 |
81extern inline int fetestexcept(int __excepts); 82extern inline int fegetround(void); 83extern inline int fesetround(int __round); 84 |
|
72int 73fegetenv(fenv_t *envp) 74{ 75 76 __fnstenv(&envp->__x87); 77 __stmxcsr(&envp->__mxcsr); 78 /* 79 * fnstenv masks all exceptions, so we need to restore the --- 13 unchanged lines hidden (view full) --- 93 __fnclex(); 94 envp->__mxcsr = mxcsr; 95 mxcsr &= ~FE_ALL_EXCEPT; 96 mxcsr |= FE_ALL_EXCEPT << _SSE_EMASK_SHIFT; 97 __ldmxcsr(mxcsr); 98 return (0); 99} 100 | 85int 86fegetenv(fenv_t *envp) 87{ 88 89 __fnstenv(&envp->__x87); 90 __stmxcsr(&envp->__mxcsr); 91 /* 92 * fnstenv masks all exceptions, so we need to restore the --- 13 unchanged lines hidden (view full) --- 106 __fnclex(); 107 envp->__mxcsr = mxcsr; 108 mxcsr &= ~FE_ALL_EXCEPT; 109 mxcsr |= FE_ALL_EXCEPT << _SSE_EMASK_SHIFT; 110 __ldmxcsr(mxcsr); 111 return (0); 112} 113 |
114extern inline int fesetenv(const fenv_t *__envp); 115 |
|
101int 102feupdateenv(const fenv_t *envp) 103{ 104 __uint32_t mxcsr; 105 __uint16_t status; 106 107 __fnstsw(&status); 108 __stmxcsr(&mxcsr); --- 41 unchanged lines hidden --- | 116int 117feupdateenv(const fenv_t *envp) 118{ 119 __uint32_t mxcsr; 120 __uint16_t status; 121 122 __fnstsw(&status); 123 __stmxcsr(&mxcsr); --- 41 unchanged lines hidden --- |