floatingpoint.h (326) | floatingpoint.h (338) |
---|---|
1/*- 2 * Copyright (c) 1993 Andrew Moore, Talke Studio 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 --- 41 unchanged lines hidden (view full) --- 50#define fnstenv(addr) __asm("fnstenv %0" : "=m" (*addr) : "0" (*addr)) 51#define fldenv(addr) __asm("fldenv %0" : : "m" (*addr)) 52 53#ifdef __i386__ 54 55/* 56 * return the contents of a FP register 57 */ | 1/*- 2 * Copyright (c) 1993 Andrew Moore, Talke Studio 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 --- 41 unchanged lines hidden (view full) --- 50#define fnstenv(addr) __asm("fnstenv %0" : "=m" (*addr) : "0" (*addr)) 51#define fldenv(addr) __asm("fldenv %0" : : "m" (*addr)) 52 53#ifdef __i386__ 54 55/* 56 * return the contents of a FP register 57 */ |
58static __inline__ 59__fpgetreg(reg) | 58static __inline__ int 59__fpgetreg(int _reg) |
60{ | 60{ |
61 unsigned short mem; | 61 unsigned short _mem; |
62 | 62 |
63 switch(reg) { | 63 switch(_reg) { |
64 default: | 64 default: |
65 fnstcw(&mem); | 65 fnstcw(&_mem); |
66 break; 67 case FP_STKY_REG: | 66 break; 67 case FP_STKY_REG: |
68 fnstsw(&mem); | 68 fnstsw(&_mem); |
69 break; 70 } | 69 break; 70 } |
71 return mem; | 71 return _mem; |
72} 73 74/* 75 * set a FP mode; return previous mode 76 */ | 72} 73 74/* 75 * set a FP mode; return previous mode 76 */ |
77static __inline__ 78__fpsetreg(m, reg, fld, off) | 77static __inline__ int 78__fpsetreg(int _m, int _reg, int _fld, int _off) |
79{ | 79{ |
80 unsigned env[7]; 81 unsigned p; | 80 unsigned _env[7]; 81 unsigned _p; |
82 | 82 |
83 fnstenv(env); 84 p = (env[reg] & fld) >> off; 85 env[reg] = (env[reg] & ~fld) | (m << off & fld); 86 fldenv(env); 87 return p; | 83 fnstenv(_env); 84 _p = (_env[_reg] & _fld) >> _off; 85 _env[_reg] = (_env[_reg] & ~_fld) | (_m << _off & _fld); 86 fldenv(_env); 87 return _p; |
88} 89 90#endif /* __i386__ */ 91 92#endif /* __GNUC__ */ 93 94/* 95 * SysV/386 FP control interface --- 12 unchanged lines hidden --- | 88} 89 90#endif /* __i386__ */ 91 92#endif /* __GNUC__ */ 93 94/* 95 * SysV/386 FP control interface --- 12 unchanged lines hidden --- |