mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-22 00:09:25 +02:00
* signal cleanup for linux
* sigactionhandler instead of tsigaction for bsds * sigcontext moved to cpu dir
This commit is contained in:
parent
b28fd2f6b9
commit
7fb8c3dfbd
@ -190,7 +190,7 @@
|
||||
PSignalHandler = ^SignalHandler;
|
||||
SignalRestorer = Procedure;cdecl;
|
||||
PSignalRestorer = ^SignalRestorer;
|
||||
TSigAction = procedure (Sig: cint; var info : tsiginfo_t;Var SigContext:SigContextRec); cdecl;
|
||||
SigActionHandler = procedure (Sig: cint; var info : tsiginfo_t;Var SigContext:SigContextRec); cdecl;
|
||||
|
||||
|
||||
SigActionRec = packed record
|
||||
@ -199,7 +199,7 @@
|
||||
0: (Sh: SignalHandler; Sa_Flags: longint; Sa_Mask: SigSet);
|
||||
1: (sa_handler: TSigAction);
|
||||
}
|
||||
Sa_Handler: TSigAction;
|
||||
Sa_Handler: SigActionHandler;
|
||||
Sa_Mask: sigset_t;
|
||||
Sa_Flags: cint;
|
||||
end;
|
||||
@ -271,7 +271,12 @@ const
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.5 2004-01-08 21:52:34 jonas
|
||||
Revision 1.6 2005-01-30 18:01:15 peter
|
||||
* signal cleanup for linux
|
||||
* sigactionhandler instead of tsigaction for bsds
|
||||
* sigcontext moved to cpu dir
|
||||
|
||||
Revision 1.5 2004/01/08 21:52:34 jonas
|
||||
* fixed signal handling under 10.3.2, still have to verify whether it's
|
||||
backwards compatible
|
||||
|
||||
|
@ -158,7 +158,7 @@ type sigset_t = array[0..3] of Longint;
|
||||
PSignalHandler = ^SignalHandler;
|
||||
SignalRestorer = Procedure;cdecl;
|
||||
PSignalRestorer = ^SignalRestorer;
|
||||
TSigAction = procedure(Sig: Longint; var sininfo:tsiginfo_t;var SigContext: SigContextRec);cdecl;
|
||||
sigActionHandler = procedure(Sig: Longint; var sininfo:tsiginfo_t;var SigContext: SigContextRec);cdecl;
|
||||
|
||||
TSigset=sigset_t;
|
||||
sigset=tsigset;
|
||||
@ -170,7 +170,7 @@ type sigset_t = array[0..3] of Longint;
|
||||
0: (Sh: SignalHandler);
|
||||
1: (Sa: TSigAction);
|
||||
end;}
|
||||
sa_handler : tsigAction;
|
||||
sa_handler : sigActionHandler;
|
||||
Sa_Flags : Longint;
|
||||
Sa_Mask : TSigSet;
|
||||
end;
|
||||
@ -196,7 +196,12 @@ const
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.9 2004-12-30 12:52:43 marco
|
||||
Revision 1.10 2005-01-30 18:01:15 peter
|
||||
* signal cleanup for linux
|
||||
* sigactionhandler instead of tsigaction for bsds
|
||||
* sigcontext moved to cpu dir
|
||||
|
||||
Revision 1.9 2004/12/30 12:52:43 marco
|
||||
* tsignalhandler added"
|
||||
|
||||
Revision 1.8 2003/10/27 17:12:45 marco
|
||||
|
@ -17,7 +17,7 @@
|
||||
**********************************************************************}
|
||||
|
||||
|
||||
procedure SignalToRunerror(Sig: longint; _a2,_a3,_a4 : dword; SigContext: PSigInfoRec; uContext : PuContext); cdecl;
|
||||
procedure SignalToRunerror(Sig: longint; _a2,_a3,_a4 : dword; SigContext: PSigInfo; uContext : PuContext); cdecl;
|
||||
|
||||
var
|
||||
res,fpustate : word;
|
||||
@ -41,7 +41,12 @@ end;
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.2 2004-03-27 19:20:11 florian
|
||||
Revision 1.3 2005-01-30 18:01:15 peter
|
||||
* signal cleanup for linux
|
||||
* sigactionhandler instead of tsigaction for bsds
|
||||
* sigcontext moved to cpu dir
|
||||
|
||||
Revision 1.2 2004/03/27 19:20:11 florian
|
||||
* signal handling fixed
|
||||
|
||||
Revision 1.1 2003/11/21 00:40:06 florian
|
||||
|
72
rtl/linux/arm/sighndh.inc
Normal file
72
rtl/linux/arm/sighndh.inc
Normal file
@ -0,0 +1,72 @@
|
||||
{
|
||||
$Id$
|
||||
This file is part of the Free Pascal run time library.
|
||||
Copyright (c) 1999-2000 by Jonas Maebe,
|
||||
member of the Free Pascal development team.
|
||||
|
||||
TSigContext
|
||||
|
||||
See the file COPYING.FPC, included in this distribution,
|
||||
for details about the copyright.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
**********************************************************************}
|
||||
|
||||
{$packrecords C}
|
||||
|
||||
type
|
||||
PSigContext = ^TSigContext;
|
||||
TSigContext = record
|
||||
trap_no : dword;
|
||||
error_code : dword;
|
||||
oldmask : dword;
|
||||
arm_r0 : dword;
|
||||
arm_r1 : dword;
|
||||
arm_r2 : dword;
|
||||
arm_r3 : dword;
|
||||
arm_r4 : dword;
|
||||
arm_r5 : dword;
|
||||
arm_r6 : dword;
|
||||
arm_r7 : dword;
|
||||
arm_r8 : dword;
|
||||
arm_r9 : dword;
|
||||
arm_r10 : dword;
|
||||
arm_fp : dword;
|
||||
arm_ip : dword;
|
||||
arm_sp : dword;
|
||||
arm_lr : dword;
|
||||
arm_pc : dword;
|
||||
arm_cpsr : dword;
|
||||
fault_address : dword;
|
||||
end;
|
||||
|
||||
{ from include/asm-ppc/signal.h }
|
||||
stack_t = record
|
||||
ss_sp: pointer;
|
||||
ss_flags: longint;
|
||||
ss_size: size_t;
|
||||
end;
|
||||
|
||||
{ from include/asm-arm/ucontext.h }
|
||||
pucontext = ^tucontext;
|
||||
tucontext = record
|
||||
uc_flags : dword;
|
||||
uc_link : pucontext;
|
||||
uc_stack : stack_t;
|
||||
uc_mcontext : TSigContext;
|
||||
uc_sigmask : sigset_t;
|
||||
end;
|
||||
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.1 2005-01-30 18:01:15 peter
|
||||
* signal cleanup for linux
|
||||
* sigactionhandler instead of tsigaction for bsds
|
||||
* sigcontext moved to cpu dir
|
||||
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ begin
|
||||
fpseterrno(oerrno);
|
||||
exit(cuint(-1));
|
||||
End;
|
||||
if oact.sa_handler=signalhandler(SIG_IGN) Then
|
||||
if oact.sa_handler=SigActionhandler(SIG_IGN) Then
|
||||
Begin
|
||||
fpsleep:=fpnanosleep(@time_to_sleep, @time_remaining);
|
||||
oerrno:=fpgeterrno;
|
||||
@ -565,7 +565,12 @@ end;
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.14 2004-11-19 13:15:14 marco
|
||||
Revision 1.15 2005-01-30 18:01:15 peter
|
||||
* signal cleanup for linux
|
||||
* sigactionhandler instead of tsigaction for bsds
|
||||
* sigcontext moved to cpu dir
|
||||
|
||||
Revision 1.14 2004/11/19 13:15:14 marco
|
||||
* external rework. Mostly done.
|
||||
|
||||
Revision 1.13 2004/11/14 12:21:08 marco
|
||||
|
@ -20,7 +20,7 @@
|
||||
const
|
||||
FPU_All = $7f;
|
||||
|
||||
function GetFPUState(const SigContext : SigContextRec) : longint;
|
||||
function GetFPUState(const SigContext : TSigContext) : longint;
|
||||
begin
|
||||
if assigned(SigContext.fpstate) then
|
||||
GetfpuState:=SigContext.fpstate^.sw;
|
||||
@ -32,8 +32,8 @@ begin
|
||||
{$endif SYSTEM_DEBUG}
|
||||
end;
|
||||
|
||||
procedure SignalToRunerror(Sig: longint; SigContext: SigContextRec); cdecl;
|
||||
|
||||
procedure SignalToRunerror(sig : longint; SigInfo: PSigInfo; SigContext: PSigContext);cdecl;
|
||||
var
|
||||
res,fpustate : word;
|
||||
begin
|
||||
@ -44,7 +44,7 @@ begin
|
||||
{ this is not allways necessary but I don't know yet
|
||||
how to tell if it is or not PM }
|
||||
res:=200;
|
||||
fpustate:=GetFPUState(SigContext);
|
||||
fpustate:=GetFPUState(SigContext^);
|
||||
if (FpuState and FPU_All) <> 0 then
|
||||
begin
|
||||
{ first check the more precise options }
|
||||
@ -70,12 +70,17 @@ begin
|
||||
end;
|
||||
{ give runtime error at the position where the signal was raised }
|
||||
if res<>0 then
|
||||
HandleErrorAddrFrame(res,pointer(SigContext.eip),pointer(SigContext.ebp));
|
||||
HandleErrorAddrFrame(res,pointer(SigContext^.eip),pointer(SigContext^.ebp));
|
||||
end;
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.4 2004-08-08 09:36:09 florian
|
||||
Revision 1.5 2005-01-30 18:01:15 peter
|
||||
* signal cleanup for linux
|
||||
* sigactionhandler instead of tsigaction for bsds
|
||||
* sigcontext moved to cpu dir
|
||||
|
||||
Revision 1.4 2004/08/08 09:36:09 florian
|
||||
* fixed runerror for invalid operation
|
||||
|
||||
Revision 1.3 2004/02/05 01:16:12 florian
|
||||
|
67
rtl/linux/i386/sighndh.inc
Normal file
67
rtl/linux/i386/sighndh.inc
Normal file
@ -0,0 +1,67 @@
|
||||
{
|
||||
$Id$
|
||||
This file is part of the Free Pascal run time library.
|
||||
Copyright (c) 1999-2000 by Jonas Maebe,
|
||||
member of the Free Pascal development team.
|
||||
|
||||
Sigcontext and Sigaction
|
||||
|
||||
See the file COPYING.FPC, included in this distribution,
|
||||
for details about the copyright.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
**********************************************************************}
|
||||
|
||||
{$packrecords C}
|
||||
|
||||
type
|
||||
tfpreg = record
|
||||
significand: array[0..3] of word;
|
||||
exponent: word;
|
||||
end;
|
||||
|
||||
pfpstate = ^tfpstate;
|
||||
tfpstate = record
|
||||
cw, sw, tag, ipoff, cssel, dataoff, datasel: cardinal;
|
||||
st: array[0..7] of tfpreg;
|
||||
status: cardinal;
|
||||
end;
|
||||
|
||||
PSigContext = ^TSigContext;
|
||||
TSigContext = record
|
||||
gs, __gsh: word;
|
||||
fs, __fsh: word;
|
||||
es, __esh: word;
|
||||
ds, __dsh: word;
|
||||
edi: cardinal;
|
||||
esi: cardinal;
|
||||
ebp: cardinal;
|
||||
esp: cardinal;
|
||||
ebx: cardinal;
|
||||
edx: cardinal;
|
||||
ecx: cardinal;
|
||||
eax: cardinal;
|
||||
trapno: cardinal;
|
||||
err: cardinal;
|
||||
eip: cardinal;
|
||||
cs, __csh: word;
|
||||
eflags: cardinal;
|
||||
esp_at_signal: cardinal;
|
||||
ss, __ssh: word;
|
||||
fpstate: pfpstate;
|
||||
oldmask: cardinal;
|
||||
cr2: cardinal;
|
||||
end;
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.1 2005-01-30 18:01:15 peter
|
||||
* signal cleanup for linux
|
||||
* sigactionhandler instead of tsigaction for bsds
|
||||
* sigcontext moved to cpu dir
|
||||
|
||||
}
|
||||
|
@ -491,7 +491,7 @@ begin
|
||||
{ all flags and information set to zero }
|
||||
FillChar(act, sizeof(SigActionRec),0);
|
||||
{ initialize handler }
|
||||
act.sa_handler := signalhandler(@SignalToRunError);
|
||||
act.sa_handler := @SignalToRunError;
|
||||
{$ifdef RTSIGACTION}
|
||||
act.sa_flags:=SA_SIGINFO
|
||||
{$ifdef cpux86_64}
|
||||
@ -565,7 +565,12 @@ end;
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.22 2004-11-02 14:49:48 florian
|
||||
Revision 1.23 2005-01-30 18:01:15 peter
|
||||
* signal cleanup for linux
|
||||
* sigactionhandler instead of tsigaction for bsds
|
||||
* sigcontext moved to cpu dir
|
||||
|
||||
Revision 1.22 2004/11/02 14:49:48 florian
|
||||
* fixed baseunix.signal for CPU using rt_sigaction
|
||||
* fixed it for x86_64 too
|
||||
|
||||
|
@ -17,8 +17,7 @@
|
||||
**********************************************************************}
|
||||
|
||||
|
||||
procedure SignalToRunerror(Sig: longint; SigContext: PSigContextRec); cdecl;
|
||||
|
||||
procedure SignalToRunerror(sig : longint; SigInfo: PSigInfo; SigContext: PSigContext);cdecl;
|
||||
var
|
||||
res : word;
|
||||
{ fpustate: longint; }
|
||||
@ -47,14 +46,19 @@ begin
|
||||
SIGSEGV :
|
||||
res:=216;
|
||||
end;
|
||||
{ give runtime error at the position where the signal was raised }
|
||||
{ give runtime error at the position where the signal was raised }
|
||||
if res<>0 then
|
||||
HandleErrorAddrFrame(res,pointer(SigContext^.pt_regs^.nip),pointer(SigContext^.pt_regs^.gpr[1]));
|
||||
end;
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.4 2004-01-02 17:57:16 jonas
|
||||
Revision 1.5 2005-01-30 18:01:15 peter
|
||||
* signal cleanup for linux
|
||||
* sigactionhandler instead of tsigaction for bsds
|
||||
* sigcontext moved to cpu dir
|
||||
|
||||
Revision 1.4 2004/01/02 17:57:16 jonas
|
||||
* re-enable fpu exceptions in signal handler, they're turned off by the
|
||||
kernel
|
||||
|
||||
|
88
rtl/linux/powerpc/sighndh.inc
Normal file
88
rtl/linux/powerpc/sighndh.inc
Normal file
@ -0,0 +1,88 @@
|
||||
{
|
||||
$Id$
|
||||
This file is part of the Free Pascal run time library.
|
||||
Copyright (c) 1999-2000 by Jonas Maebe,
|
||||
member of the Free Pascal development team.
|
||||
|
||||
TSigContext
|
||||
|
||||
See the file COPYING.FPC, included in this distribution,
|
||||
for details about the copyright.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
**********************************************************************}
|
||||
|
||||
{$packrecords C}
|
||||
|
||||
type
|
||||
{ from include/ppc/ptrace.h }
|
||||
pptregs = ^tptregs;
|
||||
tptregs = record
|
||||
gpr: array[0..31] of cardinal;
|
||||
nip: cardinal;
|
||||
msr: cardinal;
|
||||
orig_gpr3: cardinal; { Used for restarting system calls }
|
||||
ctr: cardinal;
|
||||
link: cardinal;
|
||||
xer: cardinal;
|
||||
ccr: cardinal;
|
||||
mq: cardinal; { 601 only (not used at present) }
|
||||
{ Used on APUS to hold IPL value. }
|
||||
trap: cardinal; { Reason for being here }
|
||||
dar: cardinal; { Fault registers }
|
||||
dsisr: cardinal;
|
||||
result: cardinal; { Result of a system call }
|
||||
end;
|
||||
|
||||
{ from include/asm-ppc/signal.h }
|
||||
stack_t = record
|
||||
ss_sp: pointer;
|
||||
ss_flags: longint;
|
||||
ss_size: size_t;
|
||||
end;
|
||||
|
||||
{ from include/asm-ppc/sigcontext.h }
|
||||
tsigcontext_struct = record
|
||||
_unused: array[0..3] of dword;
|
||||
signal: longint;
|
||||
handler: dword;
|
||||
oldmask: dword;
|
||||
pt_regs: pptregs;
|
||||
end;
|
||||
|
||||
{ from include/asm-ppc/ucontext.h }
|
||||
pucontext = ^tucontext;
|
||||
tucontext = record
|
||||
uc_flags : dword;
|
||||
uc_link : pucontext;
|
||||
uc_stack : stack_t;
|
||||
uc_mcontext : tsigcontext_struct;
|
||||
uc_sigmask : sigset_t;
|
||||
end;
|
||||
|
||||
|
||||
{ from arch/ppc/kernel/signal.c, the type of the actual parameter passed }
|
||||
{ to the sigaction handler }
|
||||
t_rt_sigframe = record
|
||||
_unused: array[0..1] of cardinal;
|
||||
pinfo: psiginfo;
|
||||
puc: pointer;
|
||||
siginfo: tsiginfo;
|
||||
uc: tucontext;
|
||||
end;
|
||||
|
||||
PSigContext = ^TSigContext;
|
||||
TSigContext= tsigcontext_struct;
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.1 2005-01-30 18:01:15 peter
|
||||
* signal cleanup for linux
|
||||
* sigactionhandler instead of tsigaction for bsds
|
||||
* sigcontext moved to cpu dir
|
||||
|
||||
}
|
||||
|
@ -123,171 +123,14 @@ Const
|
||||
const
|
||||
SI_PAD_SIZE = ((128 div sizeof(longint)) - 3);
|
||||
|
||||
|
||||
type
|
||||
tfpreg = record
|
||||
significand: array[0..3] of word;
|
||||
exponent: word;
|
||||
end;
|
||||
|
||||
pfpstate = ^tfpstate;
|
||||
tfpstate = record
|
||||
cw, sw, tag, ipoff, cssel, dataoff, datasel: cardinal;
|
||||
st: array[0..7] of tfpreg;
|
||||
status: cardinal;
|
||||
end;
|
||||
|
||||
SigSet = array[0..wordsinsigset-1] of cint;
|
||||
sigset_t= SigSet;
|
||||
PSigSet = ^SigSet;
|
||||
psigset_t=psigset;
|
||||
TSigSet = SigSet;
|
||||
|
||||
|
||||
{$ifdef cpui386}
|
||||
PSigContextRec = ^SigContextRec;
|
||||
SigContextRec = record
|
||||
gs, __gsh: word;
|
||||
fs, __fsh: word;
|
||||
es, __esh: word;
|
||||
ds, __dsh: word;
|
||||
edi: cardinal;
|
||||
esi: cardinal;
|
||||
ebp: cardinal;
|
||||
esp: cardinal;
|
||||
ebx: cardinal;
|
||||
edx: cardinal;
|
||||
ecx: cardinal;
|
||||
eax: cardinal;
|
||||
trapno: cardinal;
|
||||
err: cardinal;
|
||||
eip: cardinal;
|
||||
cs, __csh: word;
|
||||
eflags: cardinal;
|
||||
esp_at_signal: cardinal;
|
||||
ss, __ssh: word;
|
||||
fpstate: pfpstate;
|
||||
oldmask: cardinal;
|
||||
cr2: cardinal;
|
||||
end;
|
||||
{$endif cpui386}
|
||||
|
||||
|
||||
{$Ifdef cpum68k}
|
||||
PSigContextRec = ^SigContextRec;
|
||||
SigContextRec = record
|
||||
{ dummy for now PM }
|
||||
end;
|
||||
{$endif cpum68k}
|
||||
|
||||
|
||||
{$ifdef cpupowerpc}
|
||||
{ from include/ppc/ptrace.h }
|
||||
pptregs = ^tptregs;
|
||||
tptregs = record
|
||||
gpr: array[0..31] of cardinal;
|
||||
nip: cardinal;
|
||||
msr: cardinal;
|
||||
orig_gpr3: cardinal; { Used for restarting system calls }
|
||||
ctr: cardinal;
|
||||
link: cardinal;
|
||||
xer: cardinal;
|
||||
ccr: cardinal;
|
||||
mq: cardinal; { 601 only (not used at present) }
|
||||
{ Used on APUS to hold IPL value. }
|
||||
trap: cardinal; { Reason for being here }
|
||||
dar: cardinal; { Fault registers }
|
||||
dsisr: cardinal;
|
||||
result: cardinal; { Result of a system call }
|
||||
end;
|
||||
|
||||
{ from include/asm/ppc/siginfo.h }
|
||||
psiginfo = ^tsiginfo;
|
||||
tsiginfo = record
|
||||
si_signo : longint;
|
||||
si_errno : longint;
|
||||
si_code : longint;
|
||||
_sifields : record
|
||||
case longint of
|
||||
0 : ( _pad : array[0..(SI_PAD_SIZE)-1] of longint );
|
||||
1 : ( _kill : record
|
||||
_pid : pid_t;
|
||||
_uid : uid_t;
|
||||
end );
|
||||
2 : ( _timer : record
|
||||
_timer1 : dword;
|
||||
_timer2 : dword;
|
||||
end );
|
||||
3 : ( _rt : record
|
||||
_pid : pid_t;
|
||||
_uid : uid_t;
|
||||
_sigval : pointer;
|
||||
end );
|
||||
4 : ( _sigchld : record
|
||||
_pid : pid_t;
|
||||
_uid : uid_t;
|
||||
_status : longint;
|
||||
_utime : clock_t;
|
||||
_stime : clock_t;
|
||||
end );
|
||||
5 : ( _sigfault : record
|
||||
_addr : pointer;
|
||||
end );
|
||||
6 : ( _sigpoll : record
|
||||
_band : longint;
|
||||
_fd : longint;
|
||||
end );
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
{ from include/asm-ppc/signal.h }
|
||||
stack_t = record
|
||||
ss_sp: pointer;
|
||||
ss_flags: longint;
|
||||
ss_size: size_t;
|
||||
end;
|
||||
|
||||
{ from include/asm-ppc/sigcontext.h }
|
||||
tsigcontext_struct = record
|
||||
_unused: array[0..3] of dword;
|
||||
signal: longint;
|
||||
handler: dword;
|
||||
oldmask: dword;
|
||||
pt_regs: pptregs;
|
||||
end;
|
||||
|
||||
{ from include/asm-ppc/ucontext.h }
|
||||
pucontext = ^tucontext;
|
||||
tucontext = record
|
||||
uc_flags : dword;
|
||||
uc_link : pucontext;
|
||||
uc_stack : stack_t;
|
||||
uc_mcontext : tsigcontext_struct;
|
||||
uc_sigmask : sigset_t;
|
||||
end;
|
||||
|
||||
|
||||
{ from arch/ppc/kernel/signal.c, the type of the actual parameter passed }
|
||||
{ to the sigaction handler }
|
||||
t_rt_sigframe = record
|
||||
_unused: array[0..1] of cardinal;
|
||||
pinfo: psiginfo;
|
||||
puc: pointer;
|
||||
siginfo: tsiginfo;
|
||||
uc: tucontext;
|
||||
end;
|
||||
|
||||
PSigContextRec = ^SigContextRec;
|
||||
SigContextRec = tsigcontext_struct;
|
||||
{$endif cpupowerpc}
|
||||
|
||||
|
||||
{$ifdef cpusparc}
|
||||
PSigContextRec = ^SigContextRec;
|
||||
SigContextRec = record
|
||||
{ dummy for now PM }
|
||||
end;
|
||||
|
||||
|
||||
psiginfo = ^tsiginfo;
|
||||
tsiginfo = record
|
||||
si_signo : longint;
|
||||
@ -325,152 +168,16 @@ type
|
||||
end );
|
||||
end;
|
||||
end;
|
||||
{$endif cpusparc}
|
||||
|
||||
{$ifdef cpux86_64}
|
||||
p_fpstate = ^_fpstate;
|
||||
_fpstate = packed record
|
||||
cwd,
|
||||
swd,
|
||||
twd, // Note this is not the same as the 32bit/x87/FSAVE twd
|
||||
fop : word;
|
||||
rip,
|
||||
rdp : qword;
|
||||
mxcsr,
|
||||
mxcsr_mask : dword;
|
||||
st_space : array[0..31] of dword; // 8*16 bytes for each FP-reg
|
||||
xmm_space : array[0..63] of dword; // 16*16 bytes for each XMM-reg
|
||||
reserved2 : array[0..23] of dword;
|
||||
end;
|
||||
|
||||
PSigContextRec = ^SigContextRec;
|
||||
SigContextRec = packed record
|
||||
__pad00 : array[0..4] of qword;
|
||||
r8,
|
||||
r9,
|
||||
r10,
|
||||
r11,
|
||||
r12,
|
||||
r13,
|
||||
r14,
|
||||
r15,
|
||||
rdi,
|
||||
rsi,
|
||||
rbp,
|
||||
rbx,
|
||||
rdx,
|
||||
rax,
|
||||
rcx,
|
||||
rsp,
|
||||
rip,
|
||||
eflags : qword;
|
||||
cs,
|
||||
gs,
|
||||
fs,
|
||||
__pad0 : word;
|
||||
err,
|
||||
trapno,
|
||||
oldmask,
|
||||
cr2 : qword;
|
||||
fpstate : p_fpstate; // zero when no FPU context */
|
||||
reserved1 : array[0..7] of qword;
|
||||
end;
|
||||
{$endif cpux86_64}
|
||||
|
||||
{$ifdef cpuarm}
|
||||
PSigContextRec = ^SigContextRec;
|
||||
SigContextRec = record
|
||||
trap_no : dword;
|
||||
error_code : dword;
|
||||
oldmask : dword;
|
||||
arm_r0 : dword;
|
||||
arm_r1 : dword;
|
||||
arm_r2 : dword;
|
||||
arm_r3 : dword;
|
||||
arm_r4 : dword;
|
||||
arm_r5 : dword;
|
||||
arm_r6 : dword;
|
||||
arm_r7 : dword;
|
||||
arm_r8 : dword;
|
||||
arm_r9 : dword;
|
||||
arm_r10 : dword;
|
||||
arm_fp : dword;
|
||||
arm_ip : dword;
|
||||
arm_sp : dword;
|
||||
arm_lr : dword;
|
||||
arm_pc : dword;
|
||||
arm_cpsr : dword;
|
||||
fault_address : dword;
|
||||
end;
|
||||
|
||||
{ from include/asm-ppc/signal.h }
|
||||
stack_t = record
|
||||
ss_sp: pointer;
|
||||
ss_flags: longint;
|
||||
ss_size: size_t;
|
||||
end;
|
||||
|
||||
{ from include/asm-arm/ucontext.h }
|
||||
pucontext = ^tucontext;
|
||||
tucontext = record
|
||||
uc_flags : dword;
|
||||
uc_link : pucontext;
|
||||
uc_stack : stack_t;
|
||||
uc_mcontext : SigContextRec;
|
||||
uc_sigmask : sigset_t;
|
||||
end;
|
||||
{$endif cpuarm}
|
||||
|
||||
PSigInfoRec = ^SigInfoRec;
|
||||
SigInfoRec = record
|
||||
si_signo: longint;
|
||||
si_errno: longint;
|
||||
si_code: longint;
|
||||
|
||||
case longint of
|
||||
0:
|
||||
(pad: array[0..SI_PAD_SIZE-1] of longint);
|
||||
1: { kill }
|
||||
( kill: record
|
||||
pid: longint; { sender's pid }
|
||||
uid : longint; { sender's uid }
|
||||
end );
|
||||
2: { POSIX.1b timers }
|
||||
( timer : record
|
||||
timer1 : cardinal;
|
||||
timer2 : cardinal;
|
||||
end );
|
||||
3: { POSIX.1b signals }
|
||||
( rt : record
|
||||
pid : longint; { sender's pid }
|
||||
uid : longint; { sender's uid }
|
||||
sigval : longint;
|
||||
end );
|
||||
4: { SIGCHLD }
|
||||
( sigchld : record
|
||||
pid : longint; { which child }
|
||||
uid : longint; { sender's uid }
|
||||
status : longint; { exit code }
|
||||
utime : timeval;
|
||||
stime : timeval;
|
||||
end );
|
||||
5: { SIGILL, SIGFPE, SIGSEGV, SIGBUS }
|
||||
( sigfault : record
|
||||
addr : pointer;{ faulting insn/memory ref. }
|
||||
end );
|
||||
6:
|
||||
( sigpoll : record
|
||||
band : longint; { POLL_IN, POLL_OUT, POLL_MSG }
|
||||
fd : longint;
|
||||
end );
|
||||
end;
|
||||
{ CPU dependent TSigContext }
|
||||
{$i sighndh.inc}
|
||||
|
||||
type
|
||||
SignalHandler = Procedure(Sig : Longint);cdecl;
|
||||
PSignalHandler = ^SignalHandler;
|
||||
SignalRestorer = Procedure;cdecl;
|
||||
PSignalRestorer = ^SignalRestorer;
|
||||
TSigAction = procedure(Sig: Longint; SigContext: SigContextRec);cdecl;
|
||||
|
||||
SigActionHandler = procedure(sig : longint; SigInfo: PSigInfo; SigContext: PSigContext);cdecl;
|
||||
|
||||
{$ifdef CPUARM}
|
||||
{$define NEWSIGNAL}
|
||||
@ -481,15 +188,7 @@ type
|
||||
{$endif CPUx86_64}
|
||||
|
||||
SigActionRec = packed record // this is temporary for the migration
|
||||
{$ifdef posixworkaround}
|
||||
sa_handler : signalhandler;
|
||||
{$else}
|
||||
Handler : record
|
||||
case byte of
|
||||
0: (Sh: SignalHandler);
|
||||
1: (Sa: TSigAction);
|
||||
end;
|
||||
{$endif}
|
||||
sa_handler : SigActionHandler;
|
||||
{$ifdef NEWSIGNAL}
|
||||
Sa_Flags : cuint;
|
||||
Sa_restorer : SignalRestorer; { Obsolete - Don't use }
|
||||
@ -505,7 +204,12 @@ type
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.22 2004-08-04 19:27:10 florian
|
||||
Revision 1.23 2005-01-30 18:01:15 peter
|
||||
* signal cleanup for linux
|
||||
* sigactionhandler instead of tsigaction for bsds
|
||||
* sigcontext moved to cpu dir
|
||||
|
||||
Revision 1.22 2004/08/04 19:27:10 florian
|
||||
* fixed floating point and integer exception handling on sparc/linux
|
||||
|
||||
Revision 1.21 2004/05/31 09:08:14 peter
|
||||
|
@ -27,8 +27,7 @@ const
|
||||
FPE_FLTSUB = 8;
|
||||
|
||||
|
||||
procedure SignalToRunerror(Sig: longint; siginfo : psiginfo); cdecl;
|
||||
|
||||
procedure SignalToRunerror(sig : longint; SigInfo: PSigInfo; SigContext: PSigContext);cdecl;
|
||||
var
|
||||
res : word;
|
||||
begin
|
||||
@ -61,15 +60,19 @@ begin
|
||||
SIGSEGV :
|
||||
res:=216;
|
||||
end;
|
||||
{ give runtime error at the position where the signal was raised }
|
||||
{ give runtime error at the position where the signal was raised }
|
||||
if res<>0 then
|
||||
HandleError(res);
|
||||
// HandleErrorAddrFrame(res,pointer(SigContext.uc.uc_mcontext.pt_regs^.nip),pointer(SigContext.uc.uc_mcontext.pt_regs^.gpr[1]));
|
||||
HandleErrorAddrFrame(res,pointer(SigContext^.sigc_pc),pointer(SigContext^.sigc_wbuf[SigContext^.sigc_oswins-1].ins[6]));
|
||||
end;
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.5 2004-11-06 22:48:16 florian
|
||||
Revision 1.6 2005-01-30 18:01:15 peter
|
||||
* signal cleanup for linux
|
||||
* sigactionhandler instead of tsigaction for bsds
|
||||
* sigcontext moved to cpu dir
|
||||
|
||||
Revision 1.5 2004/11/06 22:48:16 florian
|
||||
* fixed errno setting in mt sparc/linux mt programs
|
||||
|
||||
Revision 1.4 2004/08/04 19:27:10 florian
|
||||
|
56
rtl/linux/sparc/sighndh.inc
Normal file
56
rtl/linux/sparc/sighndh.inc
Normal file
@ -0,0 +1,56 @@
|
||||
{
|
||||
$Id$
|
||||
This file is part of the Free Pascal run time library.
|
||||
Copyright (c) 1999-2000 by Jonas Maebe,
|
||||
member of the Free Pascal development team.
|
||||
|
||||
TSigContext
|
||||
|
||||
See the file COPYING.FPC, included in this distribution,
|
||||
for details about the copyright.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
**********************************************************************}
|
||||
|
||||
{$packrecords C}
|
||||
|
||||
const
|
||||
__SUNOS_MAXWIN = 31;
|
||||
|
||||
type
|
||||
twbuf = record
|
||||
locals : array[0..7] of longint;
|
||||
ins : array[0..7] of longint;
|
||||
end;
|
||||
|
||||
PSigContext = ^TSigContext;
|
||||
TSigContext = record
|
||||
sigc_onstack, { state to restore }
|
||||
sigc_mask, { sigmask to restore }
|
||||
sigc_sp, { stack pointer }
|
||||
sigc_pc, { program counter }
|
||||
sigc_npc, { next program counter }
|
||||
sigc_psr, { for condition codes etc }
|
||||
sigc_g1, { User uses these two registers }
|
||||
sigc_o0, { within the trampoline code. }
|
||||
{ Now comes information regarding the users window set
|
||||
* at the time of the signal. }
|
||||
sigc_oswins : longint; { outstanding windows }
|
||||
{ stack ptrs for each regwin buf }
|
||||
sigc_spbuf : array[0..__SUNOS_MAXWIN-1] of pchar;
|
||||
{ Windows to restore after signal }
|
||||
sigc_wbuf : array[0..__SUNOS_MAXWIN] of twbuf;
|
||||
end;
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.1 2005-01-30 18:01:15 peter
|
||||
* signal cleanup for linux
|
||||
* sigactionhandler instead of tsigaction for bsds
|
||||
* sigcontext moved to cpu dir
|
||||
|
||||
}
|
||||
|
@ -20,7 +20,7 @@
|
||||
const
|
||||
FPU_All = $7f;
|
||||
|
||||
function GetFPUState(const SigContext : SigContextRec) : word;
|
||||
function GetFPUState(const SigContext : TSigContext) : word;
|
||||
begin
|
||||
if assigned(SigContext.fpstate) then
|
||||
GetfpuState:=SigContext.fpstate^.swd;
|
||||
@ -47,7 +47,7 @@ begin
|
||||
reenable_signal:=geterrno=0;
|
||||
end;
|
||||
|
||||
procedure SignalToRunerror(sig : longint; SigContext: SigContextRec); cdecl;
|
||||
procedure SignalToRunerror(sig : longint; SigInfo: PSigInfo; SigContext: PSigContext); cdecl;
|
||||
var
|
||||
res,fpustate : word;
|
||||
begin
|
||||
@ -58,7 +58,7 @@ procedure SignalToRunerror(sig : longint; SigContext: SigContextRec); cdecl;
|
||||
{ this is not allways necessary but I don't know yet
|
||||
how to tell if it is or not PM }
|
||||
res:=200;
|
||||
fpustate:=GetFPUState(SigContext);
|
||||
fpustate:=GetFPUState(SigContext^);
|
||||
if (FpuState and FPU_All) <> 0 then
|
||||
begin
|
||||
{ first check the more precise options }
|
||||
@ -86,12 +86,17 @@ procedure SignalToRunerror(sig : longint; SigContext: SigContextRec); cdecl;
|
||||
end;
|
||||
reenable_signal(sig);
|
||||
if res<>0 then
|
||||
HandleErrorAddrFrame(res,pointer(SigContext.rip),pointer(SigContext.rbp));
|
||||
HandleErrorAddrFrame(res,pointer(SigContext^.rip),pointer(SigContext^.rbp));
|
||||
end;
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.2 2004-05-01 15:59:17 florian
|
||||
Revision 1.3 2005-01-30 18:01:15 peter
|
||||
* signal cleanup for linux
|
||||
* sigactionhandler instead of tsigaction for bsds
|
||||
* sigcontext moved to cpu dir
|
||||
|
||||
Revision 1.2 2004/05/01 15:59:17 florian
|
||||
* x86_64 exception handling fixed
|
||||
|
||||
Revision 1.1 2004/02/05 01:16:12 florian
|
||||
|
77
rtl/linux/x86_64/sighndh.inc
Normal file
77
rtl/linux/x86_64/sighndh.inc
Normal file
@ -0,0 +1,77 @@
|
||||
{
|
||||
$Id$
|
||||
This file is part of the Free Pascal run time library.
|
||||
Copyright (c) 1999-2000 by Jonas Maebe,
|
||||
member of the Free Pascal development team.
|
||||
|
||||
TSigcontext
|
||||
|
||||
See the file COPYING.FPC, included in this distribution,
|
||||
for details about the copyright.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
**********************************************************************}
|
||||
|
||||
{$packrecords C}
|
||||
|
||||
type
|
||||
Pfpstate = ^Tfpstate;
|
||||
Tfpstate = record
|
||||
cwd,
|
||||
swd,
|
||||
twd, // Note this is not the same as the 32bit/x87/FSAVE twd
|
||||
fop : word;
|
||||
rip,
|
||||
rdp : qword;
|
||||
mxcsr,
|
||||
mxcsr_mask : dword;
|
||||
st_space : array[0..31] of dword; // 8*16 bytes for each FP-reg
|
||||
xmm_space : array[0..63] of dword; // 16*16 bytes for each XMM-reg
|
||||
reserved2 : array[0..23] of dword;
|
||||
end;
|
||||
|
||||
PSigContext = ^TSigContext;
|
||||
TSigContext = record
|
||||
__pad00 : array[0..4] of qword;
|
||||
r8,
|
||||
r9,
|
||||
r10,
|
||||
r11,
|
||||
r12,
|
||||
r13,
|
||||
r14,
|
||||
r15,
|
||||
rdi,
|
||||
rsi,
|
||||
rbp,
|
||||
rbx,
|
||||
rdx,
|
||||
rax,
|
||||
rcx,
|
||||
rsp,
|
||||
rip,
|
||||
eflags : qword;
|
||||
cs,
|
||||
gs,
|
||||
fs,
|
||||
__pad0 : word;
|
||||
err,
|
||||
trapno,
|
||||
oldmask,
|
||||
cr2 : qword;
|
||||
fpstate : Pfpstate; // zero when no FPU context */
|
||||
reserved1 : array[0..7] of qword;
|
||||
end;
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.1 2005-01-30 18:01:15 peter
|
||||
* signal cleanup for linux
|
||||
* sigactionhandler instead of tsigaction for bsds
|
||||
* sigcontext moved to cpu dir
|
||||
|
||||
}
|
||||
|
@ -138,11 +138,7 @@ Function FpSignal(signum:longint;Handler:signalhandler):signalhandler;
|
||||
var sa,osa : sigactionrec;
|
||||
|
||||
begin
|
||||
{$Ifdef BSD}
|
||||
sa.sa_handler:=tsigaction(handler);
|
||||
{$else}
|
||||
sa.sa_handler:=handler;
|
||||
{$endif}
|
||||
sa.sa_handler:=SigActionHandler(handler);
|
||||
FillChar(sa.sa_mask,sizeof(sigset),#0);
|
||||
sa.sa_flags := 0;
|
||||
{ if (sigintr and signum) =0 then
|
||||
@ -160,11 +156,7 @@ begin
|
||||
if fpgetErrNo<>0 then
|
||||
fpsignal:=NIL
|
||||
else
|
||||
{$ifdef BSD}
|
||||
fpsignal:=signalhandler(osa.sa_handler);
|
||||
{$else}
|
||||
fpsignal:=osa.sa_handler;
|
||||
{$endif}
|
||||
end;
|
||||
|
||||
{$ifdef FPC_USE_LIBC} // can't remember why this is the case. Might be legacy.
|
||||
@ -380,7 +372,12 @@ end;
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.16 2004-11-25 12:18:35 jonas
|
||||
Revision 1.17 2005-01-30 18:01:15 peter
|
||||
* signal cleanup for linux
|
||||
* sigactionhandler instead of tsigaction for bsds
|
||||
* sigcontext moved to cpu dir
|
||||
|
||||
Revision 1.16 2004/11/25 12:18:35 jonas
|
||||
* fixed invalid type conversion
|
||||
|
||||
Revision 1.15 2004/11/23 08:40:34 michael
|
||||
|
@ -512,11 +512,7 @@ var
|
||||
|
||||
begin { Changes as above }
|
||||
if command='' then exit(1);
|
||||
{$ifdef FreeBSD}
|
||||
ign.sa_handler:=TSigAction(SIG_IGN);
|
||||
{$else}
|
||||
ign.sa_handler:=SignalHandler(SIG_IGN);
|
||||
{$endif}
|
||||
ign.sa_handler:=SigActionHandler(SIG_IGN);
|
||||
fpsigemptyset(ign.sa_mask);
|
||||
ign.sa_flags:=0;
|
||||
fpsigaction(SIGINT, @ign, @intact);
|
||||
@ -1255,7 +1251,12 @@ End.
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.79 2005-01-22 20:56:11 michael
|
||||
Revision 1.80 2005-01-30 18:01:15 peter
|
||||
* signal cleanup for linux
|
||||
* sigactionhandler instead of tsigaction for bsds
|
||||
* sigcontext moved to cpu dir
|
||||
|
||||
Revision 1.79 2005/01/22 20:56:11 michael
|
||||
+ Patch for intFpExecVEMaybeP to use the right path (From Colin Western)
|
||||
|
||||
Revision 1.78 2004/11/21 11:28:21 peter
|
||||
|
@ -173,7 +173,7 @@
|
||||
fstp %st(1)
|
||||
fclex
|
||||
fldcw -4(%rbp)
|
||||
end ['ECX'];
|
||||
end;
|
||||
|
||||
|
||||
{$define FPC_SYSTEM_HAS_INT}
|
||||
@ -195,7 +195,7 @@
|
||||
frndint
|
||||
fclex
|
||||
fldcw -4(%rbp)
|
||||
end ['ECX'];
|
||||
end;
|
||||
|
||||
|
||||
|
||||
@ -220,8 +220,9 @@
|
||||
fldt d
|
||||
fistpq res
|
||||
movq res,%rax
|
||||
fclex
|
||||
fldcw oldcw
|
||||
end ['RAX','RCX'];
|
||||
end;
|
||||
|
||||
|
||||
{$define FPC_SYSTEM_HAS_ROUND}
|
||||
@ -244,13 +245,15 @@
|
||||
fnstcw oldcw
|
||||
fwait
|
||||
movw $0x1372,newcw
|
||||
fclex
|
||||
fldcw newcw
|
||||
fwait
|
||||
fldt d
|
||||
fistpq res
|
||||
movq res,%rax
|
||||
fclex
|
||||
fldcw oldcw
|
||||
end ['RAX'];
|
||||
end;
|
||||
|
||||
|
||||
{$define FPC_SYSTEM_HAS_POWER}
|
||||
@ -275,7 +278,12 @@
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.6 2004-12-12 14:30:27 peter
|
||||
Revision 1.7 2005-01-30 18:01:15 peter
|
||||
* signal cleanup for linux
|
||||
* sigactionhandler instead of tsigaction for bsds
|
||||
* sigcontext moved to cpu dir
|
||||
|
||||
Revision 1.6 2004/12/12 14:30:27 peter
|
||||
* x86_64 updates
|
||||
|
||||
Revision 1.5 2004/12/12 12:41:46 peter
|
||||
|
Loading…
Reference in New Issue
Block a user