From 167ee9867ecee62dbe2f0e6c6b62475fe028b1e3 Mon Sep 17 00:00:00 2001 From: sergei Date: Thu, 16 Feb 2012 17:13:32 +0000 Subject: [PATCH] * Moved DLL_xxx declarations to sysos.inc, so they can be reused by wince. * systlsdir.inc: don't invent own symbols for the same purpose, defining DLL_xx conditionally is enough to avoid duplicate declarations. git-svn-id: trunk@20363 - --- rtl/win/sysos.inc | 6 ++++++ rtl/win/systlsdir.inc | 27 ++++++++++++--------------- rtl/win/syswin.inc | 4 ---- rtl/wince/system.pp | 7 ------- 4 files changed, 18 insertions(+), 26 deletions(-) diff --git a/rtl/win/sysos.inc b/rtl/win/sysos.inc index 7dd3d305bb..2c5068a7f9 100644 --- a/rtl/win/sysos.inc +++ b/rtl/win/sysos.inc @@ -63,6 +63,12 @@ const VER_PLATFORM_WIN32_WINDOWS = 1; VER_PLATFORM_WIN32_NT = 2; + { DllEntryPoint } + DLL_PROCESS_ATTACH = 1; + DLL_THREAD_ATTACH = 2; + DLL_PROCESS_DETACH = 0; + DLL_THREAD_DETACH = 3; + { These constants are used for conversion of error codes } { from win32 i/o errors to tp i/o errors } { errors 1 to 18 are the same as in Turbo Pascal } diff --git a/rtl/win/systlsdir.inc b/rtl/win/systlsdir.inc index 5e449f47f3..91cb58d38f 100644 --- a/rtl/win/systlsdir.inc +++ b/rtl/win/systlsdir.inc @@ -20,16 +20,13 @@ { Process TLS callback function } { This is only useful for executables for DLLs, DLL_Entry gets called. PM } -{ The consts are the same as for DDL_Entry, - but as this file can be either in system unit or sysinitXXX - we need to rename them with EXEC prefix - to avoid duplicate entries. } -Const - EXEC_PROCESS_ATTACH = 1; - EXEC_THREAD_ATTACH = 2; - EXEC_PROCESS_DETACH = 0; - EXEC_THREAD_DETACH = 3; {$ifdef FPC_INSSIDE_SYSINIT} +Const + DLL_PROCESS_ATTACH = 1; + DLL_THREAD_ATTACH = 2; + DLL_PROCESS_DETACH = 0; + DLL_THREAD_DETACH = 3; + var TlsKey : dword; external name '_FPC_TlsKey'; @@ -56,11 +53,11 @@ procedure Exec_Tls_callback(Handle : pointer; reason : Dword; Reserved : pointer if IsLibrary then Exit; case reason of - { For executables, EXEC_PROCESS_ATTACH is called *before* the entry point, - and EXEC_PROCESS_DETACH is called *after* RTL shuts down and calls ExitProcess. + { For executables, DLL_PROCESS_ATTACH is called *before* the entry point, + and DLL_PROCESS_DETACH is called *after* RTL shuts down and calls ExitProcess. It isn't a good idea to handle resources of the main thread at these points. InitSystemThreads is necessary however, because if some statically loaded - DLL creates a thread, it will invoke EXEC_THREAD_ATTACH before anything else is + DLL creates a thread, it will invoke DLL_THREAD_ATTACH before anything else is initialized. TODO: The problem is that InitSystemThreads depends (in case of Win32) on EntryInformation which is not available at this point. @@ -68,13 +65,13 @@ procedure Exec_Tls_callback(Handle : pointer; reason : Dword; Reserved : pointer to sysinit unit or something like that. Exec_Tls_Callback is now part of sysinit unit for win32 and the EntryInformation is a constant which sholud prevent troubles } - EXEC_PROCESS_ATTACH: + DLL_PROCESS_ATTACH: begin InitHeap; InitSystemThreads; end; - EXEC_THREAD_ATTACH : + DLL_THREAD_ATTACH : begin { !!! SysInitMultithreading must NOT be called here. Windows guarantees that the main thread invokes PROCESS_ATTACH, not THREAD_ATTACH. So this always @@ -92,7 +89,7 @@ procedure Exec_Tls_callback(Handle : pointer; reason : Dword; Reserved : pointer { passing a dummy is ok, the correct value is read from the coff header of SysInstance (FK) } InitThread($1000000); { Assume everything is idempotent there, as the thread could have been created with BeginThread... } end; - EXEC_THREAD_DETACH : + DLL_THREAD_DETACH : begin if TlsGetValue(TLSKey)<>nil then DoneThread; { Assume everything is idempotent there } diff --git a/rtl/win/syswin.inc b/rtl/win/syswin.inc index 7639d754fa..aec39588d7 100644 --- a/rtl/win/syswin.inc +++ b/rtl/win/syswin.inc @@ -247,10 +247,6 @@ const Const - DLL_PROCESS_ATTACH = 1; - DLL_THREAD_ATTACH = 2; - DLL_PROCESS_DETACH = 0; - DLL_THREAD_DETACH = 3; DLLExitOK : boolean = true; Var DLLBuf : Jmp_buf; diff --git a/rtl/wince/system.pp b/rtl/wince/system.pp index b5bb046e14..ba362bbb1e 100644 --- a/rtl/wince/system.pp +++ b/rtl/wince/system.pp @@ -848,13 +848,6 @@ var _SS : Cardinal; {$endif cpu386} -Const - { DllEntryPoint } - DLL_PROCESS_ATTACH = 1; - DLL_THREAD_ATTACH = 2; - DLL_PROCESS_DETACH = 0; - DLL_THREAD_DETACH = 3; - function Dll_entry : longbool;[public, alias : '_FPC_DLL_Entry']; begin IsLibrary:=true;