diff --git a/rtl/i386/i386.inc b/rtl/i386/i386.inc index c268ae3d99..9824181b22 100644 --- a/rtl/i386/i386.inc +++ b/rtl/i386/i386.inc @@ -19,6 +19,8 @@ ****************************************************************************} var os_supports_sse : boolean; + { this variable is set to true, if currently an sse check is executed and no sig ill should be generated } + sse_check : boolean; {$asmmode intel} @@ -1218,6 +1220,25 @@ Procedure SysResetFPU;{$ifdef SYSTEMINLINE}inline;{$endif} end; +{ because of the brain dead sse detection on x86, this test is post poned } +procedure fpc_cpucodeinit; + begin + os_supports_sse:=true; + sse_check:=true; + asm + { force an sse exception if no sse is supported, the exception handler sets + os_supports_sse to false then } + { don't change this instruction, the code above depends on its size } + movq %xmm0,%xmm0 + end; + sse_check:=false; + has_sse_support:=sse_support; + has_mmx_support:=mmx_support; + SysResetFPU; + setup_fastmove; + end; + + {$ifndef darwin} { darwin requires that the stack is aligned to 16 bytes when calling another function } diff --git a/rtl/linux/i386/sighnd.inc b/rtl/linux/i386/sighnd.inc index d636017ca1..311ca8fcd7 100644 --- a/rtl/linux/i386/sighnd.inc +++ b/rtl/linux/i386/sighnd.inc @@ -64,7 +64,11 @@ begin end; SIGBUS: res:=214; - SIGILL, + SIGILL: + if sse_check then + res:=0 + else + res:=216; SIGSEGV : res:=216; end; diff --git a/rtl/linux/system.pp b/rtl/linux/system.pp index b56fc1bc38..09c45ef9cd 100644 --- a/rtl/linux/system.pp +++ b/rtl/linux/system.pp @@ -300,16 +300,21 @@ var initialstkptr : Pointer;external name '__stkptr'; begin SysResetFPU; - {$if defined(cpupowerpc)} +{$if defined(cpupowerpc)} // some PPC kernels set the exception bits FE0/FE1 in the MSR to zero, // disabling all FPU exceptions. Enable them again. fpprctl(PR_SET_FPEXC, PR_FP_EXC_PRECISE); - {$endif} +{$endif} IsConsole := TRUE; StackLength := CheckInitialStkLen(initialStkLen); StackBottom := initialstkptr - StackLength; { Set up signals handlers } InstallSignals; + +{$if defined(cpui386)} + fpc_cpucodeinit; +{$endif cpui386} + { Setup heap } InitHeap; SysInitExceptions; diff --git a/rtl/win32/system.pp b/rtl/win32/system.pp index 47a3cdc96d..ce3c79e809 100644 --- a/rtl/win32/system.pp +++ b/rtl/win32/system.pp @@ -744,10 +744,6 @@ procedure JumpToHandleErrorFrame; end; end; -var - { this variable is set to true, if currently an sse check is executed and no sig ill should be generated } - sse_check : boolean; - function syswin32_i386_exception_handler(excep : PExceptionPointers) : Longint;stdcall; var res: longint; @@ -897,25 +893,6 @@ end; {$endif Set_i386_Exception_handler} -{ because of the brain dead sse detection on x86, this test is post poned } -procedure fpc_cpucodeinit; - begin - os_supports_sse:=true; - sse_check:=true; - asm - { force an sse exception if no sse is supported, the exception handler sets - os_supports_sse to false then } - { don't change this instruction, the code above depends on its size } - movq %xmm0,%xmm0 - end; - sse_check:=false; - has_sse_support:=sse_support; - has_mmx_support:=mmx_support; - SysResetFPU; - setup_fastmove; - end; - - {**************************************************************************** OS dependend widestrings ****************************************************************************}