Commit Graph

30946 Commits

Author SHA1 Message Date
Philip Withnall
6b15af3c4c
gio: Use g_steal_handle_id() with signal unsubscriptions
This makes no functional changes, but does tidy the code up a bit and
means `g_steal_handle_id()` gets a bit more testing.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-10-08 13:57:30 +01:00
Philip Withnall
da5ce72171 Merge branch 'msys2-ci' into 'main'
CI/MSYS2: Fix prefix for gobject-introspection

See merge request GNOME/glib!4338
2024-10-08 12:15:56 +00:00
Luca Bacci
f66d144091 test-msys2.sh: Remove unnecessary line
${MINGW_PREFIX}/bin is already in PATH
2024-10-08 13:37:31 +02:00
Luca Bacci
31bd6956f0 CI/MSYS2: Fix prefix for gobject-introspection
The right prefix is /c/msys64/${MSYSTEM}, without the final /usr.
Anyway let's simply use the MINGW_PREFIX environment variable.
2024-10-08 12:20:38 +02:00
Michael Catanzaro
bb0d3d2c1c Merge branch 'fuzz-string-replace-oom' into 'main'
fuzzing: Add input length limits on g_string_replace() test

See merge request GNOME/glib!4334
2024-10-07 21:54:19 +00:00
Philip Withnall
eb413097e5 Merge branch 'xnu-mcast-iface' into 'main'
gio: Fix multicast iface selection on macOS

Closes #3489

See merge request GNOME/glib!4333
2024-10-07 14:02:02 +00:00
Nirbheek Chauhan
469084c45b gio: Fix multicast iface selection on macOS
ip_mreqn.imr_ifindex is not used correctly by the XNU kernel, and
causes us to bind to the default interface; so fallback to ip_mreq
and set the iface source address (not SSM).

Fixes https://gitlab.gnome.org/GNOME/glib/-/issues/3489
2024-10-07 14:02:02 +00:00
Philip Withnall
2fe82cb62d Merge branch 'msvc-ci-2019' into 'main'
CI: Use Visual Studio 2019 for the MSVC CI

See merge request GNOME/glib!4318
2024-10-07 13:57:51 +00:00
Philip Withnall
4416d9dcce Merge branch '3488-introspection-checks' into 'main'
build: Check for gobject-introspection-1.0 as well as g-ir-scanner

Closes #3488

See merge request GNOME/glib!4329
2024-10-07 13:46:04 +00:00
Chun-wei Fan
cba1d820d9 CI: Only run the VS2019-x86 CI job weekly or on request
As per suggested by Philip, as the Visual Studio CI jobs are the slowest to
be picked up and to be completed.
2024-10-07 14:56:56 +08:00
Chun-wei Fan
c4799982d6 CI: Add a 32-bit Visual Studio 2019 config
This way, we can continue to test whether 32-bit builds continue to work
with Visual Studio builds. Note that this uses the x64-to-x86 cross compiler.
2024-10-07 14:56:56 +08:00
Chun-wei Fan
0f0d5df4e5 CI: Use Visual Studio 2019 for the MSVC CI
...and add ability to select target platform for calling vcvarsall.bat,
so that we can accomodate 32-bit builds and possibly ARM64 builds in the
CI if we need to.
2024-10-07 14:56:55 +08:00
Philip Withnall
c94cbf2368 Merge branch 'wip/chergert/gdatainputstream-memchr' into 'main'
gio/gdatainputstream: use memchr() when possible

See merge request GNOME/glib!4327
2024-10-05 22:09:34 +00:00
Philip Withnall
276889ac85
fuzzing: Add input length limits on g_string_replace() test
Limit the input size. With a short @find, and a long `init` and `replace`
it’s quite possible to hit OOM. We’re not interested in testing that — it’s
up to the caller of `g_string_replace()` to handle that. 1KB on each of the
inputs should be plenty to find any string parsing or pointer arithmetic
bugs in `g_string_replace()`.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

oss-fuzz#371233785
2024-10-05 23:01:58 +01:00
Philip Withnall
74e37a483f Merge branch 'ebassi/gir-inline' into 'main'
gir: Ignore function-inline and method-inline elements

See merge request GNOME/glib!4331
2024-10-05 21:11:13 +00:00
Christian Hergert
760a6f6477 gio/tests: add test for single escape character
Converts the existing test to a loop and adds another test case which
tests a single stop character, \0 in this case.
2024-10-04 12:46:11 -07:00
Nirbheek Chauhan
decd9bb1ca Merge branch 'fix_woa64_1' into 'main'
Meson: fix support for aarch64-w64-mingw32 (Windows on ARM64)

Closes #3490

See merge request GNOME/glib!4330
2024-10-04 17:07:44 +00:00
Carlo Bramini
2986cd3793 Meson: fix support for aarch64-w64-mingw32 (Windows on ARM64)
This patch fixes a build error when compiling with GCC cross compiler for Windows on ARM64.
See issue #3490 for details.

Signed-off-by: Carlo Bramini carlo_bramini@users.sourceforge.net
Fixes: #3490
Closes #3490
2024-10-04 11:43:45 +02:00
Emmanuele Bassi
20134e6942 gir: Ignore function-inline and method-inline elements
Static inlines are available in the GIR, but they do not translate to
ABI, so they cannot go in the typelib. We handle them just like function
macros.
2024-10-03 18:35:38 +02:00
Philip Withnall
fb4f2e5578 Merge branch 'wip/chergert/c-utf8' into 'main'
glib/utf8: Use SIMD for UTF-8 validation

Closes #3481

See merge request GNOME/glib!4319
2024-10-03 15:07:17 +00:00
Philip Withnall
72384894b8
gutf8: Remove dead branch condition
This arm of the condition is always true, because 0x00 has been checked
in the previous branch.

This is not going to improve performance, but does mean we now have full
branch coverage of the code via our unit tests, which gives some
assurance that it’s all good.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3481
2024-10-03 15:46:01 +01:00
Philip Withnall
36e4bb9872
tests: Add some more UTF-8 validation corner cases
The move to c-utf8 for validation has exposed a few new branches where
our existing (fairly comprehensive) UTF-8 validation test suite didn’t
check things.

Add unit tests for those branches, so we keep code coverage.

I’ve validated (with an independent UTF-8 decoder) that the test vectors
are correctly marked as valid/invalid in the test data (so the tests
aren’t just blindly coded to match the behaviour of the new validator
code).

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3481
2024-10-03 15:43:35 +01:00
Philip Withnall
e570263483
tests: Add basic unit tests for g_str_is_ascii()
It turns out it’s not actually been explicitly tested before, even
though it has full code coverage through being called by other code
which is tested.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-10-03 14:31:02 +01:00
Philip Withnall
7f8f0842d0 Merge branch 'wip/pwithnall/reenable-freebsd-fatal-warnings' into 'main'
ci: Re-enable fatal warnings for FreeBSD CI

See merge request GNOME/glib!4307
2024-10-03 12:56:21 +00:00
Philip Withnall
04abc6b6c1
build: Check for gobject-introspection-1.0 as well as g-ir-scanner
Both are needed in practice to build the GIR files.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Fixes: #3488
2024-10-03 13:39:30 +01:00
Christian Hergert
e7e5ddd2ae gio/gdatainputstream: use memchr() when possible
Scanning for stop chars can require looking through a considerable amount
of input data. In the case there is a single stop character, use memchr()
which can be optimized by the compiler to look at word size or greater
amounts of data at a time.
2024-10-02 13:33:17 -07:00
Christian Hergert
b72650542c glib/utf8: Use SIMD for g_str_is_ascii()
This moves g_str_is_ascii() from gstrfuncs.c to gutf8.c so that we can
reuse the same SIMD code for ASCII validation.

On Apple Silicon:

 Before:  3297 MB/s
  After: 26146 MB/s
2024-10-01 15:30:32 -07:00
Christian Hergert
1d3d7336ed glib/utf8: Use SIMD for UTF-8 validation
This is based on the https://github.com/c-util/c-utf8 project and has
been adapted for portability and integration into GLib. c-utf8 is dual
licensed Apache-2.0 and LGPLv2.1+, the latter matching GLib.

Notably, `case 0x01 ... 0x7F:` style switch/case labels have been
converted to if/else which is more portable to non-GCC/Clang platforms
while generating the same assembly, at least on x86_64 with GCC.

Additionally, `__attribute__((aligned(n)))` is used in favor of
`__builtin_assume_aligned(n)` because it is more portable to MSVC's
`__declspec(align(n))` and also generates the same assembly as GCC's
`__builtin_assume_aligned(n)`.

For GCC x86_64 Linux on a Xeon 4214 this improved the throughput of
g_utf8_validate() for ASCII from 750MB/s to around 10,000MB/s (13x).

On GCC aarch64 Linux with an Apple Silicon M2 Pro we go from about
2,200 MB/s to 26,700 MB/s (12x).

Closes: #3481
2024-10-01 12:44:36 -07:00
Philip Withnall
17124abc7e Merge branch 'jsparber/test_openuri_portal' into 'main'
tests: Expand tests for app launching via D-Bus

See merge request GNOME/glib!4176
2024-10-01 17:49:11 +00:00
Julian Sparber
c8e80132d8 tests: Add tests for launching default for file/uri via XDG portal 2024-10-01 19:03:37 +02:00
Julian Sparber
59877f5cc6 tests: Add launch context to g_app_info_launch_uris() tests
This ensure that `g_app_info_launch_uris()` uses and set the correct
activation token.
2024-10-01 18:25:52 +02:00
Julian Sparber
73970ee0b4 gopenuriportal: Improve error messages 2024-10-01 18:25:47 +02:00
Julian Sparber
0758788a25 gopenuriportal: Create GXdpOpenURI DBus proxy when needed
Instead of using singleton initialized the first time when it's needed
we can create the `DBusProxy` object when needed without blocking since
the interface doesn't have any properties nor signals.
2024-10-01 18:25:42 +02:00
Julian Sparber
89488e98e9 gopenuriportal: Use task data instead of object data
The docs recommend using a small number of `keys` when setting data for an
object, the OpenURI portal uses three different `keys` that can easily be replaced
with `g_task_set_task_data()`.
2024-10-01 18:25:37 +02:00
Julian Sparber
ef064d625b gopenuriportal: Fix two memory leaks 2024-10-01 18:25:31 +02:00
Philip Withnall
f6d7878a54 Merge branch 'speed-up-query-exists' into 'main'
gio: Add a query_exists vfunc to GFile

See merge request GNOME/glib!4272
2024-10-01 15:45:04 +00:00
Philip Withnall
2b5d3b5831 Merge branch 'fake-document-portal-in-process' into 'main'
tests: Move fake-document-portal subprocess inside dbus-appinfo test

See merge request GNOME/glib!4311
2024-10-01 15:38:30 +00:00
Matthias Clasen
ab51ed0521 gio: Implement query_exists for resources
This avoids allocations for this frequently used method.
2024-10-01 16:35:54 +01:00
Matthias Clasen
65ad41d8a4 gio: Implement query_exists for local files
We can’t quite use `access()` for this, like `g_file_test()` does, as
`g_file_query_info()` considers a broken symlink to exist, so we need to
match that by passing `AT_SYMLINK_NOFOLLOW`.

We also use the `AT_EACCESS` flag, which makes the `faccessat()` call
cheaper on Hurd.

Systems without `faccessat()` will continue to use the
`g_file_query_info()`-based implementation of `g_file_query_exists()`.

(Commit message rewritten by Philip Withnall.)
2024-10-01 16:27:29 +01:00
Matthias Clasen
85ce99f4ad gio: Add a query_exists vfunc to GFile
g_file_query_exists looks like a simpler and faster api than
g_file_query_info. This vfunc lets us actually make it faster,
and avoid allocations in this frequently used code path.
2024-10-01 16:25:57 +01:00
Philip Withnall
e14a393d27 Merge branch '3483-mainloop-test' into 'main'
tests: Rework a mainloop test to use an explicit termination condition

Closes #3483

See merge request GNOME/glib!4324
2024-10-01 15:00:03 +00:00
Philip Withnall
9e73d9a15a Merge branch 'utf8-docs' into 'main'
gutf8: Convert docs to gi-docgen linking syntax

See merge request GNOME/glib!4304
2024-10-01 14:53:53 +00:00
Philip Withnall
f8ba505dc1
gutf8: Clarify position of end returned from g_utf8_validate()
It wasn’t previously clear (to me) whether `end` was returned pointing
to the nul terminator, or to the byte immediately preceding it. Try and
clarify that.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-10-01 15:44:43 +01:00
Philip Withnall
7302c04e32
gutf8: Convert docs to gi-docgen linking syntax
Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3250
2024-10-01 15:44:36 +01:00
Philip Withnall
766f3414eb Merge branch 'steal-handle-id' into 'main'
utils: Add g_steal_handle_id() to complement g_clear_handle_id()

See merge request GNOME/glib!4308
2024-10-01 14:25:58 +00:00
Philip Withnall
6b2cc430e0
tests: Run dbus-appinfo tests with G_TEST_OPTION_ISOLATE_DIRS
Eliminate any possibility of them accidentally using the user’s
actual home directory.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-10-01 15:22:46 +01:00
Philip Withnall
d7e368f206
tests: Move fake-document-portal subprocess inside dbus-appinfo test
For the reasons given in
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/4176#note_2233317,
it’s best to not rely on subprocesses when writing tests. Spawning a
subprocess can go wrong, getting feedback and assertion data from a
subprocess is a pain, and making sure the subprocess is killed properly
at the end of the test is hard to get right.

For tests where we are trying to mock a D-Bus service, it’s much more
reliable to run that service in-process (either in the main thread or in
a separate thread).

So, do that for the `fake-document-portal` former subprocess in the
`dbus-appinfo` test: move it to a worker thread.

This speeds the test up, simplifies the build slightly, and should make
the test run more reliable.

In particular, it provides a pattern for future `fake-*-portal` tests to
be built off. This is particularly useful for more complex portals,
where data needs to be relayed back from the mock portal service to the
unit test to check that the code under test has behaved properly. That’s
a pain to do from a subprocess.

Delete the `org.freedesktop.portal.Documents.service` file because we no
longer need to rely on D-Bus service activation within the test, as
we’re setting up the mock service thread explicitly now.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-10-01 15:22:40 +01:00
Michael Catanzaro
04543594d4 Merge branch 'gbytes-double-free' into 'main'
gbytes: Add an assertion to placate static analysis

See merge request GNOME/glib!4323
2024-10-01 14:04:13 +00:00
Michael Catanzaro
637ec98f2e Merge branch 'disable-assert-fix' into 'main'
gvariant: Fix unused variables when G_DISABLE_ASSERT is defined

See merge request GNOME/glib!4322
2024-10-01 13:57:04 +00:00
Philip Withnall
dfb0ea737b
gstdio: Move doc comment for g_clear_fd() to be next to the code
Nobody’s going to keep it up to date if it’s floating about in an
unrelated place, not next to the code.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-10-01 14:29:31 +01:00