From a2be264e116246e64f6342cc0fa80db4a452cf2a Mon Sep 17 00:00:00 2001 From: peter Date: Sun, 2 Dec 2001 17:21:25 +0000 Subject: [PATCH] * merged fixes from 1.0 --- rtl/unix/mouse.pp | 12 ++++-- rtl/win32/signals.pp | 91 +++++++++++++++++++++++++++++++++++++------- rtl/win32/system.pp | 14 +++++-- rtl/win32/win32.inc | 11 ++++-- 4 files changed, 103 insertions(+), 25 deletions(-) diff --git a/rtl/unix/mouse.pp b/rtl/unix/mouse.pp index 2a10a87879..ad1ac808ab 100644 --- a/rtl/unix/mouse.pp +++ b/rtl/unix/mouse.pp @@ -285,6 +285,7 @@ begin end; if (gpm_fs=-2) or (Select(gpm_fs+1,@fds,nil,nil,1)>0) then begin + FillChar(e,SizeOf(e),#0); Gpm_GetSnapshot(e); if e.x>0 then MouseEvent.x:=e.x-1 @@ -309,7 +310,7 @@ begin else MouseEvent.Action:=0; end; - if (gpm_fs<>-2) or (MouseEvent.Action<>0) then + if {(gpm_fs<>-2) or} (MouseEvent.Action<>0) then SysPollMouseEvent:=true else SysPollMouseEvent:=false; @@ -356,14 +357,17 @@ Const ); {$endif} - + Begin - SetMouseDriver(SysMouseDriver); + SetMouseDriver(SysMouseDriver); end. { $Log$ - Revision 1.5 2001-09-22 00:01:43 michael + Revision 1.6 2001-12-02 17:21:25 peter + * merged fixes from 1.0 + + Revision 1.5 2001/09/22 00:01:43 michael + Merged driver support for mouse from fixbranch Revision 1.4 2001/09/17 21:36:31 peter diff --git a/rtl/win32/signals.pp b/rtl/win32/signals.pp index 91f8edb702..dcb8f80ad5 100644 --- a/rtl/win32/signals.pp +++ b/rtl/win32/signals.pp @@ -161,25 +161,78 @@ var const fpucw : word = $1332; + Exception_handler_installed : boolean = false; + MAX_Level = 16; + except_level : byte = 0; +var + except_eip : array[0..Max_level-1] of longint; + except_signal : array[0..Max_level-1] of longint; + reset_fpu : array[0..max_level-1] of boolean; + + + procedure JumpToHandleSignal; + var + res, eip, ebp, sigtype : longint; + begin + asm + pushal + movl (%ebp),%eax + movl %eax,ebp + end; + if except_level>0 then + dec(except_level) + else + exit; + eip:=except_eip[except_level]; + + sigtype:=except_signal[except_level]; + if reset_fpu[except_level] then + asm + fninit + fldcw fpucw + end; + if (sigtype>=SIGABRT) and (sigtype<=SIGMAX) and + (signal_list[sigtype]<>@SIG_DFL) then + begin + res:=signal_list[sigtype](sigtype); + end + else + res:=0; + + if res=0 then + RunError(sigtype) + else + { jump back to old code } + asm + popal + movl eip,%eax + movl %eax,4(%ebp) + ret + end; + end; function Signals_exception_handler(excep :PEXCEPTION_POINTERS) : longint;stdcall; var frame,res : longint; - function CallSignal(error,frame : longint;must_reset_fpu : boolean) : longint; + function CallSignal(sigtype,frame : longint;must_reset_fpu : boolean) : longint; begin - CallSignal:=Exception_Continue_Search; -{$ifdef i386} - if must_reset_fpu then - asm - fninit - fldcw fpucw + if frame=0 then + CallSignal:=Exception_Continue_Search + else + begin + if except_level >= Max_level then + exit; + except_eip[except_level]:=excep^.ContextRecord^.Eip; + except_signal[except_level]:=sigtype; + reset_fpu[except_level]:=must_reset_fpu; + inc(except_level); + dec(excep^.ContextRecord^.Esp,4); + plongint (excep^.ContextRecord^.Esp)^ := excep^.ContextRecord^.Eip; + excep^.ContextRecord^.Eip:=longint(@JumpToHandleSignal); + CallSignal:=Exception_Continue_Execution; + end; -{$endif i386} - if (error>=SIGABRT) and (error<=SIGMAX) and (signal_list[error]<>@SIG_DFL) then - res:=signal_list[error](error); - if res>=0 then - CallSignal:=Exception_Continue_Execution; end; begin @@ -256,6 +309,8 @@ const oldexceptaddr,newexceptaddr : longint; {$endif SYSTEMEXCEPTIONDEBUG} begin + if Exception_handler_installed then + exit; {$ifdef SYSTEMEXCEPTIONDEBUG} asm movl $0,%eax @@ -274,10 +329,13 @@ const writeln(stderr,'Old exception ',hexstr(oldexceptaddr,8), ' new exception ',hexstr(newexceptaddr,8)); {$endif SYSTEMEXCEPTIONDEBUG} + Exception_handler_installed := true; end; procedure remove_exception_handler; begin + if not Exception_handler_installed then + exit; SetUnhandledExceptionFilter(nil); end; @@ -308,6 +366,8 @@ begin signal:=@SIG_ERR; runerror(201); end; + if not Exception_handler_installed then + install_exception_handler; temp := signal_list[sig]; signal_list[sig] := func; signal:=temp; @@ -328,9 +388,12 @@ initialization for i:=SIGABRT to SIGMAX do signal_list[i]:=@SIG_DFL; - install_exception_handler; + + { install_exception_handler; + delay this to first use + as other units also might install their handlers PM } finalization remove_exception_handler; -end. \ No newline at end of file +end. diff --git a/rtl/win32/system.pp b/rtl/win32/system.pp index ccba4b843b..b6d5d090c9 100644 --- a/rtl/win32/system.pp +++ b/rtl/win32/system.pp @@ -117,6 +117,7 @@ const Dll_Thread_Attach_Hook : TDLL_Entry_Hook = nil; Dll_Thread_Detach_Hook : TDLL_Entry_Hook = nil; + implementation { include system independent routines } @@ -339,7 +340,7 @@ end; function GetFileSize(h:longint;p:pointer) : longint; external 'kernel32' name 'GetFileSize'; function CreateFile(name : pointer;access,sharing : longint; - security : pointer;how,attr,template : longint) : longint; + security : PSecurityAttributes;how,attr,template : longint) : longint; external 'kernel32' name 'CreateFileA'; function SetEndOfFile(h : longint) : longbool; external 'kernel32' name 'SetEndOfFile'; @@ -490,6 +491,7 @@ Const Var shflags, oflags,cd : longint; + security : TSecurityAttributes; begin AllowSlash(p); { close first if opened } @@ -559,7 +561,10 @@ begin end; exit; end; - filerec(f).handle:=CreateFile(p,oflags,shflags,nil,cd,FILE_ATTRIBUTE_NORMAL,0); + security.nLength := Sizeof(TSecurityAttributes); + security.bInheritHandle:=true; + security.lpSecurityDescriptor:=nil; + filerec(f).handle:=CreateFile(p,oflags,shflags,@security,cd,FILE_ATTRIBUTE_NORMAL,0); { append mode } if (flags and $100)<>0 then begin @@ -1562,7 +1567,10 @@ end. { $Log$ - Revision 1.21 2001-11-08 16:16:54 florian + Revision 1.22 2001-12-02 17:21:25 peter + * merged fixes from 1.0 + + Revision 1.21 2001/11/08 16:16:54 florian + beginning of variant dispatching Revision 1.20 2001/11/07 13:05:16 michael diff --git a/rtl/win32/win32.inc b/rtl/win32/win32.inc index 889c75235e..e35c1401d1 100644 --- a/rtl/win32/win32.inc +++ b/rtl/win32/win32.inc @@ -85,10 +85,10 @@ type PLPWSTR = ^LPWSTR; PSecurityAttributes = ^TSecurityAttributes; - TSecurityAttributes = record + TSecurityAttributes = packed record nLength : DWORD; lpSecurityDescriptor : Pointer; - bInheritHandle : Boolean; + bInheritHandle : BOOL; end; PProcessInformation = ^TProcessInformation; @@ -120,7 +120,10 @@ type { $Log$ - Revision 1.6 2001-07-30 14:53:17 marco + Revision 1.7 2001-12-02 17:21:25 peter + * merged fixes from 1.0 + + Revision 1.6 2001/07/30 14:53:17 marco * whcar now in system. Revision 1.5 2001/05/02 10:25:23 marco @@ -135,5 +138,5 @@ type Revision 1.2 2000/07/13 11:33:58 michael + removed logs - + }