|
|
/* killough 5/10/98: In djgpp, use inlined assembly for performance | /* killough 5/10/98: In djgpp, use inlined assembly for performance |
* CPhipps - made __inline__ to inline, as specified in the gcc docs | * CPhipps - made __inline__ to inline, as specified in the gcc docs |
* Also made const */ | * Also made const */ |
inline static const fixed_t FixedMul(fixed_t a, fixed_t b) |
inline static CONSTFUNC fixed_t FixedMul(fixed_t a, fixed_t b) |
{ | { |
fixed_t result; | fixed_t result; |
int dummy; | int dummy; |
|
|
* killough 9/5/98: optimized to reduce the number of branches | * killough 9/5/98: optimized to reduce the number of branches |
* CPhipps - made __inline__ to inline, as specified in the gcc docs | * CPhipps - made __inline__ to inline, as specified in the gcc docs |
* Also made const */ | * Also made const */ |
inline static const fixed_t FixedDiv(fixed_t a, fixed_t b) |
inline static CONSTFUNC fixed_t FixedDiv(fixed_t a, fixed_t b) |
{ | { |
if (abs(a) >> 14 < abs(b)) | if (abs(a) >> 14 < abs(b)) |
{ | { |
|
|
#else /* I386_ASM */ | #else /* I386_ASM */ |
/* CPhipps - made __inline__ to inline, as specified in the gcc docs | /* CPhipps - made __inline__ to inline, as specified in the gcc docs |
* Also made const */ | * Also made const */ |
inline static const fixed_t FixedDiv(fixed_t a, fixed_t b) |
inline static CONSTFUNC fixed_t FixedDiv(fixed_t a, fixed_t b) |
{ | { |
return (abs(a)>>14) >= abs(b) ? ((a^b)>>31) ^ INT_MAX : | return (abs(a)>>14) >= abs(b) ? ((a^b)>>31) ^ INT_MAX : |
(fixed_t)(((int_64_t) a << FRACBITS) / b); | (fixed_t)(((int_64_t) a << FRACBITS) / b); |
|
|
* FixedMod - returns a % b, guaranteeing 0<=a<b | * FixedMod - returns a % b, guaranteeing 0<=a<b |
* (notice that the C standard for % does not guarantee this) | * (notice that the C standard for % does not guarantee this) |
*/ | */ |
inline static const fixed_t FixedMod(fixed_t a, fixed_t b) |
inline static CONSTFUNC fixed_t FixedMod(fixed_t a, fixed_t b) |
{ | { |
if (b & (b-1)) { | if (b & (b-1)) { |
fixed_t r = a % b; | fixed_t r = a % b; |