Commit Graph

77 Commits

Author SHA1 Message Date
paul
233004f72b merge r14144 from cpstrnew branch by paul:
call MultiByteToWideChar with dwFlags=0 for UTF8 code page

git-svn-id: trunk@19100 -
2011-09-17 11:56:16 +00:00
paul
2162add8ac merge r14132 from cpstrnew branch by paul:
- a set of rtl changes from AnsiString to RawByteString to various conversion functions
- a test which proves output in cp1251 and cp866 codepages (standard for Russian windows)

git-svn-id: trunk@19093 -
2011-09-17 11:39:13 +00:00
paul
8cc22972a0 merge r13488 from cpstrnew branch by florian except ncgcon.pas which has a difficult merge conflict (code moved to another unit which is not at the branch during the revision):
* first batch of patches to make tcpstr1.pp work

git-svn-id: trunk@19085 -
2011-09-17 11:16:45 +00:00
paul
ae0d732c8f merge r13485 from cpstrnew branch by florian:
* fixed compilation of system unit after last changes

git-svn-id: trunk@19083 -
2011-09-17 11:01:42 +00:00
paul
28627482c5 merge r13483 from cpstrnew branch by florian:
+ Win32Unicode2AnsiMove and Win32Wide2AnsiMove support code page parameter
+ Win32Ansi2UnicodeMove and Win32Ansi2WideMove support code page parameter
+ code page parameter added for several compilerprocs
* unified more code between win32 and win64 (widestring conversion routines

git-svn-id: trunk@19082 -
2011-09-17 10:54:00 +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
50952945e1 * Moved WideString-related code, which is identical for Win32 and Win64, into syswin.inc
* Defined HAS_WIDESTRINGMANAGER for Win32 and Win64, this allows to smartlink away part of generic widestring routines.

git-svn-id: trunk@17963 -
2011-07-08 20:07:51 +00:00
sergei
ea1e44c036 * Hacking TLS callbacks into proper shape, part 2:
- Completely removed DLL_PROCESS_DETACH callback for executables. Reason: 1) it is executed after RTL has been shut down and called ExitProcess(), at which point it is really not a good idea to do the cleanup. 2) In executable (in contrast with DLL) it is just fine to leave remaining resources alone and let OS reclaim them.
* Using 'cvar' for _tls_used and _tls_index to get proper prefixing without $ifdef's.

git-svn-id: trunk@17943 -
2011-07-06 16:43:13 +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
450fd8784b * section specification method changed
git-svn-id: trunk@17907 -
2011-07-01 19:22:12 +00:00
pierre
8e2da253f9 * Index pointer field must be set to correct value in EXECUTABLE as it is used at program launch
git-svn-id: trunk@17897 -
2011-07-01 13:15:00 +00:00
pierre
bffd571f9d * win/sysos.inc: TTlsDirectory, new record type
Used to support TlsCallbacks.

    Tls callback code added inside
    ifdef FPC_USE_TLS_DIRECTORY.
    NOTE: This code needs compiler changes also to work.

  * win/systhread.inc:
    Exec_Tls_callback: Callback for main executable.
    Several new external variables:
    FreePascal_TLS_callback, FreePascal_end_of_TLS_callback
    need to be placed into .CRT$XL* section,
    using  name '.section .CRT$XLFPC __FPC_tls_callbacks'
    extension to be provided by compiler change.
    tls_callbacks : pointer; external name '___crt_xl_start__';
    tls_data_start : pointer; external name '___tls_start__';
    tls_data_end : pointer; external name '___tls_end__';
    provided by linker script.
    tls_index : DWord that will contain the automatic
    TlsIndex generated by executable launch code (not used by
    FPC code, but might be used by code from loaded objects).
    _tls_used: TTlsdirectory record.

  * win32/system.pp and win64/system.pp:
    Code to force loading of _tls_used record.

git-svn-id: trunk@17893 -
2011-07-01 10:40:35 +00:00
pierre
128e2e9cc5 *Dll_entry: Call SysInitMultiThreading to allocate TlsKey if not yet done
git-svn-id: trunk@17892 -
2011-07-01 10:08:40 +00:00
sergei
3a7ac49cc2 - Removed Win32Wide2AnsiMove, using Win32Unicode2AnsiMove for both Unicode-to-ansi and Wide-to-ansi conversions. In general, we don't need two different conversion routines in wideStringManager, as long as they differ only in PWideChar vs PUnicodeChar (these types are identical).
git-svn-id: trunk@17202 -
2011-03-29 05:25:05 +00:00
florian
a0c25dc0f9 - removes Thread_count from the system unit of several OSes: the value of this variable was unpredictable and the hebaviour was not fixable, resolves #18089
git-svn-id: trunk@16472 -
2010-11-28 20:46:50 +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
df19960f41 * simple fix for 16158, avoid crash on duplicate calling of DLL_PROCESS_DETACH
git-svn-id: trunk@15787 -
2010-08-12 15:34:43 +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
florian
cc0d946f16 * fixes bootstrapping with 2.2.4
git-svn-id: trunk@14442 -
2009-12-14 18:51:57 +00:00
florian
7a82669942 * forgotten part of r14432
git-svn-id: trunk@14433 -
2009-12-13 11:18:49 +00:00
florian
c288e6c105 * deallocate thread variables for the main thread as well, as described in #15002
git-svn-id: trunk@14201 -
2009-11-16 19:36:32 +00:00
michael
1cf64c032f * Patch to remove useless process_entry_hook from sven barth
git-svn-id: trunk@14094 -
2009-11-07 10:10:47 +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
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
florian
a8804cf2a6 * unified some win32/win64 code
git-svn-id: trunk@11745 -
2008-09-10 21:25:59 +00:00