* signal cleanup for linux

* sigactionhandler instead of tsigaction for bsds
  * sigcontext moved to cpu dir
This commit is contained in:
peter 2005-01-30 18:01:15 +00:00
parent b28fd2f6b9
commit 7fb8c3dfbd
18 changed files with 474 additions and 362 deletions

View File

@ -190,7 +190,7 @@
PSignalHandler = ^SignalHandler; PSignalHandler = ^SignalHandler;
SignalRestorer = Procedure;cdecl; SignalRestorer = Procedure;cdecl;
PSignalRestorer = ^SignalRestorer; 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 SigActionRec = packed record
@ -199,7 +199,7 @@
0: (Sh: SignalHandler; Sa_Flags: longint; Sa_Mask: SigSet); 0: (Sh: SignalHandler; Sa_Flags: longint; Sa_Mask: SigSet);
1: (sa_handler: TSigAction); 1: (sa_handler: TSigAction);
} }
Sa_Handler: TSigAction; Sa_Handler: SigActionHandler;
Sa_Mask: sigset_t; Sa_Mask: sigset_t;
Sa_Flags: cint; Sa_Flags: cint;
end; end;
@ -271,7 +271,12 @@ const
{ {
$Log$ $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 * fixed signal handling under 10.3.2, still have to verify whether it's
backwards compatible backwards compatible

View File

@ -158,7 +158,7 @@ type sigset_t = array[0..3] of Longint;
PSignalHandler = ^SignalHandler; PSignalHandler = ^SignalHandler;
SignalRestorer = Procedure;cdecl; SignalRestorer = Procedure;cdecl;
PSignalRestorer = ^SignalRestorer; 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; TSigset=sigset_t;
sigset=tsigset; sigset=tsigset;
@ -170,7 +170,7 @@ type sigset_t = array[0..3] of Longint;
0: (Sh: SignalHandler); 0: (Sh: SignalHandler);
1: (Sa: TSigAction); 1: (Sa: TSigAction);
end;} end;}
sa_handler : tsigAction; sa_handler : sigActionHandler;
Sa_Flags : Longint; Sa_Flags : Longint;
Sa_Mask : TSigSet; Sa_Mask : TSigSet;
end; end;
@ -196,7 +196,12 @@ const
{ {
$Log$ $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" * tsignalhandler added"
Revision 1.8 2003/10/27 17:12:45 marco Revision 1.8 2003/10/27 17:12:45 marco

View File

@ -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 var
res,fpustate : word; res,fpustate : word;
@ -41,7 +41,12 @@ end;
{ {
$Log$ $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 * signal handling fixed
Revision 1.1 2003/11/21 00:40:06 florian Revision 1.1 2003/11/21 00:40:06 florian

72
rtl/linux/arm/sighndh.inc Normal file
View 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
}

View File

@ -187,7 +187,7 @@ begin
fpseterrno(oerrno); fpseterrno(oerrno);
exit(cuint(-1)); exit(cuint(-1));
End; End;
if oact.sa_handler=signalhandler(SIG_IGN) Then if oact.sa_handler=SigActionhandler(SIG_IGN) Then
Begin Begin
fpsleep:=fpnanosleep(@time_to_sleep, @time_remaining); fpsleep:=fpnanosleep(@time_to_sleep, @time_remaining);
oerrno:=fpgeterrno; oerrno:=fpgeterrno;
@ -565,7 +565,12 @@ end;
{ {
$Log$ $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. * external rework. Mostly done.
Revision 1.13 2004/11/14 12:21:08 marco Revision 1.13 2004/11/14 12:21:08 marco

View File

@ -20,7 +20,7 @@
const const
FPU_All = $7f; FPU_All = $7f;
function GetFPUState(const SigContext : SigContextRec) : longint; function GetFPUState(const SigContext : TSigContext) : longint;
begin begin
if assigned(SigContext.fpstate) then if assigned(SigContext.fpstate) then
GetfpuState:=SigContext.fpstate^.sw; GetfpuState:=SigContext.fpstate^.sw;
@ -32,8 +32,8 @@ begin
{$endif SYSTEM_DEBUG} {$endif SYSTEM_DEBUG}
end; end;
procedure SignalToRunerror(Sig: longint; SigContext: SigContextRec); cdecl;
procedure SignalToRunerror(sig : longint; SigInfo: PSigInfo; SigContext: PSigContext);cdecl;
var var
res,fpustate : word; res,fpustate : word;
begin begin
@ -44,7 +44,7 @@ begin
{ this is not allways necessary but I don't know yet { this is not allways necessary but I don't know yet
how to tell if it is or not PM } how to tell if it is or not PM }
res:=200; res:=200;
fpustate:=GetFPUState(SigContext); fpustate:=GetFPUState(SigContext^);
if (FpuState and FPU_All) <> 0 then if (FpuState and FPU_All) <> 0 then
begin begin
{ first check the more precise options } { first check the more precise options }
@ -70,12 +70,17 @@ begin
end; 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 if res<>0 then
HandleErrorAddrFrame(res,pointer(SigContext.eip),pointer(SigContext.ebp)); HandleErrorAddrFrame(res,pointer(SigContext^.eip),pointer(SigContext^.ebp));
end; end;
{ {
$Log$ $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 * fixed runerror for invalid operation
Revision 1.3 2004/02/05 01:16:12 florian Revision 1.3 2004/02/05 01:16:12 florian

View 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
}

View File

@ -491,7 +491,7 @@ begin
{ all flags and information set to zero } { all flags and information set to zero }
FillChar(act, sizeof(SigActionRec),0); FillChar(act, sizeof(SigActionRec),0);
{ initialize handler } { initialize handler }
act.sa_handler := signalhandler(@SignalToRunError); act.sa_handler := @SignalToRunError;
{$ifdef RTSIGACTION} {$ifdef RTSIGACTION}
act.sa_flags:=SA_SIGINFO act.sa_flags:=SA_SIGINFO
{$ifdef cpux86_64} {$ifdef cpux86_64}
@ -565,7 +565,12 @@ end;
{ {
$Log$ $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 baseunix.signal for CPU using rt_sigaction
* fixed it for x86_64 too * fixed it for x86_64 too

View File

@ -17,8 +17,7 @@
**********************************************************************} **********************************************************************}
procedure SignalToRunerror(Sig: longint; SigContext: PSigContextRec); cdecl; procedure SignalToRunerror(sig : longint; SigInfo: PSigInfo; SigContext: PSigContext);cdecl;
var var
res : word; res : word;
{ fpustate: longint; } { fpustate: longint; }
@ -47,14 +46,19 @@ begin
SIGSEGV : SIGSEGV :
res:=216; res:=216;
end; 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 if res<>0 then
HandleErrorAddrFrame(res,pointer(SigContext^.pt_regs^.nip),pointer(SigContext^.pt_regs^.gpr[1])); HandleErrorAddrFrame(res,pointer(SigContext^.pt_regs^.nip),pointer(SigContext^.pt_regs^.gpr[1]));
end; end;
{ {
$Log$ $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 * re-enable fpu exceptions in signal handler, they're turned off by the
kernel kernel

View 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
}

View File

@ -123,171 +123,14 @@ Const
const const
SI_PAD_SIZE = ((128 div sizeof(longint)) - 3); SI_PAD_SIZE = ((128 div sizeof(longint)) - 3);
type 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 = array[0..wordsinsigset-1] of cint;
sigset_t= SigSet; sigset_t= SigSet;
PSigSet = ^SigSet; PSigSet = ^SigSet;
psigset_t=psigset; psigset_t=psigset;
TSigSet = SigSet; 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; psiginfo = ^tsiginfo;
tsiginfo = record tsiginfo = record
si_signo : longint; si_signo : longint;
@ -325,152 +168,16 @@ type
end ); end );
end; end;
end; end;
{$endif cpusparc}
{$ifdef cpux86_64} { CPU dependent TSigContext }
p_fpstate = ^_fpstate; {$i sighndh.inc}
_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;
type
SignalHandler = Procedure(Sig : Longint);cdecl; SignalHandler = Procedure(Sig : Longint);cdecl;
PSignalHandler = ^SignalHandler; PSignalHandler = ^SignalHandler;
SignalRestorer = Procedure;cdecl; SignalRestorer = Procedure;cdecl;
PSignalRestorer = ^SignalRestorer; PSignalRestorer = ^SignalRestorer;
TSigAction = procedure(Sig: Longint; SigContext: SigContextRec);cdecl; SigActionHandler = procedure(sig : longint; SigInfo: PSigInfo; SigContext: PSigContext);cdecl;
{$ifdef CPUARM} {$ifdef CPUARM}
{$define NEWSIGNAL} {$define NEWSIGNAL}
@ -481,15 +188,7 @@ type
{$endif CPUx86_64} {$endif CPUx86_64}
SigActionRec = packed record // this is temporary for the migration SigActionRec = packed record // this is temporary for the migration
{$ifdef posixworkaround} sa_handler : SigActionHandler;
sa_handler : signalhandler;
{$else}
Handler : record
case byte of
0: (Sh: SignalHandler);
1: (Sa: TSigAction);
end;
{$endif}
{$ifdef NEWSIGNAL} {$ifdef NEWSIGNAL}
Sa_Flags : cuint; Sa_Flags : cuint;
Sa_restorer : SignalRestorer; { Obsolete - Don't use } Sa_restorer : SignalRestorer; { Obsolete - Don't use }
@ -505,7 +204,12 @@ type
{ {
$Log$ $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 * fixed floating point and integer exception handling on sparc/linux
Revision 1.21 2004/05/31 09:08:14 peter Revision 1.21 2004/05/31 09:08:14 peter

View File

@ -27,8 +27,7 @@ const
FPE_FLTSUB = 8; FPE_FLTSUB = 8;
procedure SignalToRunerror(Sig: longint; siginfo : psiginfo); cdecl; procedure SignalToRunerror(sig : longint; SigInfo: PSigInfo; SigContext: PSigContext);cdecl;
var var
res : word; res : word;
begin begin
@ -61,15 +60,19 @@ begin
SIGSEGV : SIGSEGV :
res:=216; res:=216;
end; 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 if res<>0 then
HandleError(res); HandleErrorAddrFrame(res,pointer(SigContext^.sigc_pc),pointer(SigContext^.sigc_wbuf[SigContext^.sigc_oswins-1].ins[6]));
// HandleErrorAddrFrame(res,pointer(SigContext.uc.uc_mcontext.pt_regs^.nip),pointer(SigContext.uc.uc_mcontext.pt_regs^.gpr[1]));
end; end;
{ {
$Log$ $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 * fixed errno setting in mt sparc/linux mt programs
Revision 1.4 2004/08/04 19:27:10 florian Revision 1.4 2004/08/04 19:27:10 florian

View 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
}

View File

@ -20,7 +20,7 @@
const const
FPU_All = $7f; FPU_All = $7f;
function GetFPUState(const SigContext : SigContextRec) : word; function GetFPUState(const SigContext : TSigContext) : word;
begin begin
if assigned(SigContext.fpstate) then if assigned(SigContext.fpstate) then
GetfpuState:=SigContext.fpstate^.swd; GetfpuState:=SigContext.fpstate^.swd;
@ -47,7 +47,7 @@ begin
reenable_signal:=geterrno=0; reenable_signal:=geterrno=0;
end; end;
procedure SignalToRunerror(sig : longint; SigContext: SigContextRec); cdecl; procedure SignalToRunerror(sig : longint; SigInfo: PSigInfo; SigContext: PSigContext); cdecl;
var var
res,fpustate : word; res,fpustate : word;
begin begin
@ -58,7 +58,7 @@ procedure SignalToRunerror(sig : longint; SigContext: SigContextRec); cdecl;
{ this is not allways necessary but I don't know yet { this is not allways necessary but I don't know yet
how to tell if it is or not PM } how to tell if it is or not PM }
res:=200; res:=200;
fpustate:=GetFPUState(SigContext); fpustate:=GetFPUState(SigContext^);
if (FpuState and FPU_All) <> 0 then if (FpuState and FPU_All) <> 0 then
begin begin
{ first check the more precise options } { first check the more precise options }
@ -86,12 +86,17 @@ procedure SignalToRunerror(sig : longint; SigContext: SigContextRec); cdecl;
end; end;
reenable_signal(sig); reenable_signal(sig);
if res<>0 then if res<>0 then
HandleErrorAddrFrame(res,pointer(SigContext.rip),pointer(SigContext.rbp)); HandleErrorAddrFrame(res,pointer(SigContext^.rip),pointer(SigContext^.rbp));
end; end;
{ {
$Log$ $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 * x86_64 exception handling fixed
Revision 1.1 2004/02/05 01:16:12 florian Revision 1.1 2004/02/05 01:16:12 florian

View 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
}

View File

@ -138,11 +138,7 @@ Function FpSignal(signum:longint;Handler:signalhandler):signalhandler;
var sa,osa : sigactionrec; var sa,osa : sigactionrec;
begin begin
{$Ifdef BSD} sa.sa_handler:=SigActionHandler(handler);
sa.sa_handler:=tsigaction(handler);
{$else}
sa.sa_handler:=handler;
{$endif}
FillChar(sa.sa_mask,sizeof(sigset),#0); FillChar(sa.sa_mask,sizeof(sigset),#0);
sa.sa_flags := 0; sa.sa_flags := 0;
{ if (sigintr and signum) =0 then { if (sigintr and signum) =0 then
@ -160,11 +156,7 @@ begin
if fpgetErrNo<>0 then if fpgetErrNo<>0 then
fpsignal:=NIL fpsignal:=NIL
else else
{$ifdef BSD}
fpsignal:=signalhandler(osa.sa_handler); fpsignal:=signalhandler(osa.sa_handler);
{$else}
fpsignal:=osa.sa_handler;
{$endif}
end; end;
{$ifdef FPC_USE_LIBC} // can't remember why this is the case. Might be legacy. {$ifdef FPC_USE_LIBC} // can't remember why this is the case. Might be legacy.
@ -380,7 +372,12 @@ end;
{ {
$Log$ $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 * fixed invalid type conversion
Revision 1.15 2004/11/23 08:40:34 michael Revision 1.15 2004/11/23 08:40:34 michael

View File

@ -512,11 +512,7 @@ var
begin { Changes as above } begin { Changes as above }
if command='' then exit(1); if command='' then exit(1);
{$ifdef FreeBSD} ign.sa_handler:=SigActionHandler(SIG_IGN);
ign.sa_handler:=TSigAction(SIG_IGN);
{$else}
ign.sa_handler:=SignalHandler(SIG_IGN);
{$endif}
fpsigemptyset(ign.sa_mask); fpsigemptyset(ign.sa_mask);
ign.sa_flags:=0; ign.sa_flags:=0;
fpsigaction(SIGINT, @ign, @intact); fpsigaction(SIGINT, @ign, @intact);
@ -1255,7 +1251,12 @@ End.
{ {
$Log$ $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) + Patch for intFpExecVEMaybeP to use the right path (From Colin Western)
Revision 1.78 2004/11/21 11:28:21 peter Revision 1.78 2004/11/21 11:28:21 peter

View File

@ -173,7 +173,7 @@
fstp %st(1) fstp %st(1)
fclex fclex
fldcw -4(%rbp) fldcw -4(%rbp)
end ['ECX']; end;
{$define FPC_SYSTEM_HAS_INT} {$define FPC_SYSTEM_HAS_INT}
@ -195,7 +195,7 @@
frndint frndint
fclex fclex
fldcw -4(%rbp) fldcw -4(%rbp)
end ['ECX']; end;
@ -220,8 +220,9 @@
fldt d fldt d
fistpq res fistpq res
movq res,%rax movq res,%rax
fclex
fldcw oldcw fldcw oldcw
end ['RAX','RCX']; end;
{$define FPC_SYSTEM_HAS_ROUND} {$define FPC_SYSTEM_HAS_ROUND}
@ -244,13 +245,15 @@
fnstcw oldcw fnstcw oldcw
fwait fwait
movw $0x1372,newcw movw $0x1372,newcw
fclex
fldcw newcw fldcw newcw
fwait fwait
fldt d fldt d
fistpq res fistpq res
movq res,%rax movq res,%rax
fclex
fldcw oldcw fldcw oldcw
end ['RAX']; end;
{$define FPC_SYSTEM_HAS_POWER} {$define FPC_SYSTEM_HAS_POWER}
@ -275,7 +278,12 @@
{ {
$Log$ $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 * x86_64 updates
Revision 1.5 2004/12/12 12:41:46 peter Revision 1.5 2004/12/12 12:41:46 peter