... |
... |
@@ -27,6 +27,8 @@ |
27
|
27
|
#include <sys/sysctl.h>
|
28
|
28
|
#include <errno.h>
|
29
|
29
|
|
|
30
|
#include <x86/fpu.h>
|
|
31
|
|
30
|
32
|
#include "os.h"
|
31
|
33
|
#include "arch.h"
|
32
|
34
|
#include "globals.h"
|
... |
... |
@@ -133,19 +135,19 @@ os_sigcontext_fpu_modes(ucontext_t *scp) |
133
|
135
|
{
|
134
|
136
|
unsigned int modes;
|
135
|
137
|
|
136
|
|
union savefpu *sv = (union savefpu *) &scp->uc_mcontext.__fpregs.__fp_reg_set;
|
137
|
|
struct env87 *env_87 = (struct env87 *) &sv->sv_87.sv_env;
|
138
|
|
struct envxmm *env_xmm = (struct envxmm *) &sv->sv_xmm.sv_env;
|
|
138
|
union savefpu *sv = &scp->uc_mcontext.__fpregs.__fp_reg_set;
|
|
139
|
struct save87 *env_87 = (struct save87 *) &sv->sv_87;
|
|
140
|
struct fxsave *env_xmm = (struct fxsave *) &sv->sv_xmm;
|
139
|
141
|
u_int16_t cw;
|
140
|
142
|
u_int16_t sw;
|
141
|
143
|
|
142
|
144
|
if (scp->uc_flags & _UC_FPU) {
|
143
|
145
|
if (scp->uc_flags & _UC_FXSAVE) {
|
144
|
|
cw = env_xmm->en_cw;
|
145
|
|
sw = env_xmm->en_sw;
|
|
146
|
cw = env_xmm->fx_cw;
|
|
147
|
sw = env_xmm->fx_sw;
|
146
|
148
|
} else {
|
147
|
|
cw = env_87->en_cw & 0xffff;
|
148
|
|
sw = env_87->en_sw & 0xffff;
|
|
149
|
cw = env_87->s87_cw & 0xffff;
|
|
150
|
sw = env_87->s87_sw & 0xffff;
|
149
|
151
|
}
|
150
|
152
|
} else {
|
151
|
153
|
cw = 0;
|
... |
... |
@@ -156,7 +158,7 @@ os_sigcontext_fpu_modes(ucontext_t *scp) |
156
|
158
|
|
157
|
159
|
#ifdef FEATURE_SSE2
|
158
|
160
|
if (fpu_mode == SSE2) {
|
159
|
|
u_int32_t mxcsr = env_xmm->en_mxcsr;
|
|
161
|
u_int32_t mxcsr = env_xmm->fx_mxcsr;
|
160
|
162
|
|
161
|
163
|
DPRINTF(0, (stderr, "SSE2 modes = %08x\n", (int)mxcsr));
|
162
|
164
|
modes |= mxcsr;
|
... |
... |
@@ -347,9 +349,9 @@ sigfpe_handler(HANDLER_ARGS) |
347
|
349
|
}
|
348
|
350
|
|
349
|
351
|
if (ucontext->uc_flags & _UC_FXSAVE) {
|
350
|
|
sv->sv_xmm.sv_env.en_sw |= trap;
|
|
352
|
sv->sv_xmm.fx_sw |= trap;
|
351
|
353
|
} else {
|
352
|
|
sv->sv_87.sv_env.en_sw |= trap;
|
|
354
|
sv->sv_87.s87_sw |= trap;
|
353
|
355
|
}
|
354
|
356
|
interrupt_handle_now(signal, code, context);
|
355
|
357
|
}
|
... |
... |
@@ -385,16 +387,16 @@ os_dlsym(const char *sym_name, lispobj lib_list) |
385
|
387
|
void
|
386
|
388
|
restore_fpu(ucontext_t *scp)
|
387
|
389
|
{
|
388
|
|
union savefpu *sv = (union savefpu *) &scp->uc_mcontext.__fpregs.__fp_reg_set;
|
389
|
|
struct env87 *env_87 = &sv->sv_87.sv_env;
|
390
|
|
struct envxmm *env_xmm = &sv->sv_xmm.sv_env;
|
|
390
|
union savefpu *sv = &scp->uc_mcontext.__fpregs.__fp_reg_set;
|
|
391
|
struct save87 *env_87 = (struct save87 *) &sv->sv_87;
|
|
392
|
struct fxsave *env_xmm = (struct fxsave *) &sv->sv_xmm;
|
391
|
393
|
u_int16_t cw;
|
392
|
394
|
|
393
|
395
|
if (scp->uc_flags & _UC_FPU) {
|
394
|
396
|
if (scp->uc_flags & _UC_FXSAVE) {
|
395
|
|
cw = env_xmm->en_cw;
|
|
397
|
cw = env_xmm->fx_cw;
|
396
|
398
|
} else {
|
397
|
|
cw = env_87->en_cw & 0xffff;
|
|
399
|
cw = env_87->s87_cw & 0xffff;
|
398
|
400
|
}
|
399
|
401
|
} else {
|
400
|
402
|
return;
|
... |
... |
@@ -403,7 +405,7 @@ restore_fpu(ucontext_t *scp) |
403
|
405
|
__asm__ __volatile__ ("fldcw %0"::"m"(*&cw));
|
404
|
406
|
|
405
|
407
|
if (fpu_mode == SSE2) {
|
406
|
|
u_int32_t mxcsr = env_xmm->en_mxcsr;
|
|
408
|
u_int32_t mxcsr = env_xmm->fx_mxcsr;
|
407
|
409
|
|
408
|
410
|
DPRINTF(0, (stderr, "restore_fpu: mxcsr (raw) = %04x\n", mxcsr));
|
409
|
411
|
__asm__ __volatile__ ("ldmxcsr %0"::"m"(*&mxcsr));
|
... |
... |
@@ -417,6 +419,7 @@ os_support_sse2() |
417
|
419
|
int support_sse2;
|
418
|
420
|
size_t len;
|
419
|
421
|
|
|
422
|
len = sizeof(size_t);
|
420
|
423
|
if (sysctlbyname("machdep.sse2", &support_sse2, &len,
|
421
|
424
|
NULL, 0) == 0 && support_sse2 != 0)
|
422
|
425
|
return TRUE;
|