mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-13 11:24:14 +02:00
* refactored SysResetFPU into SysInitFPU and SysResetFPU
git-svn-id: trunk@8966 -
This commit is contained in:
parent
ba224d6b0d
commit
7da7364ee7
@ -361,9 +361,11 @@ end;
|
||||
|
||||
|
||||
begin
|
||||
SysResetFPU;
|
||||
IsConsole := TRUE;
|
||||
IsLibrary := FALSE;
|
||||
SysResetFPU;
|
||||
if not(IsLibrary) then
|
||||
SysInitFPU;
|
||||
StackLength := CheckInitialStkLen(InitialStkLen);
|
||||
StackBottom := Sptr - StackLength;
|
||||
{ OS specific startup }
|
||||
|
@ -21,9 +21,10 @@ const
|
||||
cpu_has_edsp : boolean = false;
|
||||
in_edsp_test : boolean = false;
|
||||
|
||||
procedure fpc_cpuinit;
|
||||
begin
|
||||
{$if not(defined(wince)) and not(defined(gba)) and not(defined(nds)) and not(defined(FPUSOFT)) and not(defined(FPULIBGCC))}
|
||||
{$define FPC_SYSTEM_HAS_SYSINITFPU}
|
||||
Procedure SysInitFPU;{$ifdef SYSTEMINLINE}inline;{$endif}
|
||||
begin
|
||||
{ Enable FPU exceptions, but disable INEXACT, UNDERFLOW, DENORMAL }
|
||||
asm
|
||||
rfs r0
|
||||
@ -31,7 +32,12 @@ begin
|
||||
orr r0,r0,#0x00070000
|
||||
wfs r0
|
||||
end;
|
||||
end;
|
||||
{$endif}
|
||||
|
||||
procedure fpc_cpuinit;
|
||||
begin
|
||||
SysInitFPU;
|
||||
end;
|
||||
|
||||
{$ifdef wince}
|
||||
@ -41,6 +47,11 @@ function _controlfp(new: DWORD; mask: DWORD): DWORD; cdecl; external 'coredll';
|
||||
Procedure SysResetFPU;{$ifdef SYSTEMINLINE}inline;{$endif}
|
||||
begin
|
||||
softfloat_exception_flags:=0;
|
||||
end;
|
||||
|
||||
{$define FPC_SYSTEM_HAS_SYSINITFPU}
|
||||
Procedure SysInitFPU;{$ifdef SYSTEMINLINE}inline;{$endif}
|
||||
begin
|
||||
softfloat_exception_mask:=float_flag_underflow or float_flag_inexact or float_flag_denormal;
|
||||
{ Enable FPU exceptions, but disable INEXACT, UNDERFLOW, DENORMAL }
|
||||
{ FPU precision 64 bit, rounding to nearest, affine infinity }
|
||||
|
@ -259,6 +259,8 @@ var
|
||||
begin
|
||||
{$ifdef FPC_HAS_FEATURE_FPU}
|
||||
SysResetFPU;
|
||||
if not(IsLibrary) then
|
||||
SysInitFPU;
|
||||
{$endif FPC_HAS_FEATURE_FPU}
|
||||
|
||||
{$ifdef FPC_HAS_FEATURE_CONSOLEIO}
|
||||
|
@ -1594,12 +1594,9 @@ begin
|
||||
ErrorOfSig:=206
|
||||
else
|
||||
ErrorOfSig:=207; {'Coprocessor Error'}
|
||||
{ if exceptions then Reset FPU and reload control word }
|
||||
{ if exceptions then Reset FPU and reload control word }
|
||||
if (FPUStatus and FPU_ExceptionMask)<>0 then
|
||||
asm
|
||||
fninit
|
||||
fldcw FPU_ControlWord
|
||||
end;
|
||||
SysResetFPU;
|
||||
end;
|
||||
4 : ErrorOfSig:=215; {'Overflow'}
|
||||
1, {'Debug'}
|
||||
|
@ -1262,8 +1262,9 @@ const
|
||||
|
||||
mxcsr : dword = MM_MaskUnderflow or MM_MaskPrecision or MM_MaskDenorm;
|
||||
|
||||
{$define FPC_SYSTEM_HAS_SYSRESETFPU}
|
||||
Procedure SysResetFPU;{$ifdef SYSTEMINLINE}inline;{$endif}
|
||||
|
||||
{$define FPC_SYSTEM_HAS_SYSINITFPU}
|
||||
Procedure SysInitFPU;{$ifdef SYSTEMINLINE}inline;{$endif}
|
||||
var
|
||||
{ these locals are so we don't have to hack pic code in the assembler }
|
||||
localmxcsr: dword;
|
||||
@ -1271,7 +1272,6 @@ Procedure SysResetFPU;{$ifdef SYSTEMINLINE}inline;{$endif}
|
||||
begin
|
||||
localfpucw:=Default8087CW;
|
||||
asm
|
||||
fninit
|
||||
fldcw localfpucw
|
||||
fwait
|
||||
end;
|
||||
@ -1283,11 +1283,21 @@ Procedure SysResetFPU;{$ifdef SYSTEMINLINE}inline;{$endif}
|
||||
ldmxcsr localmxcsr
|
||||
end;
|
||||
end;
|
||||
softfloat_exception_flags:=0;
|
||||
softfloat_exception_mask:=float_flag_underflow or float_flag_inexact or float_flag_denormal;
|
||||
end;
|
||||
|
||||
|
||||
{$define FPC_SYSTEM_HAS_SYSRESETFPU}
|
||||
Procedure SysResetFPU;{$ifdef SYSTEMINLINE}inline;{$endif}
|
||||
begin
|
||||
asm
|
||||
fnclex
|
||||
fwait
|
||||
end;
|
||||
softfloat_exception_flags:=0;
|
||||
end;
|
||||
|
||||
|
||||
{ because of the brain dead sse detection on x86, this test is post poned }
|
||||
procedure fpc_cpucodeinit;
|
||||
begin
|
||||
@ -1307,6 +1317,8 @@ procedure fpc_cpucodeinit;
|
||||
has_sse_support:=os_supports_sse;
|
||||
has_mmx_support:=mmx_support;
|
||||
SysResetFPU;
|
||||
if not(IsLibrary) then
|
||||
SysInitFPU;
|
||||
{$ifdef USE_FASTMOVE}
|
||||
setup_fastmove;
|
||||
{$endif}
|
||||
|
@ -1665,11 +1665,19 @@ end;
|
||||
procedure SysResetFpu;{$ifdef SYSTEMINLINE}inline;{$endif}
|
||||
begin
|
||||
softfloat_exception_flags:=0;
|
||||
softfloat_exception_mask:=float_flag_underflow or float_flag_inexact or float_flag_denormal;
|
||||
end;
|
||||
|
||||
{$endif FPC_SYSTEM_HAS_SYSRESETFPU}
|
||||
|
||||
{$ifndef FPC_SYSTEM_HAS_SYSINITFPU}
|
||||
|
||||
procedure SysInitFpu;{$ifdef SYSTEMINLINE}inline;{$endif}
|
||||
begin
|
||||
softfloat_exception_mask:=float_flag_underflow or float_flag_inexact or float_flag_denormal;
|
||||
end;
|
||||
|
||||
{$endif FPC_SYSTEM_HAS_SYSINITFPU}
|
||||
|
||||
{$ifndef FPC_SYSTEM_HAS_SWAPENDIAN}
|
||||
function SwapEndian(const AValue: SmallInt): SmallInt;
|
||||
begin
|
||||
|
@ -795,6 +795,7 @@ Procedure SysInitExceptions;
|
||||
procedure SysInitStdIO;
|
||||
{$endif FPC_HAS_FEATURE_CONSOLEIO}
|
||||
Procedure SysResetFPU;{$ifdef SYSTEMINLINE}inline;{$endif}
|
||||
Procedure SysInitFPU;{$ifdef SYSTEMINLINE}inline;{$endif}
|
||||
|
||||
{*****************************************************************************
|
||||
Abstract/Assert/Error Handling
|
||||
|
@ -24,6 +24,7 @@ Var
|
||||
procedure InitThread(stklen:SizeUInt);
|
||||
begin
|
||||
SysResetFPU;
|
||||
SysInitFPU;
|
||||
{$ifndef HAS_MEMORYMANAGER}
|
||||
{ initialize this thread's heap }
|
||||
InitHeapThread;
|
||||
|
@ -307,6 +307,8 @@ begin
|
||||
{$endif}
|
||||
|
||||
SysResetFPU;
|
||||
if not(IsLibrary) then
|
||||
SysInitFPU;
|
||||
{$if defined(cpupowerpc)}
|
||||
// some PPC kernels set the exception bits FE0/FE1 in the MSR to zero,
|
||||
// disabling all FPU exceptions. Enable them again.
|
||||
|
@ -393,11 +393,13 @@ end;
|
||||
|
||||
|
||||
begin
|
||||
SysResetFPU;
|
||||
IsConsole := TRUE;
|
||||
IsLibrary := FALSE;
|
||||
StackLength := CheckInitialStkLen(InitialStkLen);
|
||||
StackBottom := Sptr - StackLength;
|
||||
SysResetFPU;
|
||||
if not(IsLibrary) then
|
||||
SysInitFPU;
|
||||
{ OS specific startup }
|
||||
MOS_ambMsg:=nil;
|
||||
MOS_origDir:=0;
|
||||
|
@ -140,6 +140,7 @@ end;
|
||||
(* procedure InitThread(stklen:cardinal);
|
||||
begin
|
||||
SysResetFPU;
|
||||
SysInitFPU;
|
||||
{ ExceptAddrStack and ExceptObjectStack are threadvars }
|
||||
{ so every thread has its on exception handling capabilities }
|
||||
SysInitExceptions;
|
||||
|
@ -1192,8 +1192,8 @@ end;
|
||||
|
||||
{$IFDEF MORPHOS}
|
||||
{ this is only required for MorphOS }
|
||||
{$define FPC_SYSTEM_HAS_SYSRESETFPU}
|
||||
procedure SysResetFPU;{$ifdef SYSTEMINLINE}inline;{$endif}
|
||||
{$define FPC_SYSTEM_HAS_SYSINITFPU}
|
||||
procedure SysInitFPU;{$ifdef SYSTEMINLINE}inline;{$endif}
|
||||
var tmp: array[0..1] of dword;
|
||||
begin
|
||||
asm
|
||||
@ -1208,6 +1208,12 @@ begin
|
||||
softfloat_exception_flags:=0;
|
||||
softfloat_exception_mask:=float_flag_underflow or float_flag_inexact or float_flag_denormal;
|
||||
end;
|
||||
|
||||
{$define FPC_SYSTEM_HAS_SYSRESETFPU}
|
||||
procedure SysResetFPU;{$ifdef SYSTEMINLINE}inline;{$endif}
|
||||
begin
|
||||
softfloat_exception_flags:=0;
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
{$ifndef FPC_SYSTEM_HAS_MEM_BARRIER}
|
||||
|
@ -45,20 +45,27 @@ function get_got : pointer;assembler;nostackframe;[public, alias: 'FPC_GETGOT'];
|
||||
end;
|
||||
|
||||
|
||||
{$define FPC_SYSTEM_HAS_SYSRESETFPU}
|
||||
Procedure SysResetFPU;{$ifdef SYSTEMINLINE}inline;{$endif}
|
||||
{$define FPC_SYSTEM_HAS_SYSINITFPU}
|
||||
Procedure SysInitFPU;{$ifdef SYSTEMINLINE}inline;{$endif}
|
||||
begin
|
||||
softfloat_exception_flags:=0;
|
||||
softfloat_exception_mask:=float_flag_underflow or float_flag_inexact or float_flag_denormal;
|
||||
{ enable div by 0 and invalid operation fpu exceptions
|
||||
round towards zero; ieee compliant arithmetics }
|
||||
set_fsr((get_fsr and $3fbfffff) or $09000000);
|
||||
end;
|
||||
|
||||
{$define FPC_SYSTEM_HAS_SYSRESETFPU}
|
||||
Procedure SysResetFPU;{$ifdef SYSTEMINLINE}inline;{$endif}
|
||||
begin
|
||||
softfloat_exception_flags:=0;
|
||||
end;
|
||||
|
||||
|
||||
procedure fpc_cpuinit;
|
||||
begin
|
||||
SysResetFPU;
|
||||
if not(IsLibrary) then
|
||||
SysInitFPU;
|
||||
end;
|
||||
|
||||
|
||||
|
@ -192,6 +192,9 @@ threadvar
|
||||
function GetCommandLine : pchar;
|
||||
stdcall;external KernelDLL name 'GetCommandLineA';
|
||||
|
||||
function GetCommandLineW : pwidechar;
|
||||
stdcall;external KernelDLL name 'GetCommandLineW';
|
||||
|
||||
function GetCurrentProcessId:DWORD;
|
||||
stdcall; external KernelDLL name 'GetCurrentProcessId';
|
||||
|
||||
|
@ -379,7 +379,6 @@ procedure Exe_entry;[public,alias:'_FPC_EXE_Entry'];
|
||||
xorl %eax,%eax
|
||||
movw %ss,%ax
|
||||
movl %eax,_SS
|
||||
call SysResetFPU
|
||||
xorl %ebp,%ebp
|
||||
call PASCALMAIN
|
||||
popl %ebp
|
||||
@ -1110,6 +1109,11 @@ begin
|
||||
StackBottom := StackTop - StackLength;
|
||||
{ get some helpful informations }
|
||||
GetStartupInfo(@startupinfo);
|
||||
|
||||
SysResetFPU;
|
||||
if not(IsLibrary) then
|
||||
SysInitFPU;
|
||||
|
||||
{ some misc Win32 stuff }
|
||||
hprevinst:=0;
|
||||
if not IsLibrary then
|
||||
|
@ -416,7 +416,6 @@ procedure Exe_entry;[public,alias:'_FPC_EXE_Entry'];
|
||||
xorl %rax,%rax
|
||||
movw %ss,%ax
|
||||
movl %eax,_SS
|
||||
call SysResetFPU
|
||||
xorl %rbp,%rbp
|
||||
call PASCALMAIN
|
||||
popq %rbp
|
||||
@ -1144,7 +1143,9 @@ end;
|
||||
|
||||
|
||||
begin
|
||||
SysResetFPU;
|
||||
SysResetFPU;
|
||||
if not(IsLibrary) then
|
||||
SysInitFPU;
|
||||
StackLength := CheckInitialStkLen(InitialStkLen);
|
||||
StackBottom := StackTop - StackLength;
|
||||
{ get some helpful informations }
|
||||
|
@ -1789,7 +1789,9 @@ begin
|
||||
end;
|
||||
|
||||
initialization
|
||||
SysResetFPU;
|
||||
SysResetFPU;
|
||||
if not(IsLibrary) then
|
||||
SysInitFPU;
|
||||
StackLength := CheckInitialStkLen(InitialStkLen);
|
||||
StackBottom := StackTop - StackLength;
|
||||
{ some misc stuff }
|
||||
|
@ -27,6 +27,8 @@
|
||||
procedure fpc_cpuinit;
|
||||
begin
|
||||
SysResetFPU;
|
||||
if not(IsLibrary) then
|
||||
SysInitFPU;
|
||||
end;
|
||||
|
||||
{$define FPC_SYSTEM_HAS_SPTR}
|
||||
@ -591,16 +593,10 @@ const
|
||||
|
||||
mxcsr : dword = MM_MaskUnderflow or MM_MaskPrecision or MM_MaskDenorm;
|
||||
|
||||
{$define FPC_SYSTEM_HAS_SYSRESETFPU}
|
||||
Procedure SysResetFPU;
|
||||
{$define FPC_SYSTEM_HAS_SYSINITFPU}
|
||||
Procedure SysInitFPU;
|
||||
begin
|
||||
asm
|
||||
{ Win64 uses the fpu for ln etc. so we've to reset it as well
|
||||
$ifndef WIN64}
|
||||
{ initialize fpu }
|
||||
fninit
|
||||
fwait
|
||||
{ $endif WIN64}
|
||||
{$ifdef FPC_PIC}
|
||||
movq fpucw@GOTPCREL(%rip),%rax
|
||||
fldcw (%rax)
|
||||
@ -614,10 +610,22 @@ begin
|
||||
{$endif FPC_PIC}
|
||||
end ['RAX'];
|
||||
{ x86-64 might use softfloat code }
|
||||
softfloat_exception_flags:=0;
|
||||
softfloat_exception_mask:=float_flag_underflow or float_flag_inexact or float_flag_denormal;
|
||||
end;
|
||||
|
||||
|
||||
{$define FPC_SYSTEM_HAS_SYSRESETFPU}
|
||||
Procedure SysResetFPU;
|
||||
begin
|
||||
asm
|
||||
{ initialize fpu }
|
||||
fnclex
|
||||
fwait
|
||||
end;
|
||||
{ x86-64 might use softfloat code }
|
||||
softfloat_exception_flags:=0;
|
||||
end;
|
||||
|
||||
{$ifndef FPC_SYSTEM_HAS_MEM_BARRIER}
|
||||
{$define FPC_SYSTEM_HAS_MEM_BARRIER}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user