Commit Graph

30935 Commits

Author SHA1 Message Date
Philip Withnall
c96cd22cf9 Merge branch '3042-msys2-still-intermittent' into 'main'
Revert "CI: Mark msys2-mingw32 as allowing failures"

Closes #3042

See merge request GNOME/glib!4190
2024-09-29 12:56:15 +00:00
Philip Withnall
fe8e4eb6db
ci: Clarify msys2 allow-failure policy
See the previous commit and discussion on #3420.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-09-29 13:36:03 +01:00
Philip Withnall
53f20d79b8
Revert "CI: Mark msys2-mingw32 as allowing failures"
This reverts commit 16819a4024.

The failure this was added for is intermittent and has been going on a
long time; it’s not a new failure caused by msys2 dependency/packaging
changes, so the policy in .gitlab-ci.yml doesn’t apply.

It would be great if someone fixed #3042, but un-gating GLib from msys2
testing is not the right tradeoff for it.

See: #3042
2024-09-29 13:35:57 +01:00
Philip Withnall
034d528348 Merge branch 'fix-msys2-mingw32-ci' into 'main'
ci: Only build gobject-introspection if the system version is too old

Closes #3464

See merge request GNOME/glib!4317
2024-09-29 12:33:08 +00:00
Philip Withnall
d50102f2d8
gvariant: Fix suffix alignment on 32-bit machines
This fixes commit 0b083e3d8c. The static assertion added in that commit
fails on 32-bit machines.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-09-29 13:12:31 +01:00
Philip Withnall
d3e0d4fbde
gpoll: Remove unused variable
Fixes commit 3baf1f1a73.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-09-29 12:30:53 +01:00
Philip Withnall
96652e7def
ci: Only build gobject-introspection if the system version is too old
We want to build GLib against a matched version of
gobject-introspection, and this version will probably be bumped quite
often as the two are developed in tandem.

However, if the CI system provides a newer version, we should probably
use that, otherwise we’re essentially downgrading part of the OS on the
CI system, and that probably will result in issues. In particular,
gobject-introspection <1.82 has a bug on MSYS2 which means it doesn’t
build (see issue #3464).

So, build gobject-introspection manually if the CI system version is too
old, otherwise use the system version. Do this programmatically so we
don’t have to repeatedly add and remove the gobject-introspection build
commands from the CI configuration as versions are bumped.

Fixes: #3464
2024-09-29 12:25:35 +01:00
Philip Withnall
e115eafb8a
lcov: Fix use of deprecated lcov_branch_coverage option
This option was renamed to `branch_coverage` in more recent versions of
lcov. This might explain why branch coverage is not being collected by
CI at the moment.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-09-28 22:38:00 +01:00
Philip Withnall
4136db0a8c
fuzzing: Add simple fuzz test for g_string_replace()
Now that the implementation of it is significantly more complex,
involving pointer arithmetic, it should probably be fuzzed. It’s not an
API which is obviously used to handle untrusted input, but some users of
GLib might do so.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-09-28 22:37:53 +01:00
Philip Withnall
303f04286e Merge branch 'feature' into 'main'
remove quadratic behavior in g_string_replace

See merge request GNOME/glib!4313
2024-09-28 21:09:53 +00:00
James Tirta
e8517e7776 remove quadratic behavior in g_string_replace
Current implementation replaces find in string with replace
one-at-a-time and replacement is done in O(n^2) time. The new
implementation is O(n). Memory allocation is done once instead of
incrementally.

In the old implementation, every replacement will move the whole
rest of the string from the current position to make space for
the replace string and then insert the replace string.

In the new implementation, when the replace string is shorter or equal
to the find string, it will move the characters in-place and requires no
additional memory. When the replace string is longer, find the required
size needed for the new string and preallocate a new string to copy the
original string to with its replacements. When the replace string is an
empty string use the old implementation to handle the special case.
2024-09-28 21:09:53 +00:00
Philip Withnall
e1af498896 Merge branch 'amolenaar/fix-macos-url-launcher' into 'main'
macos: Fix URL launcher

Closes #3484

See merge request GNOME/glib!4312
2024-09-28 17:20:51 +00:00
Arjan Molenaar
fd6c1f34da macos: Fix URL launcher
URLs should be provided to the AppInfo.launch_uris() function.
2024-09-27 21:45:33 +02:00
Philip Withnall
d7bb4664e7
tests: Add a way to get the mock session bus address in tests
This is better than using `g_getenv ("DBUS_SESSION_BUS_ADDRESS")` as it
will fail more explicitly if the mock bus somehow isn’t running.

This will be used in an upcoming commit.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-09-27 17:08:21 +01:00
Philip Withnall
019de2cbbc Merge branch 'wip/chergert/gvariant-inline-suffix-data' into 'main'
glib/gvariant: Inline small gvariant data using C99 flexible arrays

See merge request GNOME/glib!4301
2024-09-27 12:35:05 +00:00
Philip Withnall
0a9573b53b Merge branch 'wip/lantw/tests-FreeBSD-doesn't-use-glibc' into 'main'
tests: FreeBSD doesn't use glibc

See merge request GNOME/glib!4310
2024-09-27 11:34:36 +00:00
Ting-Wei Lan
095fd5a06b tests: FreeBSD doesn't use glibc
FreeBSD has its own libc implementation. It is maintained as a part of
the operating system, not a copy of glibc.
2024-09-27 11:41:33 +08:00
Christian Hergert
0b083e3d8c glib/gvariant: Avoid many GBytes allocation
Previously, all GVariants would allocate a GBytes for the buffered
contents. This presents a challenge for small GVariant type created
during the building process of GVariantBuilder as that results in an
allocation for the GVariant, GBytes, and the byte buffer.

Recent changes for GBytes may reduce those 3 allocations to 2, but even
that is quite substantial overhead for a 32-bit integer.

This changeset switches GVariant to use g_new/g_free allocators instead
of g_slice_new/free. When benchmarked alone, this presented no
measurable difference in overhead with the standard glibc allocator.

With that change in place, allocations may then become variable in size
to contain small allocations at the end of the GVariant reducing things
to a single allocation (plus the GVariantTypeInfo reference).

The size of GVariant is already 1 cacheline @ 64-bytes on x86_64. This
uses that to guarantee our alignment of data maintains the 8-bytes
guarantee of GVariant, and also extends it to match malloc().

On 32-bit systems, we are similarly aligned but reduce the amount we
will inline to 32 bytes so we have a total of 1 cacheline.

This is all asserted at compile-time to enforce the guarantee.

In the end, this changeset reduces the wallclock time of building many
GVariant in a loop using GVariantBuilder by 10% beyond the 10% already
gained through GBytes doing the same thing.
2024-09-26 14:28:41 -07:00
Michael Catanzaro
0012d1921d Merge branch 'main' into 'main'
fix https://gitlab.gnome.org/GNOME/glib/-/issues/3444

Closes #3444

See merge request GNOME/glib!4309
2024-09-26 21:01:20 +00:00
stefan11111
89480c2e0a fix https://gitlab.gnome.org/GNOME/glib/-/issues/3444 2024-09-26 22:47:30 +03:00
Philip Withnall
1f59e89391
ci: Re-enable fatal warnings for FreeBSD CI
Now that the CI runner has Meson 1.4, we can revert commit
eda5bb386b and re-enable fatal warnings.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-09-26 13:29:52 +01:00
Philip Withnall
c2a5bd2c65 Merge branch 'wip/chergert/no-copy-gvarianttype-stack-builder' into 'main'
glib/gvariant: avoid GVariantType copy for stack builders

See merge request GNOME/glib!4286
2024-09-26 11:57:26 +00:00
Christian Hergert
0f95b18a7b gio: use g_variant_builder_init_static()
All uses of g_variant_builder_init() in gio are safe to translate to the
new g_variant_builder_init_static() alternative as the type will outlive
the call to g_variant_builder_end() (or is already static in nature).
2024-09-26 12:48:16 +01:00
Christian Hergert
bfac590364 gio/gdbus-codegen: use g_variant_builder_init_static()
Make the generated GDBus-based code use GVariantBuilder with a static
GVariantType to avoid copying the GVariantType on each use.

This is gated behind a GLib 2.83.0 check.
2024-09-26 12:48:16 +01:00
Philip Withnall
80e8bc7c0b Merge branch 'wip/chergert/reduce-copies-for-gvarianttype-cache' into 'main'
gvarianttypeinfo: reduce caching overhead

See merge request GNOME/glib!4293
2024-09-26 11:11:52 +00:00
Philip Withnall
2258c08769 Merge branch 'main' into 'main'
gpoll windows: use a threadpool when polling large number of fds

See merge request GNOME/glib!4300
2024-09-26 10:27:20 +00:00
Yash Trivedi
3baf1f1a73 gpoll windows: use a threadpool when polling large number of fds 2024-09-26 10:27:19 +00:00
Christian Hergert
c50e44a6e0 glib/gvariant: add g_variant_builder_init_static()
This adds another form of stack building which allows avoiding the rather
expensive GVariantType malloc/memcpy/free. In a tight loop this reduced
wallclock time by about 4-5% for cases where you do not need to further
open using g_variant_builder_open() which still require a copy at this
time.

New API is provided instead of modifying g_variant_type_init() because
previously it was possible (though misguided) to use g_variant_type_init()
which a dynamically allocated GVariantType which could be freed before
g_variant_builder_end() or g_variant_builder_clear() was called.

# Conflicts:
#	glib/gvariant.c
2024-09-25 11:13:58 -07:00
Christian Hergert
2deb5dcfc0 glib/gvariant: add test for g_variant_type_hash() 2024-09-25 10:05:36 -07:00
Christian Hergert
1850b5c1ab gvarianttypeinfo: avoid string copy for cache lookup
When trying to locate a GVariantTypeInfo from the cache we were copying
the string so that we can use g_str_hash, as that requires a \0 terminated
string.

However, we have hash and equal functions which can be used without the
extra copy. Additionally, these were moved to headers in previous commits
so they can be used without having to re-check GVariantType we already
know to be valid.
2024-09-25 10:05:33 -07:00
Philip Withnall
133ade7244 Merge branch 'ebassi/gi-docgen-wrap-update' into 'main'
Update the wrap file for gi-docgen

See merge request GNOME/glib!3816
2024-09-25 16:45:45 +00:00
Philip Withnall
efab4c1c71
build: Bump the gi-docgen dependency to 2024.1
This gives us an updated enumeration template and link validation,
amongst other things.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-09-25 17:27:46 +01:00
Emmanuele Bassi
e6d0229b22 subprojects: Update the wrap file for gi-docgen
Use the [provide] section to override the binary name, and track the
main development branch, like GTK does, so we get warnings and a
consistent output.
2024-09-25 17:24:56 +01:00
Philip Withnall
428942d626 Merge branch 'wraps' into 'main'
subprojects: Update pcre2 to 10.44

See merge request GNOME/glib!4268
2024-09-25 16:22:53 +00:00
Philip Withnall
8b8b8a5a5e
ci: Bump CI image versions to cache new version of PCRE
As per the previous commit.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-09-25 17:06:10 +01:00
Benjamin Gilbert
47f11d20d9 subprojects: Update pcre2 to 10.44
Bug fixes.
2024-09-25 17:06:04 +01:00
Philip Withnall
0ad601ef38 Merge branch 'c_std' into 'main'
build: switch back to c_std=gnu99 pending ObjC fix

See merge request GNOME/glib!4305
2024-09-25 15:22:03 +00:00
Philip Withnall
fd9c00179f Merge branch 'wip/chergert/gvariant-use-proper-macros-conditions' into 'main'
Fix incorrect use of assert/debug/check macros

See merge request GNOME/glib!4292
2024-09-25 15:06:10 +00:00
Benjamin Gilbert
23009aadc6 build: switch back to c_std=gnu99 pending ObjC fix
It's better to warn by default on MSVC (which we were already doing before
we bumped to 1.4.0) than to fail by default on macOS.

Fixes: 51e3e7d9ae ("build: Bump Meson dependency to 1.4.0")
2024-09-25 07:45:06 -07:00
Philip Withnall
f2ca182ab4 Merge branch 'wip/chergert/fix-gvariant-spec' into 'main'
docs/gvariant: fix a(si) example in specification

Closes #3478

See merge request GNOME/glib!4289
2024-09-25 14:39:05 +00:00
Philip Withnall
267342420f Merge branch 'wip/chergert/fix-ganalyzer-use' into 'main'
glib/gvariant: Fix check for G_ANALYZER_ANALYZING

Closes #3480

See merge request GNOME/glib!4291
2024-09-25 13:43:02 +00:00
Philip Withnall
04e45e3cef Merge branch 'wip/chergert/gvariant-transfer-gbyte-ownership' into 'main'
glib/gvariant: Avoid extraneous GBytes ref counting

See merge request GNOME/glib!4299
2024-09-25 13:42:57 +00:00
Philip Withnall
2691c5e24e
gdbusdaemon: Fix check for G_ANALYZER_ANALYZING
As with the previous commit, this is _always_ defined in `gmacros.h`
and therefore the `#ifndef` will always be 0 even if disabled.
Just use `#if` instead.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-09-25 14:30:48 +01:00
Philip Withnall
5ac765689c Merge branch 'wip/chergert/g_variant_ref_sink-perf' into 'main'
glib/gvariant: skip bitlock for g_variant_ref_sink()

See merge request GNOME/glib!4302
2024-09-25 13:21:56 +00:00
Philip Withnall
765eea0a78 Merge branch 'wip/chergert/gvarianttype-proper-const' into 'main'
gvarianttype: mark const functions as such

See merge request GNOME/glib!4294
2024-09-25 13:11:11 +00:00
Philip Withnall
e071e1bfc0 Merge branch 'wip/chergert/avoid-malloc-in-format-string-validation' into 'main'
gvariant: Avoid malloc/free in valid_format_string()

See merge request GNOME/glib!4295
2024-09-25 13:10:34 +00:00
Philip Withnall
5d40bc448e Merge branch 'wip/chergert/g_variant_type_is_subtype_of-fastpath' into 'main'
glib/gvarianttype: g_variant_type_is_subtype_of() fastpath

See merge request GNOME/glib!4297
2024-09-25 13:08:52 +00:00
Philip Withnall
4596bd819d Merge branch 'wip/chergert/gvariantbuilder-avoid-g_renew-for-known-children-length' into 'main'
glib/gvariant: avoid g_renew() for definite tuples

See merge request GNOME/glib!4298
2024-09-25 13:03:22 +00:00
Christian Hergert
9a380ee918 glib/gvariant: Avoid extraneous GBytes ref counting
Right now we create a bunch of GBytes which then get their reference count
incremented and immediately decremented. This causes quite a bit of
disruption for cacheline re-use.

Instead, this change creates an internal helper to transfer ownership of
GBytes to the new GVariant directly.

Surprisingly, this reduced wallclock time by about 6% for a contrived
benchmark of building "as" variant with GVariantBuilder.
2024-09-25 13:09:17 +01:00
Philip Withnall
842c828535 Merge branch 'wip/chergert/use-utf8-validate-for-strlen' into 'main'
glib/gvariant: use g_utf8_validate() for strlen

See merge request GNOME/glib!4296
2024-09-25 12:00:26 +00:00