Types for bindings of C libraries in druntime need to match the
C headers. Small differences can result in hard to debug problems.
This test tries to automatically find types with a wrong size.
This is done by also getting type sizes from C headers using ImportC
and comparing them. Differences between the sizes can have different reasons:
* Bugs in ImportC (e.g. for bitfields) can result in a wrong size
* Type definitions in druntime can be wrong
* Different preprocessor options could be used, like _FILE_OFFSET_BITS
* Size differences can be fine, because some structs contain a member
for the size or a version
Members of structs and unions with the same name are also compared.
For types with potential problems a comparison of the layout is printed.
The test contains a list of known problems, which are only treated as
warnings and not errors.
merge stable
Signed-off-by: Nicholas Wilson <thewilsonator@users.noreply.github.com>
Merged-on-behalf-of: Nicholas Wilson <thewilsonator@users.noreply.github.com>
Note the X86_64 typo. These functions are never used in druntime, and if the typo is fixed, it adds two unused function _definitions_ to druntime. Let's not do that, and instead remove these function definitions all-together.
Android supports native ELF TLS since API level 29 (Android v10),
so we can use the generic rt.sections_elf_shared implementation now,
which among other things also enables *shared* druntime/Phobos libs.
The 22 integration tests came with a mix of removing only ROOT
(generated/OS/BUILD/MODEL) or GENERATED (generated) subdirs as
part of their `make clean`.
And running `make clean` in the druntime dir only cleaned up the
default BUILD=release variant, while running `make unittest` without
explicit BUILD type includes running the integration tests in both
debug and release variants.
Streamline/fix this to always cleaning up ROOT, and running `make clean`
in both variants when running druntime's `make clean`.
Get rid of obsolete `{C,Cpp}Runtime_DigitalMars` special cases
Signed-off-by: Dennis <dkorpel@users.noreply.github.com>
Signed-off-by: Nicholas Wilson <thewilsonator@users.noreply.github.com>
Merged-on-behalf-of: Nicholas Wilson <thewilsonator@users.noreply.github.com>
The signature of calloc is `void* calloc( size_t num, size_t size )`, where `num` is the number of objects and `size` is the byte size per object. (https://en.cppreference.com/w/c/memory/calloc)
The number of bytes allocated is the same with this fix, but it solves potential memory alignment issues.
I am fairly convinced that no possible arguments to or global state at the time
of any call to Thread.sleep can result in memory corruption.
There is a precondition on Thread.sleep, that the duration must be
non-negative. On Windows, Thread.sleep calls Sleep, which takes an unsigned
integer. On POSIX, Thread.sleep calls nanosleep, which is specified to handle
negative durations gracefully. As such, violating this precondition should not
be a source of undefined behavior.
* Remove the interface function fullCollectNoStack from the gcinterface
* Fix tests that depend on the GC not scanning the stack.
* Remove all nostack remnants
* Add changelog entry
FreeBSD 14 changed the signature of qsort_r to be POSIX-compliant with
POSIX, making it so that our binding for it no longer matches, resulting
in a crash when it's used.
This implements a fix similar to what the FreeBSD headers do to avoid
breaking code (they provide a static inline extern(C++) overload for the
old signature). This provides a deprecated extern(D) overload for the
old signature. The extern(C) overload now matches the new signature. The
changes have been versioned so that they only affect FreeBSD 14 and
newer.
Technically, if someone used Cmp when declaring their function for
qsort_r, this would still break them (though with a compilation error
that should be easy to fix rather than silent breakage or a crash), but
I don't really see a way around that, and Cmp is not part of the POSIX
API, so no one would have a clue that it was a thing without digging
through the bindings. Arguably, we should make it private, since it's
not part of POSIX, but I haven't done anything with that in this commit.
My guess is that in reality, no D programs are both written to use
qsort_r and run on FreeBSD (outside of the druntime tests), but this
way, they won't break unless they use Cmp to declare their comparator
function. They'll just get a deprecation message that they should update
their code.
Regardless, we have to change the signature for FreeBSD 14 for it to
work, and this does that.