Commit Graph

27670 Commits

Author SHA1 Message Date
Marco Trevisan
6f6692562f Merge branch 'adapt_gsignal_changes' into 'main'
gobject_gdb.py: adapt to recent gsignal changes

See merge request GNOME/glib!3465
2023-06-07 10:27:51 +00:00
Philip Withnall
1f1378b80e Merge branch 'add-space' into 'main'
resolver: Add space in documentations

See merge request GNOME/glib!3466
2023-06-07 10:25:25 +00:00
Maximiliano Sandoval R
389398d444
resolver: Add space in documentations
It is standard practice to put a space in between Returns and Since in docstrings.
2023-06-04 17:33:00 +02:00
Nelson Benítez León
c301542f81 gobject_gdb.py: adapt to recent gsignal changes
Add to script the new functions added in
commit 2368187e and commit e5ee6e14 which are:

signal_emitv_unlocked()
signal_emit_valist_unlocked()

so that the "<emit signal 'blabla'>" line keeps
showing after them.
2023-06-02 14:42:45 +01:00
Leônidas Araújo
3304a517d9 Update Brazilian Portuguese translation
(cherry picked from commit 7f8bb8a2ea)
2023-06-01 18:25:18 +00:00
Philip Withnall
8764fe4740 Merge branch 'wip/pwithnall/done-with-macos' into 'main'
ci: Disable the macOS CI

See merge request GNOME/glib!3463
2023-06-01 14:13:41 +00:00
Philip Withnall
ef6e8939aa ci: Disable the macOS CI
It’s almost a complete waste of time at the moment. For several reasons,
jobs flakily fail on it more often than they succeed. It’s wasting
resources, slowing down development and making people quite frustrated.

 * https://gitlab.gnome.org/Infrastructure/GitLab/-/issues/627
 * https://gitlab.gnome.org/GNOME/glib/-/issues/2949
 * https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3462 and related
   test failures

Nobody has stepped up to deal with the test or CI runner flakiness, or
generally maintain this CI runner. If someone does care about preventing
regressions for GLib on macOS, and can put time into making the CI
reliable, then this commit can be reverted.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-06-01 14:51:21 +01:00
Philip Withnall
d861eee868 Merge branch 'wip/smcv/async-signal-safety' into 'main'
gstdio: Improve documentation of some functions as async-signal safe

See merge request GNOME/glib!3458
2023-06-01 13:42:54 +00:00
Philip Withnall
da0a945477 tests: Reduce thread and iteration count on CI for /thread/rec-mutex3
It’s fairly consistently timing out on macOS. Looking at the verbose
test output, it’s still making progress right up until when it times out
(i.e. it hasn’t hit a `GRecMutex` bug and hasn’t deadlocked), so it
seems that the test runner is just hopelessly overloaded/underpowered
for the number of threads and iterations we’re asking it to test.

Tone those numbers down for CI test runs then.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-06-01 12:19:09 +01:00
Philip Withnall
add5fceedb tests: Move /thread/rec-mutex3 test state into a struct
And dynamically allocate the arrays. This will allow the scale of the
test to be configured in the following commit, which will allow it to be
tweaked to not time out on slow CI runners.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-06-01 12:12:38 +01:00
Philip Withnall
9db8765e21 tests: Use g_assert_*() rather than g_assert() in rec-mutex tests
It won’t get compiled out with `G_DISABLE_ASSERT`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-06-01 11:53:19 +01:00
Philip Withnall
10fb2db8f7 Merge branch 'test-timing' into 'main'
gtestutils: print timing information per test case in TAP output

See merge request GNOME/glib!3420
2023-06-01 10:48:15 +00:00
Daniel P. Berrangé
29311d4309 gtestutils: print execution time after every test
Displaying the execution time will aid developers in understanding which
test cases are responsible for slow execution times. The test code is
already measuring the execution time for every test case, but is not
reporting that data anywhere accessible to developers running the tests.

The new code will print a TAP comment:

  # slow test /the/test/path executed in NN.NN secs

for any test taking longer than 0.5 seconds to run.

Example new output format:

  $ ./build/glib/tests/unix
  TAP version 13
  # random seed: R02S690dc3c7a04866e4890501eedc7f8eef
  1..13
  # Start of glib-unix tests
  ok 1 /glib-unix/pipe
  # /glib-unix/pipe-stdio-overwrite summary: Test that g_unix_open_pipe() will use the first available FD, even if it?s stdin/stdout/stderr
  # Bug Reference: https://gitlab.gnome.org/GNOME/glib/-/issues/2795
  ok 2 /glib-unix/pipe-stdio-overwrite
  ok 3 /glib-unix/error
  ok 4 /glib-unix/nonblocking
  ok 5 /glib-unix/sighup
  # slow test /glib-unix/sighup executed in 0.50 secs
  ok 6 /glib-unix/sigterm
  # slow test /glib-unix/sigterm executed in 0.50 secs
  ok 7 /glib-unix/sighup_again
  # slow test /glib-unix/sighup_again executed in 0.50 secs
  ok 8 /glib-unix/sighup_add_remove
  ok 9 /glib-unix/sighup_nested
  ok 10 /glib-unix/callback_after_signal
  # slow test /glib-unix/callback_after_signal took 2.00 secs
  ok 11 /glib-unix/child-wait
  # Start of get-passwd-entry tests
  # /glib-unix/get-passwd-entry/root summary: Tests that g_unix_get_passwd_entry() works for a known-existing username.
  ok 12 /glib-unix/get-passwd-entry/root
  # /glib-unix/get-passwd-entry/nonexistent summary: Tests that g_unix_get_passwd_entry() returns an error for a nonexistent username.
  ok 13 /glib-unix/get-passwd-entry/nonexistent
  # End of get-passwd-entry tests
  # End of glib-unix tests

As a practical usage example, the meson log can be queried to find
slow tests project-wide:

  $ grep 'slow test' build/meson-logs/testlog.txt | sort -n -k 7 -r | head
  # slow test /threadpool/basics executed in 36.04 secs
  # slow test /gobject/refcount/properties-3 executed in 30.00 secs
  # slow test /gio/io-basics executed in 12.54 secs
  # slow test /timeout/rounding executed in 10.60 secs
  # slow test /GObject/threaded-weak-ref executed in 10.42 secs
  # slow test /thread/rerun-all executed in 9.84 secs
  # slow test /gobject/refcount/object-advanced executed in 5.46 secs
  # slow test /thread/static-rw-lock executed in 5.00 secs
  # slow test /gobject/refcount/signals executed in 5.00 secs
  # slow test /gobject/refcount/signals executed in 5.00 secs

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2023-06-01 11:29:46 +01:00
Philip Withnall
fbc66b834e Merge branch 'mcatanzaro/#2829' into 'main'
Improve depfile generated by glib-compile-resources

Closes #2829

See merge request GNOME/glib!3460
2023-06-01 09:36:15 +00:00
Michael Catanzaro
3e3a0304f7 Improve depfile generated by glib-compile-resources
glib-compile-resources --dependency-file= currently generates a depfile
with rules that look like this:

foo.xml: resource1 resource2

This means that if any of the files listed in the GResource manifest
foo.xml change, rebuild foo.xml because foo.xml depends on those files.
This is not useful because the XML manifest is not expected to be a
generated dependency and even if it was, changes to the listed files
would not imply any need to regenerate the manifest. What we really do
need to regenerate is the C source file that is generated by
glib-compile-resources after processing the XML manifest and all the
resource files. That is, the rule should look like this:

foo.c: foo.xml resource1 resource2

as suggested by Hans Ulrich Niedermann in the issue report.

Fixes #2829
2023-05-31 14:50:21 -05:00
Daniel P. Berrangé
b6ce20329a gtestutils: use an enum for test case result fields
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2023-05-31 20:47:22 +01:00
Simon McVittie
0d86ee0a86 gstdio: Improve documentation of g_clear_fd() as async-signal safe
Add cross-references as requested for similar new API in !3457.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-05-31 16:34:16 +01:00
Simon McVittie
9af6b7e4e7 gstdio: Improve documentation of g_close() as async-signal safe
Add cross-references as requested for similar new API in !3457.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-05-31 16:34:14 +01:00
Philip Withnall
7a82da2992 Merge branch 'wip/smcv/steal-fd-preserves-errno' into 'main'
gmain: Document that g_steal_fd() preserves errno

See merge request GNOME/glib!3456
2023-05-31 14:34:33 +00:00
Philip Withnall
2d6073fae2 Merge branch 'symlink-target-filename' into 'main'
gfileinfo: add (type filename) annotation to symlink_target functions

See merge request GNOME/glib!3455
2023-05-31 08:46:13 +00:00
Jason Francis
c556a4d8f8
gfileinfo: add (type filename) annotation to symlink_target functions 2023-05-31 00:54:38 -04:00
Emmanuele Bassi
6fc6d9ea3e Merge branch 'ebassi/keyfile-docs' into 'main'
docs: Use the type name as the section name for GKeyFile

See merge request GNOME/glib!3453
2023-05-31 01:05:34 +00:00
Emmanuele Bassi
e8440ddcf9 Merge branch 'ebassi/type-table-docs' into 'main'
Allow proper introspection of GTypeValueTable

See merge request GNOME/glib!3441
2023-05-30 23:26:54 +00:00
Michael Catanzaro
b7d5e4bc19 Merge branch 'mcatanzaro/#2832' into 'main'
Fix: GSocketClient cannot proxy connect unless default port is explicitly specified in proxy URL

Closes #2832

See merge request GNOME/glib!3451
2023-05-30 16:50:40 +00:00
Simon McVittie
c97348428f gmain: Document that g_steal_fd() preserves errno
This is useful when writing similarly low-level code, and was always true
as implemented here; let's document it so that other codebases can rely
on it.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-05-30 16:02:16 +01:00
Michael Catanzaro
d624c850b2 Add some tests for socks:// URI default ports
This also tests socks5h:// which we don't actually support yet, just to
make sure it works, which it does.
2023-05-30 09:55:39 -05:00
Michael Catanzaro
cc5bb80b9a Fix failure to respect default port of proxy URLs
Currently we require explicitly specifying the port when configuring a
proxy server, which is seriously weird. I take the fact that nobody
reported a bug until 2022 to indicate that almost nobody is using
proxies. Whatever. Let's assume that if no port is provided, the default
port for the protocol should be used instead.

For example, you can now specify in GNOME settings that your proxy server
is https://example.com and it will work. Previously, you had to write
https://example.com:443. Yuck!

This was originally reported as GProxyResolver bug, but nothing is
actually wrong there. It's actually GProxyAddressEnumerator that gets
tripped up by URLs returned by GProxyResolver without a default port.
This breaks GSocketClient.

Fixing this requires exposing GUri's _default_scheme_port() function to
GIO. I considered copy/pasting it since it's not very much code, but I
figure the private call mechanism is probably not too expensive, and I
don't like code duplication.

Fixes #2832
2023-05-30 09:49:43 -05:00
Michael Catanzaro
42cb8dfb95 guri: the default port for SOCKS URLs is 1080
This is true for socks://, socks4://, socks4a://, and socks5://. I could
list them individually and risk breaking in the future if socks6:// ever
exists, or test for "socks" and risk breaking if a future URL scheme
begins with "socks" but doesn't use port 1080. I picked the latter.
2023-05-30 09:49:43 -05:00
Philip Withnall
5c50aec060 Merge branch 'glib-mkenums_parse_trigraph' into 'main'
Take double-quote characters into account when parsing trigraph

Closes #65

See merge request GNOME/glib!3452
2023-05-30 14:45:54 +00:00
Philip Withnall
fe458559d8 Merge branch 'gsignal-emission-locks-cleanups' into 'main'
gsignal: Reduce lock/unlock pairs and ensure we always work on valid signal nodes

See merge request GNOME/glib!2824
2023-05-30 13:57:27 +00:00
Emmanuele Bassi
d4f2db270f Annotate GTypeValueTable callbacks for availability
The compiler annotations are mainly useful for people using the symbols
directly.

To avoid getting compiler warnings for the GTypeValueTable definition
itself, we need to wrap the structure with
G_GNUC_BEGIN_IGNORE_DEPRECATIONS and G_GNUC_END_IGNORE_DEPRECATIONS.
2023-05-30 14:38:16 +01:00
Emmanuele Bassi
23a9dbdaf6 Allow proper introspection of GTypeValueTable
The introspection scanner cannot deal very well with function pointers
into a plain structure. In order to document the various function
pointers in GTypeValueTable we need to create typed callbacks, and
use them to replace the anonymous function pointers inside the
structure. This not only allows us to properly document the function
pointers, but it also allows us to annotate the arguments and return
value of those function pointers.

See also: https://gitlab.gnome.org/GNOME/gobject-introspection/-/merge_requests/400#note_1721707
2023-05-30 14:38:16 +01:00
Philip Withnall
32ec11e51d Merge branch 'free-sized-macro' into 'main'
gmem: Add an inline definition of g_free() to automatically use g_free_sized()

See merge request GNOME/glib!3252
2023-05-30 13:29:25 +00:00
Emmanuel Fleury
7e5607d534 Take double-quote characters into account when parsing trigraph
For now, the function parse_trigraph() defined in gobject/glib-mkenums
script was not taking double-quotes characters into account:

>>> parse_trigraph('name="eek, a comma"')
{'name': '"eek', 'a': None}

This patch take double-quotes characters into account:

>>> parse_trigraph('name="eek, a comma"')
{'name': 'eek, a comma'}

Closes issue #65
2023-05-30 15:22:05 +02:00
Philip Withnall
1aefcf4e0e Merge branch 'ok/termux-build-issues' into 'main'
gio, tests: adaptations for building with bionic libc from termux

Closes #3008

See merge request GNOME/glib!3443
2023-05-30 13:04:17 +00:00
Marco Trevisan (Treviño)
2e1ceb9563 gsignals: Do not zero two times the instance GValue's GType
We already use g_new0 to create such arrays and nothing writes in the first
pointer till this point, so no need to zero it again.
2023-05-30 13:52:08 +01:00
Marco Trevisan (Treviño)
76ed55f3a7 gsignal: Use static allocation if we've just few emission hooks
Normally we don't really have emission hooks around, so try to allocate
only tiny array to contain a few of them and in case we exceed that limit,
we go back to use allocated ones.
2023-05-30 13:52:08 +01:00
Marco Trevisan (Treviño)
bfc599b8a2 gsignal: Reduce lock/unlock operations when calling signal_emit_unlocked_R
We used to call this function as unlocked, with a node value that
could be invalid at the point of the call, so let's ensure that when
we call such function it's defined, and then reduce the access to the
signal node members when we're unlocked or after a lock/unlock operation
that may have changed it.

As per this, add more tests handling multiple signal hooks cases that we
did not cover before.
2023-05-30 13:52:08 +01:00
Marco Trevisan (Treviño)
e5ee6e141d gsignal: Cleanup g_signal_emitv splitting it in locked and unlocked paths
It just makes code easier to maintain and more clearly scoped.
2023-05-30 13:52:08 +01:00
Marco Trevisan (Treviño)
f011910395 gsignal: Do not try to access to node members when unlocked
In g_signal_emit_valist() we used to access to param types array and
n_params values after unlocking the mutex, and this might have lead to
making such values unreliable for the current call.

So let's keep them around until we're done with the function call
2023-05-30 13:52:07 +01:00
Marco Trevisan (Treviño)
2368187eb9 gsignal: Avoid possible race in g_signal_emit_by_name
Since we're locking and unlocking once we've found the signal ID, we
might have performed calls to g_signal_emit_valist() with a signal id
that was already been removed, and thus failing later.

This is not really an issue as inside g_signal_emit_valist() we were
re-checking for the signal id, but we can make this more reliable so
that the first thread that acquires the lock can also be sure to emit.
2023-05-30 13:52:07 +01:00
Marco Trevisan (Treviño)
0bc725d4fe gobject/tests/signals: Add tests for g_object_emitv
It's very much used by bindings but we didn't really test it locally.
2023-05-30 13:52:07 +01:00
Philip Withnall
c0bdc61879 meson: Export HAVE_FREE_SIZED in glibconfig.h for use in g_free()
This allows the `g_free()` wrapper introduced in the previous commit to
only be defined if `free_sized()` is actually available to improve
performance.

This avoids passing an allocation size to every `g_free()` call if it’s
not going to be used, saving a register store instruction each time.

Suggested by Marco Trevisan in
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3252#note_1660032

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-05-30 13:45:05 +01:00
Marco Trevisan (Treviño)
c580b5c2f4 gmem: Add an inline definition of g_free() to automatically use g_free_sized()
When using GCC we can take the advantage of __builtin_object_size() to
know the allocated size of a memory area, this generally only works when
some optimization level enabled (-O1 seems enough here) and can provide
us with memory size information for lower-level optimizations.
2023-05-30 13:43:25 +01:00
Emmanuele Bassi
28e8f5c136 docs: Rename the GBookmarkFile section
Use the type name, to ensure that the section docblock gets merged into
the type docblock in the introspection data.

Helps: #2961
2023-05-30 13:33:45 +01:00
Philip Withnall
ad464d5563 Merge branch 'main' into 'main'
gio/tests/portal-support: Fix snap test ordering race

Closes #3020

See merge request GNOME/glib!3454
2023-05-30 12:29:06 +00:00
Philip Withnall
0196a36022 Merge branch 'more-atomic-exchange-full' into 'main'
gdataset, gobject: Use atomic compare and exchange full to set pointers

See merge request GNOME/glib!3426
2023-05-30 11:59:40 +00:00
Emmanuele Bassi
4386d912d7 docs: Use the type name as the section name for GKeyFile
Without this, the section docblock for GKeyFile disappears into the
ether when generating the introspection data.

Helps: #2961
2023-05-30 12:46:30 +01:00
Marco Trevisan (Treviño)
ea904fba1a gresource: Use compare and exchange full to get registered resources 2023-05-30 12:34:41 +01:00
Philip Withnall
28f83c9cf7 gresource: Ensure lazy_register_resources is always accessed atomically
On some platforms, pointer-sized reads are not necessarily atomic, so we
always need to use the correct atomic access primitives.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-05-30 12:33:48 +01:00