DOSBox-X
|
00001 /* FPU control word bits. x86-64 version. 00002 Copyright (C) 1993,1995,1996,1997,1998,2000,2001,2002 Free Software Foundation, Inc. 00003 This file is part of the GNU C Library. 00004 Contributed by Olaf Flebbe. 00005 00006 The GNU C Library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Lesser General Public 00008 License as published by the Free Software Foundation; either 00009 version 2.1 of the License, or (at your option) any later version. 00010 00011 The GNU C Library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Lesser General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License along 00017 with this program; if not, write to the Free Software Foundation, Inc., 00018 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 00020 #ifndef _FPU_CONTROL_H 00021 #define _FPU_CONTROL_H 1 00022 00023 /* Note that this file sets on x86-64 only the x87 FPU, it does not 00024 touch the SSE unit. */ 00025 00026 /* Here is the dirty part. Set up your 387 through the control word 00027 * (cw) register. 00028 * 00029 * 15-13 12 11-10 9-8 7-6 5 4 3 2 1 0 00030 * | reserved | IC | RC | PC | reserved | PM | UM | OM | ZM | DM | IM 00031 * 00032 * IM: Invalid operation mask 00033 * DM: Denormalized operand mask 00034 * ZM: Zero-divide mask 00035 * OM: Overflow mask 00036 * UM: Underflow mask 00037 * PM: Precision (inexact result) mask 00038 * 00039 * Mask bit is 1 means no interrupt. 00040 * 00041 * PC: Precision control 00042 * 11 - round to extended precision 00043 * 10 - round to double precision 00044 * 00 - round to single precision 00045 * 00046 * RC: Rounding control 00047 * 00 - rounding to nearest 00048 * 01 - rounding down (toward - infinity) 00049 * 10 - rounding up (toward + infinity) 00050 * 11 - rounding toward zero 00051 * 00052 * IC: Infinity control 00053 * That is for 8087 and 80287 only. 00054 * 00055 * The hardware default is 0x037f which we use. 00056 */ 00057 00058 //#include <features.h> 00059 00060 /* masking of interrupts */ 00061 #define _FPU_MASK_IM 0x01 00062 #define _FPU_MASK_DM 0x02 00063 #define _FPU_MASK_ZM 0x04 00064 #define _FPU_MASK_OM 0x08 00065 #define _FPU_MASK_UM 0x10 00066 #define _FPU_MASK_PM 0x20 00067 00068 /* precision control */ 00069 #define _FPU_EXTENDED 0x300 /* libm requires double extended precision. */ 00070 #define _FPU_DOUBLE 0x200 00071 #define _FPU_SINGLE 0x0 00072 00073 /* rounding control */ 00074 #define _FPU_RC_NEAREST 0x0 /* RECOMMENDED */ 00075 #define _FPU_RC_DOWN 0x400 00076 #define _FPU_RC_UP 0x800 00077 #define _FPU_RC_ZERO 0xC00 00078 00079 #define _FPU_RESERVED 0xF0C0 /* Reserved bits in cw */ 00080 00081 00082 /* The fdlibm code requires strict IEEE double precision arithmetic, 00083 and no interrupts for exceptions, rounding to nearest. */ 00084 00085 #define _FPU_DEFAULT 0x037f 00086 00087 /* IEEE: same as above. */ 00088 #define _FPU_IEEE 0x037f 00089 00090 /* Type of the control word. */ 00091 typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__))); 00092 00093 /* Macros for accessing the hardware control word. */ 00094 #define _FPU_GETCW(cw) __asm__ ("fnstcw %0" : "=m" (*&cw)) 00095 #define _FPU_SETCW(cw) __asm__ ("fldcw %0" : : "m" (*&cw)) 00096 00097 /* Default control word set at startup. */ 00098 extern fpu_control_t __fpu_control; 00099 00100 #endif /* fpu_control.h */