summaryrefslogtreecommitdiffstats
path: root/Alc/helpers.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2012-09-16 01:35:16 -0700
committerChris Robinson <[email protected]>2012-09-16 01:35:16 -0700
commit657ee85136861c9da105a67050ae84a85ecfe808 (patch)
tree09c60903ae761af302703315761355513c1c168c /Alc/helpers.c
parent965306b296d6599d8562c713c18a01b8766eafee (diff)
Use a struct to store the FPU mode
Diffstat (limited to 'Alc/helpers.c')
-rw-r--r--Alc/helpers.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/Alc/helpers.c b/Alc/helpers.c
index 9529acec..5acf2be2 100644
--- a/Alc/helpers.c
+++ b/Alc/helpers.c
@@ -173,41 +173,38 @@ void al_free(void *ptr)
}
-int SetMixerFPUMode(void)
+void SetMixerFPUMode(FPUCtl *ctl)
{
#if defined(_FPU_GETCW) && defined(_FPU_SETCW) && (defined(__i386__) || defined(__x86_64__))
fpu_control_t fpuState, newState;
_FPU_GETCW(fpuState);
+ ctl->state = fpuState;
newState = fpuState&~(_FPU_EXTENDED|_FPU_DOUBLE|_FPU_SINGLE |
_FPU_RC_NEAREST|_FPU_RC_DOWN|_FPU_RC_UP|_FPU_RC_ZERO);
newState |= _FPU_SINGLE | _FPU_RC_ZERO;
if((CPUCapFlags&CPU_CAP_SSE))
newState |= 0x8000; /* flush-to-zero */
_FPU_SETCW(newState);
-#else
- int fpuState;
-#if defined(HAVE__CONTROLFP)
- fpuState = _controlfp(0, 0);
+#elif defined(HAVE__CONTROLFP)
+ ctl->state = _controlfp(0, 0);
(void)_controlfp(_RC_CHOP|_DN_FLUSH|_PC_24, _MCW_RC|_MCW_DN|_MCW_PC);
#elif defined(HAVE_FESETROUND)
- fpuState = fegetround();
+ ctl->state = fegetround();
#ifdef FE_TOWARDZERO
fesetround(FE_TOWARDZERO);
#endif
#endif
-#endif
- return fpuState;
}
-void RestoreFPUMode(int state)
+void RestoreFPUMode(const FPUCtl *ctl)
{
#if defined(_FPU_GETCW) && defined(_FPU_SETCW) && (defined(__i386__) || defined(__x86_64__))
- fpu_control_t fpuState = state;
+ fpu_control_t fpuState = ctl->state;
_FPU_SETCW(fpuState);
#elif defined(HAVE__CONTROLFP)
- _controlfp(state, _MCW_RC|_MCW_DN|_MCW_PC);
+ _controlfp(ctl->state, _MCW_RC|_MCW_DN|_MCW_PC);
#elif defined(HAVE_FESETROUND)
- fesetround(state);
+ fesetround(ctl->state);
#endif
}