Commit Graph

66 Commits

Author SHA1 Message Date
ondrej
c4dd3b661a * rtl: implement TRandomGenerator for thread-safe random
git-svn-id: trunk@47598 -
2020-11-26 05:59:00 +00:00
yury
187cc46b32 * Windows: Do not use CommandLineToArgvW for parsing command line parameters, because it treats \" as an escape sequence for the double quote.
- Implemented parsing of the command line which is backward compatible.
  - Do not use GetCommandLineA.

git-svn-id: trunk@45227 -
2020-05-02 18:19:26 +00:00
svenbarth
68d743a83e * fix for Mantis #36941: apply (adjusted) patch by Bi0T1N to implement SetThreadDebugNameA and -U for Windows, with the exception of Windows CE
git-svn-id: trunk@45206 -
2020-05-01 13:10:54 +00:00
yury
8d95da3fea * Windows: Reworked handling of command line arguments to properly support Unicode:
- Use the CommandLineToArgvW API function to parse the Unicode command line (we can use it since Win9x is not supported anymore).
  - Implemented non-public functions ParamStrA and ParamStrU which are exposed in the objpas and uuchar units to provide correct AnsiString and UnicodeString versions of ParamStr(). 
  - The cleanup code is moved from InternalExit to the finalization section of the System unit.

git-svn-id: trunk@45037 -
2020-04-23 12:38:42 +00:00
svenbarth
7a0a1d9f36 * fix for Mantis #36544: provide an overall exception handler for the library startup code in case of unhandled exceptions (the loading of the library is considered failed in that case) when SEH is active
+ added test

git-svn-id: trunk@43901 -
2020-01-10 15:39:20 +00:00
svenbarth
2e259ee3cc * the VMT of the exception class needs to be referenced indirectly
git-svn-id: trunk@43543 -
2019-11-21 21:44:48 +00:00
marco
f5e684067d * turn off MB_PRECOMPOSED for encodings named in MSDN multibytetowidechar function, as detailed by Aserge in https://forum.lazarus.freepascal.org/index.php?topic=45380.0;topicseen
git-svn-id: trunk@42043 -
2019-05-12 14:18:36 +00:00
florian
b421ed0db1 * fixed TranslateMxcsr
+ correctly handle sse exceptions on i386, resolves #32671
+ test

git-svn-id: trunk@38268 -
2018-02-17 15:40:49 +00:00
Tomas Hajny
e5ceb04725 * patch by Dmitry Boyarintsev (bug #31023) implementing SysSetCtrlBreakHandler for Win32 and Win64
git-svn-id: trunk@35050 -
2016-12-03 23:35:20 +00:00
svenbarth
3f45860cf9 Use constref instead of const when passing TEntryInformation along
git-svn-id: trunk@33951 -
2016-06-11 20:45:47 +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
788393c298 Change WideString initialization to work correctly with indirect main information as well
rtl/inc/systemh.inc & rtl/java/jsystemh_types.inc:
  - TEntryInformation: remove WideInitTables
rtl/win/sysosh.inc:
  + TEntyrInformationOS: add WideInitTables
rtl/win/syswin.inc:
  * adjust WStrInitTablesTable, so that it is now a pointer and can be used both with direct and indirect main entry
  * InitWin32Widestrings: WStrInitTablesTable is now a pointer
rtl/win32/sysinit.inc:
  * WideInitTables has moved to the OS specific part of the entry information
rtl/win32/system.pp:
  * OsSetupEntryinformation: setup WStrInitTablesTable

git-svn-id: trunk@33571 -
2016-04-29 13:13:14 +00:00
Tomas Hajny
92d045c483 * GetStdHandle returns a THandle (use of longint was not 64-bit safe)
git-svn-id: trunk@33460 -
2016-04-10 01:26:30 +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
svenbarth
e3060130a4 Adjustments so that the resource string related tables are provided inside the system unit (both for indirect and direct entry targets).
rtl/inc/system.inc:
  + new variables that hold pointers to the tables
  + new procedure SetupEntryInformation() that should be used in the entry points of indirect entry targets to setup cross target fields
  + for direct entry targets the two resource string tables are imported here and supplied as initialization to the table pointers
objpas/objpas.pp:
  * adjust table declarations so that the pointers provided from the System unit are used
  * adjust usages of the tables as they are now pointers
win32/system.pp:
  * Exe_Entry: use SetupEntryInformation()
win/syswin.inc:
  * Dll_Entry: use SetupEntryInformation()

git-svn-id: trunk@33028 -
2016-01-29 17:19:33 +00:00
pierre
260c6583cf Only set StdInputHandle, StdOutputHandle and StdErrorHandle once
git-svn-id: trunk@29094 -
2014-11-20 21:57:15 +00:00
michael
d5a88caecd * Do not display error message if NoErrMsg is set.
git-svn-id: trunk@27765 -
2014-05-11 10:19:04 +00:00
nickysn
fb20791cbe * replaced all the remaining uses of nativeint in the rtl with either sizeint
or objpasint

git-svn-id: trunk@27237 -
2014-03-23 13:38:16 +00:00
sergei
e79e038f9c + Win32/Win64 SEH: STATUS_FLOAT_MULTIPLE_(FAULTS|TRAPS) need additional handling. Makes floating-point exceptions consistent between x87 and SSE.
git-svn-id: trunk@27177 -
2014-03-17 22:49:29 +00:00
nickysn
5242ed7864 * changed TResStrInitTable.Count and TWStrInitTablesTable.Count to nativeint
git-svn-id: trunk@26921 -
2014-03-02 13:27:59 +00:00
sergei
1f22c2de22 - Text i/o routines are not expected to return a value.
git-svn-id: trunk@26834 -
2014-02-22 13:42:41 +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
Jonas Maebe
d1b2a5f362 * changed the initial value DefaultFileSystemCodePage from CP_ACP to CP_UTF8:
o since we always use UTF-16 for OS file API calls, this will only affect
     possible intermediate code page conversions inside RTL routines and hence
     prevent potential data loss. This was already the same for NativeNT and
     WinCE, which are in the same boat
   o DefaultRTLFileSystemCodePage, which specifies the code page used to return
     strings from single byte RTL routines, remains CP_ACP and hence nothing
     will change as far as programs using the RTL are concerned

git-svn-id: trunk@26377 -
2014-01-04 15:05:42 +00:00
sergei
04c0845189 * Moved more reusable exception handling code from seh64.inc to syswin.inc.
* sysutils.pp: Install ExceptObjProc and ExceptClsProc also on Win32.

git-svn-id: trunk@26181 -
2013-12-04 14:02:54 +00:00
sergei
6a40ff730c * In preparation to support SEH on Win32, moved definitions that apply to Win32 from seh64.inc into syswin.inc.
git-svn-id: trunk@26153 -
2013-11-29 14:23:46 +00:00
Jonas Maebe
598d2feeb6 + rtldefs.inc file for every target that contains defines shared by multiple
RTL units. Comes with a FPCRTL_FILESYSTEM_UTF8 define that can be
    activated for targets whose single byte filesystem interface enforces
    UTF-8; included in inc/systemh.inc and unix/cwstring.pp until now
  + DefaultFileSystemCodePage variable that holds the code page used for
    communicating with the OS single byte file system APIs, and for the
    strings returned by those same APIs. Initialized with
   o the result of GetACP in the system unit of Windows platforms, except for
     WinCE which uses UTF-8 since its file system OS API calls already use
     the UTF-16 versions
   o CP_UTF8 on Unix platforms with FPCRTL_FILESYSTEM_UTF8 defined, and with
     DefaultSystemCodePage on other Unix platforms
   o DefaultSystemCodePage on Java/Android JVM targets
  + DefaultRTLFileSystemCodePage variable that holds the code page used to
    encode strings returned by RTL routines that return filenames obtained
    from OS API calls. By default the same as DefaultFileSystemCodePage on
    all platforms. Separate from DefaultFileSystemCodePage for clarity on
    platforms that may use either utf-16 or single byte OS API calls to
    send/receive file names (such as most Windows platforms)
  + new scpFileSystemSingleByte enum that can be passed to
    GetStandardCodePage() to get the default code page for OS single byte file
    system APIs, with implementations for Unix and Windows
  + SetMultiByteFileSystemCodePage() procedure to override the value of
    DefaultFileSystemCodePage

  In principle, in the long run unchanged programs only using generic
  ansistrings and unicodestrings should (mostly) behave the same as in
  FPC 2.6.0 as far as RTL-level file system APIs are concerned if
  they set DefaultFileSystemCodePage and DefaultRTLFileSystemCodePage
  to DefaultSystemCodePage at the start of their execution

git-svn-id: branches/cpstrrtl@22466 -
2012-09-27 07:54:06 +00:00
sergei
cd44c5f45c Win32 and Win64, fixed DLL exit sequence, resolves #14603:
* Unwind to DllEntry context only if called from DllEntry. Otherwise, terminate the entire process, making sure that RTL won't be finalized twice.
* Call DLL_process_detach_hook before RTL is finalized, not after.

git-svn-id: trunk@20367 -
2012-02-16 23:39:03 +00:00
sergei
167ee9867e * 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 -
2012-02-16 17:13:32 +00:00
sergei
ebb2205c63 * Moved TExceptionRecord definition to sysos.inc, it is identical for all Windows targets.
git-svn-id: trunk@19868 -
2011-12-18 00:45:52 +00:00
sergei
76b9d7e766 - Removed Win32Wide2AnsiMove() again, it was removed already in r17202 but got restored during subsequent cpstrnew merging.
git-svn-id: trunk@19781 -
2011-12-08 21:28:12 +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
37abdd52df * Reverted r19693, calling SysInitMultithreading from PROCESS_ATTACH is plain wrong because it depends on initialized thread manager. Calling InitSystemThreads is more correct, but in case of Win32 it further depends on EnrtyInformation, which is not available at this point. Properly solving the issue requires moving the entire TLS stuff into sysinit units or something like that.
git-svn-id: trunk@19715 -
2011-11-30 15:14:00 +00:00
sergei
266acd1bed * Windows TLS callbacks, call SysInitMultithreading early, it is necessary because if a statically loaded DLL creates a thread, apparently DLL_THREAD_ATTACH callback executes right away before the entry point. In turn, DLL_THREAD_ATTACH requires TLSIndex to be initialized.
git-svn-id: trunk@19693 -
2011-11-26 20:52:27 +00:00
paul
270fb09e87 rtl: add WideStringManager.GetStandardCodePageProc method to retrieve system ansi and console code pages
git-svn-id: trunk@19539 -
2011-10-25 01:39:11 +00:00
paul
5bf39cd1c1 rtl: remove ver2_2 define
git-svn-id: trunk@19471 -
2011-10-12 01:55:46 +00:00
paul
836889fc64 rtl: move some CP_xxx constants from syswin into systemh for generic use, redeclare UTF8Sting, RawByteString using constant identifiers instead of pure numbers. replace comparison with $ffff codepage to CP_NONE
git-svn-id: trunk@19354 -
2011-10-04 05:05:14 +00:00
pierre
7e87ca4c3c * Comment about mingw tlssup.c added
git-svn-id: trunk@19349 -
2011-10-03 22:03:02 +00:00
sergei
ad5d2ccabb * Moved command line handling and randomize() to syswin.inc, so a single copy of code is used for both win32 and win64. This implies that apostrophe is no longer supported as quoting symbol in win64.
Win64 doesn't support it itself either.

git-svn-id: trunk@19201 -
2011-09-23 21:45:02 +00:00
sergei
f35a8179b1 * Status codes are identical for win32 and win64, moved them to syswin.inc.
git-svn-id: trunk@19160 -
2011-09-20 15:01:22 +00:00
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