Commit Graph

43 Commits

Author SHA1 Message Date
florian
bb8b8f2eae * do not set IsMultithread on windows, if no second thread is started, resolves #30535
git-svn-id: trunk@35567 -
2017-03-11 21:35:48 +00:00
svenbarth
f8b458106e * fix for Mantis #30747: for anonymous events CreateEvent() needs to be called with a Nil parameter for the name, not an empty string
git-svn-id: trunk@34736 -
2016-10-16 19:29:49 +00:00
svenbarth
535621faaa Rename FPC_HAS_INDIRECT_MAIN_INFORMATION to FPC_HAS_INDIRECT_ENTRY_INFORMATION which is more logical considering the record's name
git-svn-id: trunk@33950 -
2016-06-11 20:38:22 +00:00
svenbarth
6afda909d4 Rework TlsKey handling on Windows so that it works as intended with indirect main information
rtl/inc/system.inc:
  * SetupEntryInformation: call new, optional function OSSetupEntryInformation to handle platform specific entry information initialization
rtl/win/sysosh.inc, TEntryInformationOS:
  + new field TlsKeyAddr which will hold the address to the main binary's TlsKey variable
win32/sysinit.inc:
  + provide the variable holding the TlsKey and pass that on to the entry information record
win32/system.pp:
  + new OS specific entry information initialization (currently only the TlsKey)
win/systhrd.inc:
  * declare TlsKey as a pointer to a DWord value instead of a DWord; on non-indirect entry platforms this is initialized with the address of new variable TlsKeyVar, on indirect entry platforms it will be initialized by the entry information initialization
  * adjust usages of TlsKey from DWord to PDWord
win/systlsdir.inc:
  * TlsKey is now a PDWord and (in sysinit) points to TlsKeyVar
win/syswin.inc:
  * adjust TlsKey usage
inc/heaptrc.pp:
  * TlsKey is now a PDWord, thus adjust the import and the usage

git-svn-id: trunk@33091 -
2016-02-12 17:03:52 +00:00
sergei
83deae45b8 * First part of 64-bit Windows fixes from Mantis #23074.
git-svn-id: trunk@26806 -
2014-02-18 02:10:35 +00:00
sergei
179586f589 + SEH support for Win32. Enable by cycling with OPT=-dTEST_WIN32_SEH.
Although basic things work (no regressions in test suite, also with TEST_OPT=-O2), there are some secondary issues/TODOs:
- Exception frame around PASCALMAIN is not properly removed in DLLs
- No stack traces yet
- Stack overallocated in finalizer procedures, their entry/exit code needs cleanup
- Signals unit is probably completely broken.

git-svn-id: trunk@26225 -
2013-12-12 12:43:46 +00:00
sergei
6788fd6433 + Win64 SEH: install a top-level exception handler around thread functions. This was a missing puzzle piece of SEH support. Now behavior of unhandled exceptions in non-main threads is consistent with that of main thread, and, in general, behavior of SEH-enabled RTL is consistent with one without SEH.
git-svn-id: trunk@23482 -
2013-01-21 17:16:15 +00:00
sergei
7969fb4ee1 - Removed TlsSize variable, it duplicates threadvarblocksize.
git-svn-id: trunk@23360 -
2013-01-10 20:13:08 +00:00
pierre
f80bc70707 + Add _FPC_TlsSize public symbol for use by heaptrc unit
git-svn-id: trunk@20180 -
2012-01-26 13:51:34 +00:00
pierre
4a9c8e330b + Move EXEC_callback into separate file win/systlsdir.inc
* In win32/sysinitXX units, rename EntryInforation
    to SysInitEntryInformation.
    include new win/systlsdir.inc file from
    win/syswin.inc for win64 target
    and from win32/sysinit.inc for win32 target.
    Set fields of both SysInitEntryInformation and EntryInformation
    by converting them into typed constants.

git-svn-id: trunk@19779 -
2011-12-08 16:11:07 +00:00
sergei
ef48f93d85 * win/systhrd.inc: modified ThreadMain so it initializes RTL if not already done, allowing TLS callbacks to be optional.
* win/syswin.inc: added a workaround for buggy ld on win64, see comments in source for details.

git-svn-id: trunk@18019 -
2011-07-25 07:41:32 +00:00
sergei
5c3aca5148 * thread.inc, DoneThread: allow CurrentTM.ReleaseThreadVars to be unassigned and reset ThreadID (in preparation to support Windows native threadvars)
* win/systhrd.inc: added error checking in several places. Fail with code 226 if resources cannot be allocated, as Delphi does.
* win/syswin.inc, Dll_entry: Don't call DoneThread in PROCESS_DETACH callback, it is redundant because the main thread is finalized by FPC_DO_EXIT. SysReleaseThreadVars is still necessary. Also removed redundant assignments to return value.

git-svn-id: trunk@17992 -
2011-07-15 23:57:23 +00:00
sergei
02a5efc619 * win/systhrd.inc, clean up:
- removed assembler from SysRelocateThreadVars: never actually worked, and this file is shared between different CPUs - not a proper place for assembler anyway.
- Obtain handle of kernel32.dll using GetModuleHandle, allows to get rid of UnloadLibrary call.

git-svn-id: trunk@17975 -
2011-07-11 17:18:48 +00:00
sergei
138c2b6b0a * Hacking TLS callbacks into proper shape:
- Do not call DLL hooks from exe callback handler.
  - Do not call SysInitMultitheading from DLL_THREAD_ATTACH handler, it may only be called from the main thread. See comments in syswin.inc for details. Reverts rev. 17892.
  + To guarantee that SysInitMultithreading is called from the main thread, assume executables always multithreaded, just like DLLs are.
  - Also removed all checks with MainThreadIdWin32, except checks for double DLL_PROCESS_DETACH in DLLs. They duplicate what Windows already does (the main thread invokes only PROCESS_ATTACH/PROCESS_DETACH and never THREAD_ATTACH/THREAD_DETACH callbacks).
  * Attempts to avoid double initialization/finalization (once in callback, second time in normal control flow).
  * Net result: webtbs/tw2423 and webtbs/tw15530 fixed, webtbs/tw3661 broken (because heaptrc does not support checking pointers in TLS area, and with 'always multithreaded' apps the Output varible moves into TLS).

git-svn-id: trunk@17938 -
2011-07-05 11:57:11 +00:00
pierre
1339c66ec9 * SysAllocateThreadVars: Make sure the data slot is only allocated once
git-svn-id: trunk@17891 -
2011-07-01 10:07:38 +00:00
pierre
0fabda01a8 * Added code to support Windows 95 again
This code is disabled by default, you need to complie the RTL
  with option -dSUPPORT_WIN95.

    2.4.2 release is already not usable on Windows 95 because
  the kernel32 DLL function TryEnterCriticalSection is loaded
  into system unit unconditionnally, while this function does
  not exist in Winddows 95 kernel32.

    This patch uses LoadLibrary/GetProcAddress coupple to check if
  TryEnterCriticalSection exists and provides an alternate implementation
  that will be used on Windows 95 systems only (Windows 98 kernel32
  DLL does export TryEnterCriticalSection).

git-svn-id: trunk@16579 -
2010-12-17 14:12:43 +00:00
michael
cc0be1be4d * Completely initialize threadvars when an external thread is detected. Needs still cleanup code (or a better thread initialization/finalization).
git-svn-id: trunk@16432 -
2010-11-25 15:50:49 +00:00
florian
27ff441975 o patch from Sven Barth:
- remove critical section from dll initialization, windows allows only one thread at one to run dllmain, resolves #17858

git-svn-id: trunk@16263 -
2010-10-30 14:37:55 +00:00
marco
8cce3d3f91 * closethread thread manager field/function. Mantis 13160
git-svn-id: trunk@15072 -
2010-03-26 23:31:52 +00:00
marco
c477df5046 * TCriticalSection.Tryenter support (Mantis 15928) + short test/demo
tested on FreeBSD (general Unix) and Windows. Note that Haiku seems 
    to have a native threadmgr rather than the Unix one. Will notify 
    maintainer (Olivier)

git-svn-id: trunk@15026 -
2010-03-21 11:34:05 +00:00
florian
e6648da567 * make heaptrc aware of the fact that multi threading could be initialized before heaptrc itself is initialized, this is currently the case for windows dlls
git-svn-id: trunk@14560 -
2010-01-07 13:41:43 +00:00
florian
fb07fe5856 * always assume a multithreaded application when using threadvars in dlls, resolves #14992
git-svn-id: trunk@14557 -
2010-01-06 21:26:49 +00:00
michael
12fcb19bf4 * Added comment in SysRelocateThreadVar, not working in Windows Vista
git-svn-id: trunk@13753 -
2009-09-21 09:34:53 +00:00
florian
2f8e263560 * allow only one thread at a time to attach on a dll so the tls slot is allocated properly, resolves #12987
git-svn-id: trunk@13648 -
2009-09-05 13:41:09 +00:00
florian
a8c6d9ec3a * partially reverted 13571, I didn't get it work on W7 x64 in win32 mode
* use $ffffffff to signal an unsed TLSKey, 0 is a valid TLSKey and could be returned by Windows in theory

git-svn-id: trunk@13608 -
2009-08-29 20:46:06 +00:00
florian
d3d3596cd6 * accelerated/fixed TLS access on win32 by Pierre Muller
git-svn-id: trunk@13571 -
2009-08-21 09:15:11 +00:00
florian
380f3ac78f * fix from Nikolay Samofatov for #12987: initialize thread vars in libraries on windows correctly
* unified dll entry code between win32 and win64

git-svn-id: trunk@13445 -
2009-07-25 21:08:36 +00:00
yury
3b32571557 * Fixed compilation for win64. ThreadID is DWORD on both win32 and win64.
git-svn-id: trunk@13235 -
2009-06-05 14:59:42 +00:00
florian
88f6b8854e * proper error handling in case of thread creation failure on windows, resolves #13768, no test case due because such a test is too sensitive regarding race conditions etc. and might cause false failures
git-svn-id: trunk@13222 -
2009-06-01 14:17:01 +00:00
florian
6c5471f324 * don't destroy LastError when resolving a threadvar on windows, resolves #10205 (?)
git-svn-id: trunk@10621 -
2008-04-09 21:27:11 +00:00
florian
ecc45e16db * formatting fixed ;)
git-svn-id: trunk@8613 -
2007-09-23 13:09:24 +00:00
micha
7f2a257102 + heap manager now per thread, reduce heap lock contention
+ heap threading test

git-svn-id: trunk@7407 -
2007-05-20 20:58:12 +00:00
micha
702685717f * cleanup of rtlevents, remove startwait due to persistance guarantee
git-svn-id: trunk@5854 -
2007-01-08 19:11:07 +00:00
yury
ff37ef8786 * fixed i386-wince support. WinCE API functions are cdecl.
git-svn-id: trunk@5741 -
2006-12-29 20:49:03 +00:00
michael
d4c30020ee Fix to be able to allocate threadvars when non-rtl code creates a new thread
git-svn-id: trunk@5475 -
2006-11-25 14:59:40 +00:00
yury
e062922528 * added an option to use target-specific memory manager instead of standard. This is controlled by HAS_MEMORYMANAGER and HAS_MT_MEMORYMANAGER defines.
* wince executables use C memory manager now (as all apps compiled by eVC++). It saves 5.5 KB of exe size.

git-svn-id: trunk@4282 -
2006-07-23 10:23:31 +00:00
yury
11576fd24b * fixed warnings and notes while compiling system unit for wince.
git-svn-id: trunk@4250 -
2006-07-18 15:00:09 +00:00
florian
33baacbe04 * fixed leaking of TThread
git-svn-id: trunk@3519 -
2006-05-14 09:15:09 +00:00
yury
398b31226b * Fixed threadvars alignment for ARM CPU.
git-svn-id: trunk@1036 -
2005-09-02 11:58:19 +00:00
florian
0a58f18502 * from Yury Sidorov:
+ Added new target WinCE for i386 (to be able compile and run programs in WinCE emulator)
  + Exceptions work now.
  * System unit seems to be fully working

git-svn-id: trunk@597 -
2005-07-09 09:33:07 +00:00
florian
8adc1c9b0c + RTL part of WinCE patches from Yuri Sidorov
git-svn-id: trunk@572 -
2005-07-03 15:52:27 +00:00
michael
859bb30daa + Removed HASTHREADVAR SUPPORT_THREADVAR defines
git-svn-id: trunk@295 -
2005-06-09 17:40:29 +00:00
florian
ad3b9b9464 * windows rtl restructuring to share code between win32 and win64
* BeginThread can take a qword on 64 bit targets as stacksize

git-svn-id: trunk@287 -
2005-06-08 19:08:49 +00:00