Commit Graph

47 Commits

Author SHA1 Message Date
Michael VAN CANNEYT
706e090457 * Char -> AnsiChar 2023-07-14 17:26:10 +02: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
Tomas Hajny
dff7cb3c3c * added missing error constant
git-svn-id: trunk@29808 -
2015-02-23 11:19:50 +00:00
Tomas Hajny
b9f88aa80c * mapping of I/O error number 206 having different meaning in FPC to RTE 3
git-svn-id: trunk@29797 -
2015-02-22 22:25:44 +00:00
marco
8e2f8d7f3c * for wince use getprocessaddresa, mantis #27450
git-svn-id: trunk@29684 -
2015-02-13 10:23:05 +00:00
svenbarth
2d454dc8fa Move DynLibs support to System unit using a manager approach like for Threads, WideStrings, etc.. This is needed so that we can support features like "delayed" and loading of dynamic packages.
Each port that allows the usage of dynamic libraries should call InitSystemDynLibs during initialization of the System unit.
The DynLibs unit has been adjusted to be a forwarder for the functions that now reside in the System unit (for backwards compatiblity just in case). Additionally the unit will register the DynLibsManager if it doesn't reside in the System unit anyway.
Currently only the Windows targets (Win32, Win64 and WinCE) implement the DynLibsManager inside the System unit. For other systems using the LoadLibrary, etc. functions will lead to a run error/exception.
If a port wants to implement its own DynLibsManager then it needs to define DISABLE_NO_DYNLIBS_MANAGER. TLibHandle, NilHandle and optionally TOrdinalEntry (it's set to SizeUInt otherwise) should be defined in sysdlh.inc which needs to be enabled using the define FPC_SYSTEM_HAS_SYSDLH (because there are targets which have FEATURE_DYNLIBS enabled, but don't support them... e.g. powerpc-wii -.-).
The DynLibsManager contains methods for loading a library based on a RawByteString and based on a UnicodeString. BOTH should be implemented, but internally one can forward to the other.
The loading by ordinal *can* be be implemented. If it is set to Nil then the implementation of GetProcAddress(lib,ordinal) will return Nil.

+ new functions SetDynLibsManager and GetDynLibsManager to set and retrieve the current DynLibsManager
* provide interface of DynLibs unit in unit System

git-svn-id: trunk@29613 -
2015-02-03 20:00:00 +00:00
svenbarth
b79e7ce1f9 Implement GetCPUCount for Windows OSes. This is for all three Windows targets.
rtl/win/sysos.inc:
  + add definition of TSystemInfo structure
  + add import of GetSystemInfo
  + add implementation of GetCPUCount which returns value for number of processors retrieved by GetSystemInfo

git-svn-id: trunk@28643 -
2014-09-12 18:40:59 +00:00
sergei
c83f4c5ddc * Windows targets: removed 'errno' threadvar, OS error codes can be passed directly to Errno2InOutRes().
git-svn-id: trunk@26815 -
2014-02-19 07:28:46 +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
Tomas Hajny
3e5601d89e * fix ChDir and GetDir handling for other than the current drive and avoid changing the current directory in GetDir in that case
git-svn-id: trunk@25541 -
2013-09-23 20:41:54 +00:00
Jonas Maebe
63e8d0c31c * do not yet map GetCommandLine() to GetCommandLineW() with -dFPC_UNICODE_RTL,
because its result is assigned to the global cmdline variable which is still
    a pchar in all cases

git-svn-id: branches/cpstrrtl@25309 -
2013-08-19 22:47:15 +00:00
Jonas Maebe
df6a2dce00 + unicodestring support for assign/erase/rename
+ codepage support for textrec/filerec and the above routines
  * textrec/filerec now store the filename by default using widechar. It is
    possible to switch back to ansichars using the FPC_ANSI_TEXTFILEREC define.
    In that case, from now on the filename will always be stored in
    DefaultFileSystemEncoding
  * fixed potential buffer overflows and non-null-terminated file names in
    textrec/filerec
  + dodirseparators(pwidechar), changed the dodirseparators(pchar/pwidechar)
    parameters into var-parameters and gave those routines an extra parameter
    that indicates whether the p(wide)char can be changed in place if
    necessary or whether a copy must be made first (avoids us having to make
    all strings always unique everywhere, because they might be changed on
    some platforms via a pchar)
  * do_open/do_erase/do_rename got extra boolean parameters indicating whether
    the passed pchars point to data that can be freely changed (to pass on to
    dodirseparators() if applicable)
  * objects.pp: force assign(pchar) to be called, because
    assign(array[0..255]) cannot choose between pchar and rawbytestring
    versions (and removing the pchar version means that assign(pchar) will
    be mapped to assign(shortstring) in {$h-})
  * fixed up some routines in other units that depend on the format of
    the textrec/filerec.name field

git-svn-id: branches/cpstrrtl@25137 -
2013-07-19 16:30:51 +00:00
Jonas Maebe
a5273abc9c + support for CP_OEMCP
* changed all mappings from CP_ACP to DefaultSystemCodePage to calls to the
    new TranslatePlaceholderCP() routine (which also handles CP_OEMCP)
  * removed unnecessary CP_ACP adaptations in fpc_AnsiStr_Concat_multi()
    for JVM target (now handled in the ansistring to unicodestring conversion
    routine)

git-svn-id: branches/cpstrrtl@25091 -
2013-07-12 17:18:24 +00:00
Jonas Maebe
d66d15aad3 + added mkdir/chdir/rmdir(rawbytestring) and (unicodestring) to the system unit
* renamed platform-specific pchar versions of those rouines to do_*() and
    changed them to either rawbytestring or unicodestring depending on the
    FPCRTL_FILESYSTEM_SINGLE_BYTE_API/FPCRTL_FILESYSTEM_TWO_BYTE_API setting
  * implemented generic shortstring versions of those routines on top of either
    rawbytestring or unicodestring depending on the API-kind (in case of the
    embedded target, if ansistring are not supported they will map directly
    to shortstring routines instead)
  * all platform-specific *dir() routines with rawbytestring parameters now
    receive their parameters in DefaultFileSystemCodePage
  - removed no longer required ansistring variants from the objpas unit
  - removed no longer required FPC_SYS_MKDIR etc aliases
  * factored out empty string and inoutres<>0 checks from platform-specific
    *dir() routines to generic ones
  o platform-specific notes:
   o amiga/morphos: check new pathconv(rawbytestring) function
   o macos TODO: convert PathArgToFSSpec (and the routines it calls) to
     rawbytestring
   o nativent: added SysUnicodeStringToNtStr() function
   o wii: convert dirio callbacks to use rawbytestring to avoid conversion
  + test for unicode mk/ch/rm/getdir()

git-svn-id: branches/cpstrrtl@25048 -
2013-07-04 22:28:37 +00:00
Jonas Maebe
08ab4dcabe * convert calls to GetCurrentDirectory to *W in Windows do_getdir()
git-svn-id: branches/cpstrrtl@25042 -
2013-07-04 22:28:13 +00:00
Jonas Maebe
62ee16278b * changed getdir(ansistring):ansistring to
getdir(rawbytestring):rawbytestring so it can accept strings in any
    encoding and cleanly return results in DefaultRTLFileSystemCodePage
  + getdir(unicodestring):unicodestring
  * renamed the getdir implementation of all platforms except for embedded-
    without-ansistring-support to do_getdir(), and depending on the
    FPCRTL_FILESYSTEM_SINGLE_BYTE_API/FPCRTL_FILESYSTEM_TWO_BYTE_API define
    changed its shortstring parameter to ansistring or unicodestring. The
    do_getdir(rawbytestring) routine should just set the code page of the
    return value to DefaultFileSystemCodePage without conversion (not
    DefaultRTLFileSystemCodePage with conversion, that conversion is performed
    in getdir if necessary; this avoids double conversions in case
    getdir(unicodestring) is called)
  + generic getdir(shortstring) for platforms supporting either ansistrings or widestrings
  o platform maintainers:
   o OS/2: adjust code to supports paths > 255 characters if those are supported
   o Wii: adjust used callback to use rawbytestring to support paths > 255 characters and
     avoid shortstring->rawbytestring conversion overhead
   o Windows: GetCurrentDirectoryW is now always used (to prevent data loss)

git-svn-id: branches/cpstrrtl@24993 -
2013-06-27 21:37:47 +00:00
marco
e57174a14f * defined -W versions for several -A functions under ifdef FPC_UNICODE_RTL
git-svn-id: trunk@24644 -
2013-05-30 15:47:41 +00:00
svenbarth
930b76e8fb Fix compilation of WinCE. Change the fixed UNICODE define of WinCE to FPC_OS_UNICODE, so that it won't be undefined when changing the mode/string type and that the usage of a UNICODE API is independant of the mode.
Also adjusted all Windows (Win32/64/CE) units to define a "UNICODE" if "FPC_OS_UNICODE" is defined (except the Jedi units).
Also the common RTL units that checked for UNICODE now check for FPC_OS_UNICODE.

git-svn-id: trunk@24420 -
2013-05-04 11:06:32 +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
c3b106fde3 * StringToOleStr(UnicodeString), reduced to single SetString call, this way it does not depend on private functions and does not require $ifdef's.
git-svn-id: trunk@20263 -
2012-02-05 18:43:20 +00:00
sergei
ce2812e24a * Split combined declarations of GetModuleHandle and GetModuleFileName into separate WinCE and non-WinCE versions. Using Pointer as 'common denominator' in combined declarations was making it impossible to use e.g. GetModuleHandle('literal') in System unit.
* Also fixed parameter and return types for these declarations.

git-svn-id: trunk@19881 -
2011-12-22 02:17:02 +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
32094761ef * win32/system.pp, win64/system.pp: Moved duplicated declarations of WinAPI functions to sysos.inc (Florian's comment about include ordering is no longer true, wstrings.inc comes after sysos.inc these days).
* Result of GetCurrentProcess and first argument of ReadProcessMemory are THandle, not dword.

git-svn-id: trunk@19726 -
2011-12-02 18:52:48 +00:00
paul
6131a9188c rtl: fix wince compilation, reimplement WinCEWide2AnsiMove, WinCEAnsi2WideMove by copying win32 code
git-svn-id: trunk@19470 -
2011-10-12 01:50:14 +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
florian
28126cf0d5 * convert disk full to run time error 101
git-svn-id: trunk@18131 -
2011-08-07 09:15:42 +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
mazen
b127fc154a * Fixed spell error revealed by lintian.
git-svn-id: trunk@16094 -
2010-10-06 20:33:57 +00:00
pierre
bdefb849fc * Fix for Bug report 17550
git-svn-id: trunk@16089 -
2010-10-06 16:04:46 +00:00
florian
cba72c423d * patch by Sergei Gorelkin to use always SetFilePointer, also for files with >2GB, this saves some lines of code, resolves #14630
git-svn-id: trunk@13838 -
2009-10-10 18:52:50 +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
michael
174de3eab1 Merged revisions 9693-10480 via svnmerge from
svn+ssh://svn.freepascal.org/FPC/svn/fpc/branches/resources

........
  r9694 | michael | 2008-01-09 21:31:18 +0100 (Wed, 09 Jan 2008) | 1 line
  
  * Initial check-in
........
  r9695 | michael | 2008-01-09 21:35:58 +0100 (Wed, 09 Jan 2008) | 1 line
  
  * New version from Giulio Bernardi
........
  r9697 | michael | 2008-01-09 21:41:54 +0100 (Wed, 09 Jan 2008) | 1 line
  
  * Patch from Giulio Bernardi with resource support
........
  r9698 | michael | 2008-01-09 21:46:33 +0100 (Wed, 09 Jan 2008) | 1 line
  
  * Patch from Giulio Bernardi to add more resource testing
........
  r9699 | michael | 2008-01-09 21:57:26 +0100 (Wed, 09 Jan 2008) | 1 line
  
  * New tool from Giulio Bernardi
........
  r9700 | michael | 2008-01-09 21:58:23 +0100 (Wed, 09 Jan 2008) | 1 line
  
  * New tool from Giulio Bernardi
........
  r9701 | michael | 2008-01-09 22:01:54 +0100 (Wed, 09 Jan 2008) | 1 line
  
  * Added fcl-res
........
  r9702 | michael | 2008-01-09 22:01:58 +0100 (Wed, 09 Jan 2008) | 1 line
  
  * Added fcl-res
........
  r9703 | michael | 2008-01-10 08:54:26 +0100 (Thu, 10 Jan 2008) | 1 line
  
  * Fixed double code
........
  r9704 | jonas | 2008-01-10 10:59:20 +0100 (Thu, 10 Jan 2008) | 2 lines
  
    - removed duplicate code
........
  r9705 | jonas | 2008-01-10 11:25:21 +0100 (Thu, 10 Jan 2008) | 2 lines
  
    + added missing fcl-res dependencies
........
  r9706 | jonas | 2008-01-10 11:58:30 +0100 (Thu, 10 Jan 2008) | 2 lines
  
    + dependencies for fpintres and fpextres
........
  r9707 | yury | 2008-01-10 12:47:51 +0100 (Thu, 10 Jan 2008) | 3 lines
  
  * Fixed compilation of resource, which is included in a unit located in different folder than main source.
  * .res files must be copied to units output folder, otherwise .res files will not be found when only compiled units path is available and compiler does not know anything about sources folder.
  * Improved resource related error messages.
........
  r9708 | michael | 2008-01-10 12:52:13 +0100 (Thu, 10 Jan 2008) | 1 line
  
  * Removed double source after end.
........
  r9709 | michael | 2008-01-10 12:52:48 +0100 (Thu, 10 Jan 2008) | 1 line
  
  * No longer needed
........
  r9710 | tom_at_work | 2008-01-10 22:09:08 +0100 (Thu, 10 Jan 2008) | 1 line
  
  * properly align FPC_RESLOCATION so that linking does not fail on some architectures (e.g. ppc64)
........
  r9711 | tom_at_work | 2008-01-10 23:53:12 +0100 (Thu, 10 Jan 2008) | 1 line
  
  * fix splitting of 64 bit load/stores from/to unaligned memory locations into multiple load/stores, which in some cases generated wrong code
........
  r9712 | michael | 2008-01-11 11:00:08 +0100 (Fri, 11 Jan 2008) | 1 line
  
  * Fixed bug in BSS section on 64-bit platforms
........
  r9720 | giulio | 2008-01-12 10:02:04 +0100 (Sat, 12 Jan 2008) | 1 line
  
  Updated fcl-res documentation: occurrences of reslib changed to fcl-res.
........
  r9740 | giulio | 2008-01-13 19:36:44 +0100 (Sun, 13 Jan 2008) | 3 lines
  
   - Don't try to compile resources on systems with a non windows-like resource support.
   - Don't add the .or file to the list of object files if resource compiling failed.
........
  r10201 | giulio | 2008-02-04 11:35:44 +0100 (Mon, 04 Feb 2008) | 5 lines
  
  * resource compiling supported on OS/2 via wrc
  * CompileResourceFiles and CollectResourceFiles don't do target-specific checks anymore
  * refactored a bit
........
  r10389 | giulio | 2008-02-25 21:32:52 +0100 (Mon, 25 Feb 2008) | 2 lines
  
  Deleted test file which was committed by mistake
........
  r10472 | giulio | 2008-03-10 12:22:18 +0100 (Mon, 10 Mar 2008) | 2 lines
  
  changed define FPC_HAS_RESOURCES to FPC_HAS_WINLIKERESOURCES
........

git-svn-id: trunk@10481 -
2008-03-12 21:33:48 +00:00
florian
7da7364ee7 * refactored SysResetFPU into SysInitFPU and SysResetFPU
git-svn-id: trunk@8966 -
2007-10-28 12:06:49 +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
yury
4bfe0e6819 * Optimization for code size.
git-svn-id: trunk@5331 -
2006-11-11 14:19:33 +00:00
florian
4fb0d13138 + few com helpers added
git-svn-id: trunk@5144 -
2006-11-01 09:42:40 +00:00
florian
807fc6e948 * basic file io fixed for win64
git-svn-id: trunk@3241 -
2006-04-17 08:50:59 +00:00
florian
1db5db975e * more 64 bit clean up
git-svn-id: trunk@3224 -
2006-04-16 09:42:12 +00:00
florian
598853240c * keep the stack 16 byte aligned on winx64
* fixed some winx64 issues regarding exec

git-svn-id: trunk@3213 -
2006-04-15 16:49:18 +00:00
oro06
c1ac14c0f3 *arm/wince lib import corrected for Loadlibrary, GetProcAddress
git-svn-id: trunk@2070 -
2005-12-28 15:09:52 +00:00
florian
b88fcfda62 + 64 bit fs support
git-svn-id: trunk@1793 -
2005-11-20 15:50:06 +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
florian
07442c5693 * fixed passing of variant parameters for windows api
* widestrings need to be allocated by a special OS call on windows

git-svn-id: trunk@458 -
2005-06-20 19:56:36 +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