Commit Graph

29406 Commits

Author SHA1 Message Date
Thomas Haller
3c09257ea1 glib: add internal g_uint_hash()/g_uint_equal()
We have g_int_hash()/g_int_equal(), which in practice might also work
with with pointers to unsigned integers. However, according to strict
interpretation of C, I think it is not valid to conflate the two.

Even if it were valid in all cases that we want to support, we should
still have separate g_uint_{hash,equal} functions (e.g. by just #define
them to their underlying g_int_{hash,equal} implementations).

Add instead internal hash/equal functions for guint.
2023-11-06 08:48:12 +01:00
Philip Withnall
734f8184e8 Merge branch 'gvalue-steal-string' into 'main'
gvalue: add "steal_string"

See merge request GNOME/glib!3695
2023-11-04 11:05:47 +00:00
Alexander Slobodeniuk
7880d87091 gvalue: add g_value_steal_string()
This call is needed to avoid an extra copy after
serialization of the data.
2023-11-04 10:40:30 +00:00
Philip Withnall
32e8a73efb tests: Refactor thread-pool-slow to separate test functions
Previously thread-pool-slow ran a single test which encoded a state
machine and polling timer to run 8 different sub-tests and check for
their exit conditions.

This was a bit ugly, and since the timer ran at 1s granularity, several
of the tests completed quite fast and then hang around for most of 1s
before finishing and moving to the next test.

Split the test functions up into separate GTest tests, and split the
state machine up between the test functions. All of the `GMainLoop`
handling is actually only needed for the `test_threadpool_idle_time()`
test.

This reduces the overall test runtime from 36s to 19s on my machine,
with 17s of that being spent in `test_threadpool_idle_time()`.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #2810
2023-11-03 12:10:49 +00:00
Philip Withnall
1195a7a638 tests: Move some global variables into local scope in thread-pool-slow
This makes things a bit more maintainable, as there’s less global state
to worry about.

It introduces no functional changes.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>
2023-11-03 11:40:44 +00:00
Philip Withnall
f0dbf6fe7c tests: Remove dead code from thread-pool-slow
This variable was never modified.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>
2023-11-03 11:38:41 +00:00
Philip Withnall
0b45f6208b tests: Fix a race in thread-pool-slow
The race was already acknowledged in the code (via `last_failed`): the
thread pool starts dequeuing jobs as soon as it’s created, so it’s
dequeuing the sorted thread IDs while they’re still being enqueued and
sorted. This can lead to them being dequeued out of the expected order
if new thread IDs are enqueued out of order, which is possible because
they’re randomly generated.

The test tried to handle this by allowing one out-of-order dequeue, but
it looks like the race can race hard enough that multiple out-of-order
dequeues are possible.

Fix that by only starting to dequeue the jobs from the thread pool once
they’ve all been enqueued and put in a total order.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Fixes: #2810
2023-11-03 11:14:51 +00:00
Philip Withnall
c37bf851e5 tests: Use g_assert_*() rather than g_assert() in stream-rw_all tests
It won’t get compiled out with `G_DISABLE_ASSERT`.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>
2023-11-02 17:49:31 +00:00
Philip Withnall
a0de4963e8 tests: Use a pipe rather than a socketpair in stream-rw_all test
The test only needs a unidirectional channel, and a pipe is sufficient
for that.

This may simplify things when running the test on Hurd; see
https://gitlab.gnome.org/GNOME/glib/-/issues/3148#note_1874198.

Additionally, set `O_NONBLOCK` on the pipe since the test seems to
expect that partial writes will succeed and that writes to a full buffer
will fail rather than block.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3148
2023-11-02 17:47:53 +00:00
Philip Withnall
7e7a6271fe Merge branch 'migrate-to-gi-docgen9' into 'main'
Switch to using gi-docgen for docs (batch 9)

See merge request GNOME/glib!3690
2023-11-02 17:01:19 +00:00
Philip Withnall
0fe15f9b9b docs: Move the GChecksum SECTION
Move it to the struct docs.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3037
2023-11-02 16:30:23 +00:00
Philip Withnall
9e95163a3c docs: Move the GZlib*Compressor SECTIONs
Move them to the struct docs.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3037
2023-11-02 16:30:23 +00:00
Philip Withnall
38c4809719 docs: Move the GWin32RegistryKey SECTION
Move it to the struct docs.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3037
2023-11-02 16:30:23 +00:00
Philip Withnall
754047849c docs: Move the GWin32*Stream SECTIONs
Move them to the struct docs.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3037
2023-11-02 16:30:23 +00:00
Philip Withnall
7df150eaac docs: Move the GVolumeMonitor SECTION
Move it to the struct docs.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3037
2023-11-02 16:30:23 +00:00
Philip Withnall
ed247401bf docs: Move the GVolume SECTION
Move it to the struct docs.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3037
2023-11-02 16:30:23 +00:00
Philip Withnall
830db4e3c0 docs: Move the GUnixSocketAddress SECTION
Move it to the struct docs.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3037
2023-11-02 16:30:23 +00:00
Philip Withnall
1390713af9 docs: Move the GUnix*Stream SECTIONs
Move them to the struct docs.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3037
2023-11-02 16:30:23 +00:00
Philip Withnall
68d3f6e53a docs: Move the GUnixCredentialsMessage SECTION
Move it to the struct docs.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3037
2023-11-02 16:30:23 +00:00
Philip Withnall
2be7859f10 docs: Move the GUnixConnection SECTION
Move it to the struct docs.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3037
2023-11-02 16:30:23 +00:00
Philip Withnall
78411d0975 docs: Move the GTlsDatabase SECTION
Move it to the struct docs.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3037
2023-11-02 16:30:23 +00:00
Philip Withnall
15ae12628d docs: Move the GTls*Connection SECTIONs
Move them to the struct docs.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3037
2023-11-02 16:30:23 +00:00
Philip Withnall
a463a29522 docs: Move the GTlsCertificate SECTION
Move it to the struct docs.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3037
2023-11-02 16:30:23 +00:00
Philip Withnall
45a815ae6d docs: Move the GSocketService SECTION
Move it to the struct docs.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3037
2023-11-02 16:30:23 +00:00
Philip Withnall
bf5c0cc2ba docs: Move the GSocketListener SECTION
Move it to the struct docs.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3037
2023-11-02 16:30:23 +00:00
Philip Withnall
1c34680833 docs: Move the GSocketAddressEnumerator SECTION
Move it to the struct docs.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3037
2023-11-02 16:30:23 +00:00
Philip Withnall
832bf0f90c docs: Move the GSimpleProxyResolver SECTIONs
Move them to the struct docs.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>
2023-11-02 16:30:23 +00:00
Philip Withnall
c16c639729 docs: Move the GSettings SECTIONs
Move them to the struct docs.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3037
2023-11-02 16:30:23 +00:00
Philip Withnall
8c3e0aa406 docs: Move the GRemoteActionGroup SECTION
Move it to the struct docs.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3037
2023-11-02 16:30:23 +00:00
Philip Withnall
bfa5d99305 docs: Move the GDBusObject SECTION
Move it to the struct docs.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3037
2023-11-02 16:30:23 +00:00
Philip Withnall
ac7cbb146e docs: Move the gtls SECTION
Move it to a separate Markdown page.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3037
2023-11-02 16:30:23 +00:00
Philip Withnall
1fdbc06385 meson: Add missing dependencies for utility files for gdbus-codegen
Various parts of the build (such as `objectmanager-rst-gen`) depend on
running `gdbus-codegen` after it’s been built, but they currently only
encode a dependency to the main codegen Python file and not the
supporting files. This can cause `gdbus-codegen` to fail with an
`ImportError` if the build races so that `objectmanager-rst-gen` is
built before the codegen supporting files.

Example failure here: https://gitlab.gnome.org/pwithnall/glib/-/jobs/3266471
```
FAILED: gio/tests/gdbus-object-manager-example/objectmanager-rst-gen-org.gtk.GDBus.Example.ObjectManager.Animal.rst gio/tests/gdbus-object-manager-example/objectmanager-rst-gen-org.gtk.GDBus.Example.ObjectManager.Cat.rst
/usr/bin/python3 gio/gdbus-2.0/codegen/gdbus-codegen --interface-prefix org.gtk.GDBus.Example.ObjectManager. --generate-rst objectmanager-rst-gen --output-directory gio/tests/gdbus-object-manager-example ../gio/tests/gdbus-object-manager-example/gdbus-example-objectmanager.xml
Traceback (most recent call last):
  File "/builds/pwithnall/glib/_build/gio/gdbus-2.0/codegen/gdbus-codegen", line 53, in <module>
    from codegen import codegen_main
  File "/builds/pwithnall/glib/_build/gio/gdbus-2.0/codegen/codegen_main.py", line 29, in <module>
    from . import dbustypes
  File "/builds/pwithnall/glib/_build/gio/gdbus-2.0/codegen/dbustypes.py", line 22, in <module>
    from . import utils
ImportError: cannot import name 'utils' from 'codegen' (/builds/pwithnall/glib/_build/gio/gdbus-2.0/codegen/__init__.py)
```

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>
2023-11-02 14:26:31 +00:00
Philip Withnall
aa936e12da Merge branch 'zbrown/gtask-prefix-error' into 'main'
gtask: Add g_task_return_prefixed_error()

See merge request GNOME/glib!3674
2023-11-02 12:53:03 +00:00
Philip Withnall
7785c5150a Merge branch 'ebassi/doc-gir-include-path' into 'main'
build: Fix the inclusion paths for GIR files in gi-docgen

See merge request GNOME/glib!3688
2023-11-02 12:26:01 +00:00
Emmanuele Bassi
3dbef3223b build: Fix the inclusion paths for GIR files in gi-docgen
The GIR files are now built by GLib itself, so they will be in the build
directories of each sub-library, except for GLib-2.0 which is built
alongside GObject-2.0.
2023-11-02 11:22:06 +00:00
Zander Brown
d33752b5ce
gtask: Add g_task_return_prefixed_error()
An equivalent to g_propagate_prefixed_error, but for errors sent though
GTask, allowing tasks to easily provide extra context to callers.
2023-11-02 02:55:55 +00:00
Philip Withnall
d1eb463ce2 gio-tool: Remove unnecessary exit() call
All the calls to `usage()` are immediately followed by a `return` from
`main()` which sets an appropriate exit status.

Calling `exit()` early means that running `gio --help` returns exit
status 1, which is incorrect — it should (by convention) return 0.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>
2023-11-02 00:50:21 +00:00
Philip Withnall
1969608db5 Merge branch 'wip/smcv/issue3157' into 'main'
tests: Don't assume that sh optimizes simple commands into exec

Closes #3157

See merge request GNOME/glib!3685
2023-11-01 22:33:07 +00:00
Philip Withnall
c1eb8ded7b Merge branch 'fix-gmessage-domain-drop' into 'main'
gmessages: fix dropping irrelevant log domains

See merge request GNOME/glib!3679
2023-11-01 22:24:46 +00:00
Alexander Slobodeniuk
ae8018d360 gmessages: fix dropping irrelevant log domains
If the string of one log domain is contained in
another, it was printing both.

For example, if G_MESSAGES_DEBUG is "Gtkspecial",
it would also keep the logs of the "Gtk" domain
2023-11-01 22:24:45 +00:00
Simon McVittie
76148fc6db tests: Don't assume that sh optimizes simple commands into exec
Depending on the operating system, /bin/sh might either be bash (for
example on Fedora or Arch) or dash (for example on Debian or Ubuntu)
or some other POSIX shell.

When bash is asked to run a simple command with no shell keywords or
metacharacters, like this one, it replaces itself with the program
via execve(), but dash does not have that optimization and treats it
like any other program invocation in a larger script: it will fork,
exec the program in the child, and wait for the child in the parent.

This seems like it conflicts with sleep_and_kill() assuming that it can
use the subprocess's process ID as the sleep(1) process ID. Specifically,
if it sends SIGKILL, it will go to the sh(1) process and not the sleep(1)
child, which could result in the sh(1) process being terminated and
its sleep(1) child being leaked.

To get the bash-like behaviour portably, explicitly use the exec builtin
to instruct the shell to replace itself with sleep(1), so that the
process ID previously used for the shell becomes the process ID of the
sleep process.

This appears to resolve an intermittent hang and test timeout on Debian
machines (especially slower ones), although I'm not 100% clear on the
mechanics of how it happens.

Resolves: https://gitlab.gnome.org/GNOME/glib/-/issues/3157
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-11-01 17:56:48 +00:00
Philip Withnall
6d38e8be22 Merge branch 'wip/pwithnall/macos-leak-sanitizer' into 'main'
glib: Disable dynamic asan loading on macOS

See merge request GNOME/glib!3683
2023-11-01 15:37:11 +00:00
Philip Withnall
6ab8062dbb Merge branch 'hurd-ci-fix' into 'main'
ci: Remove .build-linux from Hurd CI scheduled job

See merge request GNOME/glib!3665
2023-11-01 15:20:23 +00:00
Marco Trevisan
d1fcb4f253 Merge branch 'gio-test-dependencies' into 'main'
tests: Fix dependency of test.gresource on test-generated.txt

See merge request GNOME/glib!3682
2023-11-01 14:55:25 +00:00
Philip Withnall
3b4846611d glib: Disable dynamic asan loading on macOS
The weak symbol resolution doesn’t seem to work (see
https://gitlab.gnome.org/GNOME/glib/-/jobs/3265405):
```
Undefined symbols for architecture x86_64:
  "___lsan_enable", referenced from:
      _g_leak_sanitizer_is_supported in gutils.c.o
  "___lsan_ignore_object", referenced from:
      _g_ignore_leak in gquark.c.o
      _g_ignore_leak in gthreadpool.c.o
      _g_ignore_leak in gutils.c.o
      _g_leak_sanitizer_is_supported in gutils.c.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
```

See !3672

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>
2023-11-01 14:34:37 +00:00
Philip Withnall
5ff31ae57d Merge branch 'zbrown/fix-4ce58df8' into 'main'
codegen: install codegen, not just the wrapper

Closes #3161

See merge request GNOME/glib!3670
2023-11-01 14:22:29 +00:00
Philip Withnall
a61888bceb tests: Fix dependency of test.gresource on test-generated.txt
`test-generated.txt` is listed in `test.gresource.xml`, so it needs to
be specified as a dependency in the `custom_target()` which uses
`test.gresource.xml`.

Fixes intermittent build failures like:
```
FAILED: gio/tests/test.gresource
/builds/GNOME/glib/_build/gio/glib-compile-resources --compiler=gcc --target=gio/tests/test.gresource --sourcedir=/builds/GNOME/glib/gio/tests --sourcedir=/builds/GNOME/glib/_build/gio/tests --internal ../gio/tests/test.gresource.xml
../gio/tests/test.gresource.xml: Failed to locate test-generated.txt in any source directory.
```

See !3671 and #3163.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>
2023-11-01 11:24:17 +00:00
Philip Withnall
9695ddfc70 Revert "gio/tests: Add test generated txt as the resources test dependency"
This reverts commit 0b9900e4e7.

The dependency was added in the wrong place: `test-generated.txt` is
needed when compiling `test.gresource`, not when compiling the test
which ultimately uses that gresource.

See !3671 and #3163.
2023-11-01 11:10:39 +00:00
Philip Withnall
f3f23b0229 Merge branch 'gsignalgroup-avoid-g-return-macro' into 'main'
gsignalgroup: Avoid function call with side effect in g_return_* macro

See merge request GNOME/glib!3678
2023-11-01 10:53:55 +00:00
Kleis Auke Wolthuizen
9ec6c19342 gsignalgroup: Avoid function call with side effect in g_return_* macro 2023-11-01 10:53:55 +00:00