Line data Source code
1 : /* 2 : * src/x86.c 3 : * 4 : * This work was supported by the Director, Office of Science, Division 5 : * of Mathematical, Information, and Computational Sciences of the 6 : * U.S. Department of Energy under contract number DE-AC03-76SF00098. 7 : * 8 : * Copyright (c) 2000-2001 9 : * 10 : * Contains functions to set and restore the round-to-double flag in the 11 : * control word of a x86 FPU. 12 : */ 13 : 14 : #define _NO_CHANGE 0 15 : #define _UPPER_CASE 1 16 : #define _ADD_UNDERSCORE 2 17 : #define _ADD_TWO_UNDERSCORES 3 18 : 19 : #ifdef FORTRANUNDERSCORE 20 : #define NAMING _ADD_UNDERSCORE 21 : #endif 22 : 23 : #ifdef FORTRANDOUBLEUNDERSCORE 24 : #define NAMING _ADD_TWO_UNDERSCORES 25 : #endif 26 : 27 : #ifdef FORTRANCAPS 28 : #define NAMING _UPPER_CASE 29 : #endif 30 : 31 : #ifndef NAMING 32 : #define NAMING _NO_CHANGE 33 : #endif 34 : 35 : #if (NAMING == _ADD_UNDERSCORE) 36 : #define ice_shr_reprosumx86_fix_start ice_shr_reprosumx86_fix_start_ 37 : #define ice_shr_reprosumx86_fix_end ice_shr_reprosumx86_fix_end_ 38 : #endif 39 : 40 : #if (NAMING == _ADD_TWO_UNDERSCORES) 41 : #define ice_shr_reprosumx86_fix_start ice_shr_reprosumx86_fix_start__ 42 : #define ice_shr_reprosumx86_fix_end ice_shr_reprosumx86_fix_end__ 43 : #endif 44 : 45 : #if (NAMING == _UPPER_CASE) 46 : #define ice_shr_reprosumx86_fix_start ICE_SHR_REPROSUMX86_FIX_START 47 : #define ice_shr_reprosumx86_fix_end ICE_SHR_REPROSUMX86_FIX_END 48 : #endif 49 : 50 : #ifdef x86 51 : #ifndef _FPU_GETCW 52 : #define _FPU_GETCW(x) asm volatile ("fnstcw %0":"=m" (x)); 53 : #endif 54 : 55 : #ifndef _FPU_SETCW 56 : #define _FPU_SETCW(x) asm volatile ("fldcw %0": :"m" (x)); 57 : #endif 58 : 59 : #ifndef _FPU_EXTENDED 60 : #define _FPU_EXTENDED 0x0300 61 : #endif 62 : 63 : #ifndef _FPU_DOUBLE 64 : #define _FPU_DOUBLE 0x0200 65 : #endif 66 : #endif /* x86 */ 67 : 68 0 : void ice_shr_reprosumx86_fix_start(unsigned short *old_cw) { 69 : #ifdef x86 70 : unsigned short new_cw; 71 : 72 : _FPU_GETCW(*old_cw); 73 : new_cw = (*old_cw & ~_FPU_EXTENDED) | _FPU_DOUBLE; 74 : _FPU_SETCW(new_cw); 75 : #endif 76 0 : } 77 : 78 0 : void ice_shr_reprosumx86_fix_end(unsigned short *old_cw) { 79 : #ifdef x86 80 : _FPU_SETCW(*old_cw); 81 : #endif 82 0 : } 83 :