Derek (mantis #28830)
o ability for a thread to acquire a readlock when it already holds a
write lock, or vice versa
o detect when thread1 releases a lock while it hadn't acquired one
o correct result of beginwrite (return true only when another thread
held/acquired a write lock before the current thread got it)
o extra compared to Derek's patch: replaced some additional
(mostly pre-existing) interlocked*() hacks with proper memory
barriers, made formatting consistent, fixed compilation on platforms
where tthreadid is not an integer type, improved tthreadid hashing
function for 64 bit platforms, fixed some comments
git-svn-id: trunk@34678 -
normally returns int64 in FPC), before performing any further calculations -
the result always fits in a longint (the date is range checked against
MaxDateTime and that is well within longint limits). This generates faster
code on non 64-bit targets and also fixes i8086 compilation, which previously
failed on register allocation on this function.
git-svn-id: trunk@33946 -
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 -
large memory models by changing TSearchRec.FindHandle to a pointer (because
THandle is 16-bit on this platform and is thus not able to hold a far pointer
without truncating it)
git-svn-id: trunk@28451 -
platform SysUtils.TSearchRec.FileHandle is a Pointer, instead of THandle.
I didn't introduce a TFindHandle type, because I didn't want to add yet
another publicly visible type in the SysUtils interface.
git-svn-id: trunk@28449 -
using memory barriers, rather than half-heartedly using atomic
operations. Fixes random failures in trwsync on POWER7 processors
(and probably other weakly ordered architectures)
git-svn-id: trunk@27723 -
* 'mxcsr' variable made public and renamed to DefaultMXCSR.
* GetSSECSR and SetSSECSR renamed to GetMXCSR and SetMXCSR, respectively. Previous names continue to exist as deprecated aliases.
git-svn-id: trunk@27656 -
- rm ifdefs for i8086 far code memory model when doing stack traces. The
compiler will now choose the correct overload of HexStr according to the
CodePointer type.
git-svn-id: trunk@27163 -
it works correctly regardless of white kind of string is passed in
(and return a string encoded in DefaultRTLFileSystemCodePage)
git-svn-id: trunk@26450 -
into rawbytestring because otherwise -gt can overwrite it
- removed hack from r25944 in morphos/sysutils.pp that worked around this
problem
git-svn-id: trunk@25952 -
rtl/sysutils/datih.inc:
+ add StrToDate overload which allows passing of specific TFormatSettings parameter
rtl/sysutils/dati.inc:
* implement new StrToDate overload by calling IntStrToDate similar to StrToTime
git-svn-id: trunk@25392 -
rawbytestring
* DoDirSeparators() and GetDirs() marked as "rtlproc" so they can accept
non-rawbytestring arguments as their var-parameters
git-svn-id: branches/cpstrrtl@25306 -
o these routines are now generic wrappers in filutil.inc, and call
the platform-dependent internalfindfirst/next/close routines
o on unix, the fnmatch routine got proper support for UTF-8 matching
(e.g., it won't match a partial UTF-8 code point to a "?" wildcard)
o for NativeNT, a similar (untested) UTF-16 version has been added
+ test for the above
* rawbytestring/unicodestring versions of fileage
git-svn-id: branches/cpstrrtl@25302 -
so declarations can also depend on it and similar defines (not yet the
case)
+ added SYSUTILS_HAS_ANSISTR_ENVVAR_IMPL/SYSUTILS_HAS_UNICODESTR_ENVVAR_IMPL
to indicate whether the platform-dependent part of the unit provides
an ansistring/unicodestring interface to get environment variables
+ Windows version of getenvironmentvariable(unicodestring)
+ generic ansistring/unicodestring versions of GetEnvironmentVariable()
in case the platform doesn't provide them
* result of GetEnvironmentString() is ansistring/unicodestring depending
on the state of the FPC_RTL_UNICODE define
git-svn-id: branches/cpstrrtl@25116 -
CreateDir and RemoveDir, and implemented a generic one (based on the OS/2
version) in the shared sysutils code (so that the filesystem code page
support for the system unit routines can be reused)
* include both ansistring and unicodestring versions of the above routines,
and of ForceDirectories. Exception: GetCurrentDir, which cannot be
overloaded based on function result and whose return type currently
dependends on the FPC_UNICODE_RTL define
git-svn-id: branches/cpstrrtl@25113 -
compiled with unicodestring)
* changed uppercase/lowercase(ansistring) to use the same logic as the
new unicode versions (unify code for lower/upper, only make result
unique if necessary)
+ test for all four routines
git-svn-id: branches/cpstrrtl@25006 -
* moved the inclusion of sysansi.inc to before the inclusion of all other
sysutils include files so the inline body of CharInSet is available
git-svn-id: branches/cpstrrtl@25000 -
"widechar in set" compiles, but results in a runtime conversion of
the widechar into an ansistring and then getting the first character
of that ansistring, which is horribly slow -- and Delphi-incompatible,
but introduced a long time ago because of bug #7758)
* replaced all "in" operations in sysutils fina.inc with CharInSet for
the same reason
* replaced all "string" declarations in finah.inc/fina.inc with "PathStr"
and "pchar" with "PathPChar", and include them twice in sysutilh.inc/
sysutils.inc, once with PathStr=UnicodeString/PathPChar=PWideChar and
once with PathStr=AnsiString/PathPChar=PAnsiChar (not rawbytestring
because there are several routines with var-parameters and then the
string type has to match exactly; the "rtlproc" modifier could circumvent
this, but should be used sparingly, and additionally the routine's
internals would then first also have to be reviewed to ensure that at
no point they start mixing in strings with the defaultsystemcodepage
(e.g. directory separators) without first adjusting their codepage)
* call GetShortPathNameA or GetShortPathNameW in ExtractShortPathName on
Windows depending on whether we are parsing the RawByteString/UnicodeString
version of fina.inc
+ ExpandUNCFileName(unicode) version for Windows, let its
ExpandUNCFileName(ansistring) call the unicode version (avoid data loss
due to ansi conversion) and convert the result to
DefaultRTLFileSystemCodePage (to have no more data loss than what's
specified by the user)
git-svn-id: branches/cpstrrtl@24999 -
(strecopy, strend, strcat, strcomp, strlcomp, stricomp, strlcat, strrscan,
strlower, strupper, strlicomp, strpos, WideStrAlloc, StrBufSize,
StrDispose)
* adjusted pwidechar version of strnew to call WideStrAlloc instead of
StrAlloc
+ tests for several newly added sysutils pwidechar routines based on
existing tests for equivalent pchar routines
* converted several sysutils ansistr*() function tests to tests for str*
functions
git-svn-id: branches/cpstrrtl@24998 -
will be included twice using different string types (and those two
routines don't have a string argument, so this would result in duplicate
definitions), and their declaration is in filutilh.inc rather than
finah.inc anyway
* ensure that the fina.inc "MaxDirs" constant gets declared only once
* ensure that the finah.inc "TFilenameCaseMatch" type gets declared only
once
git-svn-id: branches/cpstrrtl@24994 -
o resolved conflict in updated morphos sysutils unit
o moved code that had been added to the now deleted sysunix.inc to the
unix-specific block of the fpwidestring unit's init code
git-svn-id: branches/cpstrrtl@24913 -
The default implementation of "GetTickCount" just uses the lower 32-Bit from the result of "GetTickCount64".
The default implementation of "GetTickCount64" is based upon "Now" for systems that support a floating point unit (and thus "Now").
Other systems can define a "SysTimerTick" function which is used instead if "HAS_SYSTIMERTICK" is defined.
The Windows implementation of "GetTickCount" uses Windows' "GetTickCount" function.
The implemenation of "GetTickCount64" checks whether the system is a Windows Vista or newer and then uses Windows' "GetTickCount64" function. Otherwise Windows' "GetTickCount" is used also.
The Unix implementation of "GetTickCount" is the default one.
The "GetTickCount64" implementation uses "fpgettimeofday".
git-svn-id: trunk@23215 -
before it because the value is too small, regardless of what the format
pattern sepcifies (patch by Bart Broersma, mantis #13076)
git-svn-id: trunk@23095 -
The WinCE implementation converts the rawbytestring arguments to
unicodestring and calls unicode OS APIs, while the others convert
unicodestring arguments to DefaultFileSystemCodePage and call
single byte OS APIs
+ test for the above
git-svn-id: branches/cpstrrtl@22467 -
(they don't have effect when they only appear in the implementation, and
therefore this situation will cause an error in the future)
git-svn-id: trunk@21523 -
* EExternal.ExceptionRecord changed from field to property and made available on all Windows, not just win32.
* CatchUnhandledException: removed AnsiString variable, ideally there should be no memory allocations in this code path.
git-svn-id: trunk@19849 -
* Some Delphi-compatible changes:
* For floating point underflow condition, raise EUnderflow, not EOverflow.
* For unknown codes, raise EInOutError, not Exception.
* Added entries for EZeroDivide and EStackOverflow (actually raising EZeroDivide on floating-point division by zero requires further changes to System because currently both integer and float division by zero is mapped to the same code 200).
git-svn-id: trunk@19707 -
Options now include stripquotes
* Changed ExeSearch so dirlist is optional and PATH is used if omitted.
It uses stripQuotes on windows. (bug 19282)
git-svn-id: trunk@17717 -
* return value of GetLastOSError if one is available, to be consistent with handle-based implementations and Delphi behavior.
* otherwise, return -1
git-svn-id: trunk@16318 -
* added function ExcludeLeadingPathDelimiter: it removes a path delimiter in front of a path
* added function ConcatPaths: it concats multiple path fragments, path delimiters are added if necessary
git-svn-id: trunk@15167 -
significant digits before the decimal points matches the precision
parameter exactly (mantis #16188)
* round instead of cut off digits in FloatToStr with ffGeneral
* take into account the minus sign when determining whether a number needs
to be represented using ffExponent instead of ffGeneral because it has
too many digits
git-svn-id: trunk@15114 -
* GetInterface and GetInterfaceWeak is modified so that when querying for IObjectReference not an interface is returned but the object pointer
git-svn-id: trunk@15087 -
atomic operations so that in case it's created while multiple threads are
already running, all threads are guaranteed to see this initialisation
* some minor changes to the comments of TMREWS
git-svn-id: trunk@15074 -
so the TMultiReadExclusiveWriteSynchronizer routines can be safely
executed even with the default thread manager -> removed ismultithread
checks, so that it keeps working even if ismultithread is set to true
between acquiring and freeing a lock (mantis #15619)
git-svn-id: trunk@14830 -
TMultiReadExclusiveWriteSynchronizer, to ensure that out-of-order
execution cannot already perform some reads inside the critical section
before the lock has been acquired
- removed now unnecessary read barrier before releasing a read lock
git-svn-id: trunk@14820 -
critical section, so that it can be entered recursively just like
the one from TSimpleRWSync + test
- reverted r14593, since the reason for using TRWSync instead of
TMultiReadExclusiveWriteSynchronizer was because the former
supported recursive write locks
git-svn-id: trunk@14594 -
(to remove warnings)
* don't give a thread error for basicevent and threadevent routines if
isMultiThreaded is false, except for the waiting routines (the new
TMultiReadExclusiveWriteSynchronizer creates/sets such events in the
constructor, which caused thread manager errors in case cthreads was
not used under unix)
* don't perform any actual locking in TMultiReadExclusiveWriteSynchronizer
routines if isMultiThreaded is false (in order to avoid the errors
described above)
+ added generic RTLeventResetEvent stub
git-svn-id: trunk@14592 -