1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258
|
/****************************************************************
Copyright (C) 1999-2001 Lucent Technologies
All Rights Reserved
Permission to use, copy, modify, and distribute this software and
its documentation for any purpose and without fee is hereby
granted, provided that the above copyright notice appear in all
copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of Lucent or any of its entities
not be used in advertising or publicity pertaining to
distribution of the software without specific, written prior
permission.
LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
****************************************************************/
#undef ASL_USE_FPINITMT
#ifdef __powerpc__
#undef ASL_NO_FPINITMT
#define ASL_NO_FPINITMT
#endif
#ifndef ASL_NO_FPINITMT
#ifdef _WIN32
#define ASL_USE_FPINITMT
#endif /*_WIN32*/
#endif /*ASL_NO_FPINITMT*/
#ifdef ASL_USE_FPINITMT
#include "fpinitmt.c"
#else
int isatty_ASL; /* for use with "sw" under NT */
#ifndef MSpc
#ifdef MSDOS
#define MSpc
#else
#ifdef _WIN32
#undef WIN32
#define WIN32
#else
#define _GNU_SOURCE /* needed for fedisableexcept */
#include "fenv.h"
#endif
#ifdef WIN32
#define MSpc
#endif
#endif /*MSDOS*/
#endif /*MSpc*/
#ifdef KR_headers
#define Void /*void*/
#else
#define Void void
#endif
#ifdef __cplusplus
extern "C" {
void fpinit_ASL(Void);
}
#endif
#undef FP_INIT_DONE
#ifdef __APPLE__
#if (defined (__i386__) || defined( __x86_64__ ))
#define _FPU_EXTENDED 0x300
#define _FPU_DOUBLE 0x200
#define _FPU_IEEE 0x37f
#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
void
fpinit_ASL(Void)
{
unsigned int __fpu_control;
#ifdef ASL_FPINIT_KEEP_TRAPBITS
_FPU_GETCW(__fpu_control);
__fpu_control &= ~_FPU_EXTENDED; /* clear rounding precision bits */
__fpu_control |= _FPU_DOUBLE; /* set the ones we want set */
#else
__fpu_control = _FPU_IEEE - _FPU_EXTENDED + _FPU_DOUBLE;
#endif
_FPU_SETCW(__fpu_control);
}
#define ASL_NO_FP_INIT
#define FP_INIT_DONE
#endif /* __i386 */
#endif /*APPLE*/
#ifdef __ARM_ARCH
#define ASL_NO_FP_INIT
#endif
#ifndef ASL_NO_FP_INIT
#ifdef __GLIBC__ /*{*/
#ifndef NO_fpu_control /*{*/
#define FP_INIT_DONE
#include "fpu_control.h"
#ifdef __alpha__ /*{*/
#ifndef USE_setfpucw
#define __setfpucw(x) __fpu_control = (x)
#endif
#endif /*}*/
#ifndef _FPU_SETCW
#undef Can_use__setfpucw
#define Can_use__setfpucw
#endif
void
fpinit_ASL(Void)
{
#ifdef Can_use__setfpucw /* Has __setfpucw gone missing from S.u.S.E. 6.3? */
#ifdef _FPU_EXTENDED /* not defined on Itanium systems running ALTIX */
__setfpucw(_FPU_IEEE - _FPU_EXTENDED + _FPU_DOUBLE);
#endif
#else
#ifdef ASL_FPINIT_KEEP_TRAPBITS
_FPU_GETCW(__fpu_control);
__fpu_control &= ~_FPU_EXTENDED; /* clear rounding precision bits */
__fpu_control |= _FPU_DOUBLE; /* set the ones we want set */
_FPU_SETCW(__fpu_control);
#else
#if defined(_FPU_IEEE) && defined(_FPU_EXTENDED) && defined(_FPU_DOUBLE)
__fpu_control = _FPU_IEEE - _FPU_EXTENDED + _FPU_DOUBLE;
_FPU_SETCW(__fpu_control);
#elif defined(__i386__) || defined(__x86_64__)
__fpu_control = 0x27f;
_FPU_SETCW(__fpu_control);
#elif defined(FE_ALL_EXCEPT)
fedisableexcept(FE_ALL_EXCEPT);
#else
!!!! How does this system work?
!!!! Either figure it out (and modify this text),
!!!! or compile fpinit.c with -DNO_fpu_control .
#endif
#endif /* ASL_FPINIT_KEEP_TRAPBITS */
#endif
}
#endif /*} NO_fpu_control */
#endif /*} __GLIBC__ */
#ifdef sgi /*{*/
#ifndef _ABIO32
#define FP_INIT_DONE
#include <sys/fpu.h>
void
fpinit_ASL(Void)
{
union fpc_csr f;
f.fc_word = get_fpc_csr();
f.fc_struct.flush = 0;
set_fpc_csr(f.fc_word);
}
#endif
#endif /*}sgi*/
#ifdef MSpc /*{*/
#ifndef No_Control87 /*{*/
#include "float.h"
#ifdef SYMANTEC
extern int _8087;
#endif
#ifndef MCW_EM
#ifndef _MCW_EM /* for cygwin with -mno-cygwin */
#define _MCW_EM 0x0008001F
#endif
#define MCW_EM _MCW_EM
#endif
#ifndef PC_53
#ifndef _PC_53
#define _PC_53 0x00010000
#endif
#define PC_53 _PC_53
#endif
#ifndef MCW_PC
#ifndef _MCW_PC
#define _MCW_PC 0x00030000
#endif
#define MCW_PC _MCW_PC
#endif
#define FP_INIT_DONE
void
fpinit_ASL(Void)
{
#ifdef SYMANTEC
if (_8087)
#endif
_control87(MCW_EM | PC_53, MCW_EM | MCW_PC);
}
#endif /*}No_Control87*/
#endif /*}MSpc*/
#ifdef __sun /*{*/
#if defined(__i386) || defined(__x86_64) /*{*/
#ifdef __cplusplus
#define externC extern "C"
#else
#define externC extern
#endif
#define PC_24 0
#define PC_53 0x200
#define PC_64 0x300
#define FP_INIT_DONE
void
fpinit_ASL(Void)
{
#ifdef USE_EXTERNAL_fpsetprec
externC int fpsetprec(int);
fpsetprec(PC_53);
#else
unsigned int x;
__asm__ __volatile__ ("fnstcw %0" : "=m" (x));
x &= ~PC_64;
x |= PC_53;
__asm__ __volatile__ ("fldcw %0" : : "m" (x));
#endif
}
#endif
#endif /*} __i386 __sun */
/* Currently, FP_PD is the default on FreeBSD, but enabled traps */
/* can cause surprises, so we restore the default IEEE mask. */
#ifdef __FreeBSD__
#include "floatingpoint.h"
#define FP_INIT_DONE
void
fpinit_ASL(Void)
{
fpsetprec(FP_PD);
fpsetmask(0);
}
#endif /* __FreeBSD__ */
#endif /* ASL_NO_FP_INIT */
#ifndef FP_INIT_DONE
void fpinit_ASL(Void) {}
#endif
#endif /*ASL_USE_FPINITMT*/
|