We can't exercise precondition check failures if GLib was (inadvisably)
compiled with -Dglib_checks=false, and we shouldn't necessarily exercise
precondition check failures when using QA tools like valgrind, so skip
these tests if run with -m no-undefined.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Previously, these tests would always pass. If the precondition check
failed (as we want it to), the subprocess would exit unsuccessfully;
but if the precondition check wrongly passed, the subprocess would
continue, allocate a nonzero amount of memory, and fail the
g_assert_null(), resulting in the subprocess exiting unsuccessfully
and the test still passing.
Signed-off-by: Simon McVittie <smcv@collabora.com>
On ILP32 platforms, 4 is a valid alignment for g_aligned_alloc(), so
use 2 as our invalid alignment instead.
Signed-off-by: Simon McVittie <smcv@collabora.com>
This allows the controller to explicitly be removed from the bus, in a
way that allows the caller to synchronise with it and know that all
other references to the controller should have been dropped (i.e. after
this method returns, there should be no in-flight D-Bus calls still
holding a reference to the object).
This is needed to be able to guarantee finalisation of the controller in
unit tests (and comparable real-world situations).
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
Helps: #1190
The resources data is generated for both GCC and MSVC toolchains, even
though we know beforehand which toolchain we're going to compile it for.
By dropping the data duplication we make the generated resources file
faster to compile, especially when dealing with large embedded data,
instead of relying on the C pre-processor to walk the whole file and
discard the branch we're not using.
We only want to include gslist.h here if it was not already included via
including glib.h, as:
* gslist.h should normally be included via glib.h if used outside of
GLib itself.
* This broke Visual Studio builds that use GResources (via
glib-compile-resources.exe) as that would cause the generated code to
include gslist.h directly, which is therefore disallowed.
When working with storage (especially GInputStream or GOutputStream) it
is preferred to use page-aligned buffers so that the operating system
can do page-mapping tricks as the operation passes through the kernel.
Another use case is allocating memory used for vectorised operations,
which must be aligned to specific boundaries.
POSIX and Windows, as well as the C11 specification, provide this kind
of allocator functions, and GLib already makes use of it inside GSlice.
It would be convenient to have a public, portable wrapper that other
projects can use.
Fixes: #2574
This will not reproduce the bug when run as a unit test, because in that
scenario, G_TEST_BUILDDIR and G_TEST_SRCDIR are set. It *can* reproduce
the bug (at least probabilistically) when run as an installed-test,
or manually in a build tree:
./_build/glib/tests/testing
Reproduces: https://gitlab.gnome.org/GNOME/glib/-/issues/2563
Signed-off-by: Simon McVittie <smcv@collabora.com>
If `GDebugControllerDBus` remains as the only, or default,
implementation of `GDebugController`, `dup_default()` cannot work.
`GDebugControllerDBus` requires a `GDBusConnection` at construction
time, which the `GIOModule` construction code can’t provide it.
Either we use a default D-Bus connection (but which one? and how would
it be changed by the user later if it was the wrong one?), or delegate
singleton handling of the `GDebugController` to the user.
The latter approach seems more flexible.
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
Helps: #1190