Commit Graph

30071 Commits

Author SHA1 Message Date
Emmanuele Bassi
1a5b1393bd Add unref-to-strv to GStrvBuilder
For those projects that cannot use `g_autoptr()`, GStrvBuilder's end
plus unref is not really convenient.

We can crib the "unref to data type" model from GBytes, and have an
additional unref function that also returns the just built GStrv.
2024-03-22 00:08:26 +00:00
Philip Withnall
afcb839121 Merge branch '3286-strfuncs-annotations' into 'main'
gstrfuncs: Add missing (transfer none) annotations for several funcs

Closes #3286

See merge request GNOME/glib!3963
2024-03-21 23:33:07 +00:00
Emmanuele Bassi
6946c79c7d Merge branch 'version-bump' into 'main'
build: Post-release version bump

See merge request GNOME/glib!3975
2024-03-21 23:30:42 +00:00
Philip Withnall
0cb5a86745 build: Post-release version bump
This opens up the development cycle for 2.82.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-03-20 11:54:39 +00:00
Philip Withnall
e583a35096 Merge branch 'wip/chergert/fix-gvariant-compile' into 'main'
glib/gvariant: fix compile error with GCC 14.0.1

See merge request GNOME/glib!3973
2024-03-20 11:44:17 +00:00
Philip Withnall
bb0e2dc375 Merge branch 'port-gaction-comments-1' into 'main'
Ported the first few documentation comments in `gio/gaction.c` to gi-docgen

See merge request GNOME/glib!3969
2024-03-20 11:34:33 +00:00
Sudhanshu Tiwari
fa5237650b Ported the first 3 documentation comments in gaction.c to gi-docgen 2024-03-20 11:34:33 +00:00
Christian Hergert
e5409374b2 glib/gvariant: fix compile error with GCC 14.0.1
This was erroring on recent GCC because `struct heap_dict` is smaller than
the publicly provided size (guintptr[16]) in the header for GVariantDict.

Port to use `g_malloc()` directly, and use a static assertion to ensure
we’re allocating the larger of the two struct sizes.
2024-03-20 11:18:11 +00:00
Philip Withnall
9828b50b99 Merge branch 'hurd-test-failures' into 'main'
tests: Mark several additional tests as can_fail on GNU Hurd

See merge request GNOME/glib!3974
2024-03-19 13:16:23 +00:00
Philip Withnall
e83e4c5535 tests: Mark several additional tests as can_fail on GNU Hurd
These consistently fail on scheduled CI runs, which is not helping our
ability to catch Hurd regressions.

For example, https://gitlab.gnome.org/GNOME/glib/-/jobs/3709402

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

See: #3148
2024-03-19 13:01:26 +00:00
Philip Withnall
5b9dac546e Merge branch 'th/performance' into 'main'
[th/performance] add script for combining performance results

See merge request GNOME/glib!3954
2024-03-18 15:07:03 +00:00
Philip Withnall
9d9029c50a Merge branch 'th/gobject-toggle-refs-check' into 'main'
[th/gobject-toggle-refs-check] Fix critical warning for toggle notifications in g_object_ref()/g_object_unref()

See merge request GNOME/glib!3959
2024-03-18 14:21:29 +00:00
Thomas Haller
4d5047e0e7 tests/performance: add performance-run.sh script for running performance test
The main use of the performance test is to run it for two (or more) commits
and compare the results. Doing that manually, is cumbersome.

Add a (very hacky) script to help with that. For usage, see the comment
on top of the script.

Example:

  # first:
  meson build -Dprefix=/tmp/glib/ -Db_lto=true --buildtype release -Ddebug=true

  # then:
  GLIB_PERFORMANCE_FACTOR=17.06 \
  PERF='perf stat -r 4 -B' \
  PATCH="2.80.0..th/performance" \
  COMMITS="2.79.3 2.80.0" \
  /tmp/performance-run.sh -s 1 property-get property-set

This will build the requested $COMMITS and print something like:

  ...
  >>> combined result > /tmp/glib-performance-output.all
  Running test property-get
  property-get: Property get per second: 35742719 37208288 (+4.1%)
  Running test property-set
  property-set: Property set per second: 32341232 36942399 (+14.2%)
  Running test property-get
  property-get: Property get per second: 36934401 37143479 (+0.566%)
  Running test property-set
  property-set: Property set per second: 38046387 38165548 (+0.313%)
  Running test property-get
  property-get: Property get per second: 34759576 36359761 (+4.6%)
  Running test property-set
  property-set: Property set per second: 35262505 37651733 (+6.78%)
  Running test property-get
  property-get: Property get per second: 37014537 32870906 (-11.2%)
  Running test property-set
  property-set: Property set per second: 36633026 38216846 (+4.32%)

   Performance counter stats for './build/gobject/tests/performance/performance -s 1 property-get property-set' (4 runs):

            1,312.18 msec task-clock:u                     #    1.000 CPUs utilized               ( +-  4.82% )
                   0      context-switches:u               #    0.000 /sec
                   0      cpu-migrations:u                 #    0.000 /sec
                 121      page-faults:u                    #   92.213 /sec                        ( +-  0.24% )
       5,221,701,009      cycles:u                         #    3.979 GHz                         ( +-  2.61% )
      19,035,814,175      instructions:u                   #    3.65  insn per cycle              ( +-  0.00% )
       4,335,306,010      branches:u                       #    3.304 G/sec                       ( +-  0.00% )
              13,031      branch-misses:u                  #    0.00% of all branches             ( +-  4.17% )
                          TopdownL1                 #     10.3 %  tma_backend_bound
                                                    #      5.3 %  tma_bad_speculation
                                                    #     11.4 %  tma_frontend_bound
                                                    #     73.1 %  tma_retiring             ( +-  2.15% )

  [1]             1.3127 +- 0.0634 seconds time elapsed  ( +-  4.83% )
  [2]             1.2631 +- 0.0253 seconds time elapsed  ( +-  2.00% )

  property-get: Property get per second: 35742719 , 36934401 , 34759576 , 37014537  ;  37208288 , 37143479 , 36359761 , 32870906  ;
  property-set: Property set per second: 32341232 , 38046387 , 35262505 , 36633026  ;  36942399 , 38165548 , 37651733 , 38216846  ;
2024-03-18 13:56:03 +00:00
Thomas Haller
7b9e6d4949 tests/performance: add "refcount-toggle" test
Performance test for emitting toggle reference notifications.
2024-03-18 13:56:03 +00:00
Thomas Haller
2b1a7e30b1 tests/performance: avoid check for toggle notification in "property-{get,set}"
Bumping the reference count from 1 to 2 (and back) is more expensive,
due to the check for toggle notifications.

We have a performance test already that hits that code path. Avoid that
for he "property-{get,set}" tests, so we avoid the known overhead and
test more relevant parts.
2024-03-18 13:56:02 +00:00
Thomas Haller
b6789dd1ea tests/performance: add "refcount-1" test
When an object has ref-count 1, then calling g_object_ref() requires a
check for toggle references. That is slower. Add a test for that case.
2024-03-18 13:56:02 +00:00
Thomas Haller
282d536fd2 tests/performance: ensure to always warm up for 2 seconds
Despite all the efforts, there still seems to be a lot of noise in the
performance measurement. Especially, the first iterations seem to run
faster. Maybe that is because the kernel didn't yet determine that the
process is CPU bound and is less likely to schedule it out Or maybe it's
because burning the cycles heats up the CPU and it gets throttled after
a while. It's unclear why, and it's even unclear whether this really
happens. But from my observations, it seems to do.

Hence, more warm up.

- the first time we enter the test, ensure that we keep the CPU busy for
  at 2 seconds. This additional warm up (WARM_UP_ALWAYS_SEC) is
  global, and not per test.

- for each test, ignore the first 5% of the runs. It seems those tend to
  run faster, thus skewing the results.

- if the user specifies a "--factor", the warm up operations are the
  same and independent from external factors (such as time
  measurements).

Note that this matters the most, when you want to run the executable
twice in a row and compare the results.
2024-03-18 13:56:02 +00:00
Thomas Haller
29a69d5a1b tests/performance: add "factor" argument to performance test
By default, the test estimates a run factor for each test. This means,
if you run performance under `perf`, the results are not comparable,
as the run time depends on the estimated factor.

Add an option, to set a fixed factor.

Of course, there is only one factor argument for all tests.  Quite
possibly, you would want to run each test individually with a factor
appropriate for the test. On the other hand, all tests should be tuned
so that the same factor gives a similar test duration. So this may not
be a concern, or the tests should be adjusted. In any case, the option
is most useful when running only one test explicitly.

You can get a suitable factor by running the test once with "--verbose".

Another use case is if you run the benchmark under valgrind. Valgrind
slows down the run so much, that the estimated factor would be quite
off. As a result, the chosen code paths are different from the real run.
By setting the factor, the timing measurements don't affect the executed
code.
2024-03-18 13:56:02 +00:00
Thomas Haller
e5e3c37d22 tests/performance: add "--quiet" argument to performance
The default output is annoyingly verbose. You see

  Running test simple-construction
  simple-construction: Millions of constructed objects per second: 33.498
  Running test simple-construction1
  simple-construction1: Millions of constructed objects per second: 142.493
  Running test complex-construction
  complex-construction: Millions of constructed objects per second: 14.304
  Running test complex-construction1
  ...

where the "Running test" lines just clutter the output. In fact so much
so, that my terminal fills up and I don't see the output of all tests in
one page. The "Running test" line is not so useful, because I mostly
care about the test result, and that line already contains the test
name.

Add an option to silence this.
2024-03-18 13:56:02 +00:00
Thomas Haller
65a59bde57 tests/performance: print result in unique line
Previously, the result lines are not unique, for example

  Running test simple-construction
  Millions of constructed objects per second: 27.629
  Running test simple-construction1
  Millions of constructed objects per second: 151.879
  ...

That is undesirable, because we might want to parse the test results
with a script, and that's easier when the line is unique.

Change to:

  Running test simple-construction
  simple-construction: Millions of constructed objects per second: 27.629
  Running test simple-construction1
  simple-construction1: Millions of constructed objects per second: 151.879
  ...
2024-03-18 13:56:02 +00:00
Thomas Haller
1b298d1db1 gobject: add code comment about unlock and toggle_refs_check_and_ref_or_deref()
It may not be obvious, but the moment unlock is called, the locker
instance may be destroyed.

See g_object_unref(), which calls toggle_refs_check_and_ref_or_deref().
It will check for toggle references while dropping the ref count from 2
to 1.  It must decrement the ref count while holding the lock, but it
also must still unlock afterwards.

Note that the locker instance is on the object itself. Once we decrement
the ref count we give up our reference and another thread may race
against destroying the object. We thus must not touch object anymore.
How can we then still unlock?

This works correctly because:

- unlock operations must not touch the locker instance after unlocking.

- assume that another thread races g_object_unref() to destroy the
  object, while we are about to call object_bit_unlock() in
  toggle_refs_check_and_ref_or_deref(). Then that other thread will also
  need to acquire the same lock (during g_object_notify_queue_freeze()).
  It thus is blocked to destroy the object.

Add code comments about that.
2024-03-18 13:55:36 +00:00
Thomas Haller
f17cfcf930 gobject: extract duplicate code for toggle reference in g_object_unref()
Move comment logic to one place. Add toggle_refs_check_and_ref_or_deref().
2024-03-18 13:55:36 +00:00
Thomas Haller
1bb5661198 gobject: fix racy assertion for toggle-refs
We can only assert for having one toggle reference, after we confirmed
(under lock) that the ref count was in the toggle case.

Otherwise, if another thread refs/unrefs the object, we can hit a wrong
g_critical() assertion about

  if (tstackptr->n_toggle_refs != 1)
    {
      g_critical ("Unexpected number of toggle-refs. g_object_add_toggle_ref() must be paired with g_object_remove_toggle_ref()");

Fixes: 9ae43169cf ('gobject: fix race in toggle ref during g_object_ref()')
2024-03-18 13:55:36 +00:00
Daniel Rusek
58e9e41757 Update Czech translation 2024-03-18 11:34:19 +00:00
Philip Withnall
94e326bb89 Merge branch 'wip/smcv/signedness' into 'main'
girparser: Adjust signedness() macro

See merge request GNOME/glib!3972
2024-03-18 11:25:21 +00:00
Simon McVittie
d9ee53d0eb girparser: Add a pseudo-doc-comment for signedness()
We could consider adding this to gmacros if it's useful anywhere else.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-03-18 10:48:31 +00:00
Simon McVittie
c7e0f3e6b8 girparser: Adjust signedness() to avoid compiler warnings
No functional change intended.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-03-18 10:45:28 +00:00
Philip Withnall
8c9b9bca35 Merge branch 'wip/smcv/inline-sizeof' into 'main'
girparser: Make sizes in integer_aliases more obviously correct

See merge request GNOME/glib!3970
2024-03-18 10:34:01 +00:00
Philip Withnall
7cd72ac7c4 Merge branch 'wip/smcv/girxml-timet' into 'main'
girparser: Allow time_t, off_t, etc. to appear in GIR XML

See merge request GNOME/glib!3967
2024-03-18 10:33:10 +00:00
Emmanuele Bassi
308b06d352 Merge branch 'wip/smcv/sizet-is-still-not-intptrt' into 'main'
girparser: Don't assume sizeof(size_t) == sizeof(void *)

See merge request GNOME/glib!3966
2024-03-17 14:17:53 +00:00
Simon McVittie
31b9c2f589 girparser: Make sizes in integer_aliases more obviously correct
We don't actually need to use the Meson-detected size macros here,
because the result of `sizeof()` is an integer constant expression.

No functional change.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-03-17 12:34:09 +00:00
Simon McVittie
fa45ea2ac9 girparser: Allow time_t, off_t, etc. to appear in GIR XML
g-ir-scanner currently maps these to lower-level types at scan time by
assuming that time_t is an alias for long, off_t is an alias for size_t
and so on. This is not always accurate: some ILP32 architectures have
64-bit time_t (for Y2038 compatibility) and 64-bit off_t (for large file
support), and that mismatch is tracked as GNOME/gobject-introspection#494.

One option for resolving this g-ir-scanner bug is to have it pass these
types through to the GIR XML, and teach g-ir-compiler and its replacement
gi-compile-repository to convert them to the corresponding concrete
type tag, as they already do for abstract types such as `long long` and
`size_t`.

Loosely based on GNOME/gobject-introspection!451 by Shuyu Liu.

Co-authored-by: Shuyu Liu <liushuyu011@gmail.com>
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-03-16 10:25:30 +00:00
Simon McVittie
d2a6c379e8 girparser: Don't assume sizeof(size_t) == sizeof(void *)
We don't actually need to use the results of configure-time checks here:
sizeof is a perfectly reasonable integer constant expression, so we can
use that directly.

Helps: https://gitlab.gnome.org/GNOME/glib/-/issues/2842
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-03-16 10:24:58 +00:00
Emmanuele Bassi
e64a93269d Merge branch 'wip/smcv/lint-env' into 'main'
tests: Provide G_TEST_SRCDIR, G_TEST_BUILDDIR to lint scripts

Closes #3289

See merge request GNOME/glib!3968
2024-03-16 00:04:09 +00:00
Simon McVittie
6da055b5ab tests: Provide G_TEST_SRCDIR, G_TEST_BUILDDIR to lint scripts
These scripts use $(readlink -f) to guess their own path if necessary,
but macOS readlink doesn't support the -f option, and POSIX doesn't
guarantee that readlink even exists.

Resolves: https://gitlab.gnome.org/GNOME/glib/-/issues/3289
Fixes: d7601f7e "Incorporate some lint checks into `meson test`"
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-03-15 15:15:21 +00:00
Vincent Chatelain
968372a619 Update French translation 2024-03-14 18:23:47 +00:00
Piotr Drąg
27f7d7ca18 Update Polish translation 2024-03-14 13:47:35 +00:00
Fran Dieguez
d990779dc6 Update Galician translation 2024-03-14 09:17:38 +00:00
Michael Catanzaro
c6d4fef43c Merge branch '3287-docs-dirs' into 'main'
docs: Reduce nesting of documentation directories

Closes #3287

See merge request GNOME/glib!3964
2024-03-13 21:16:48 +00:00
Philip Withnall
548ec9f186 docs: Reduce nesting of documentation directories
The `gi-docgen` tool is not designed to be used like that. In
particular, when nesting documentation directories, the generated
`*.devhelp2` files (needed by Devhelp to show the documentation) are
nested one directory level too deep for Devhelp to find them, and hence
are useless, and the documentation doesn’t show up in this common
documentation viewer.

So, change the installed documentation directory hierarchy:
 * `${PREFIX}/share/doc/glib-2.0/gio` → `${PREFIX}/share/doc/gio-2.0`
 * `${PREFIX}/share/doc/glib-2.0/glib-unix` →
   `${PREFIX}/share/doc/glib-unix-2.0`
 * `${PREFIX}/share/doc/glib-2.0/gobject` →
   `${PREFIX}/share/doc/gobject-2.0`
 * etc.
 * `${PREFIX}/share/doc/glib-2.0/glib` → `${PREFIX}/share/doc/glib-2.0`

This is going to seem like pointless churn (the contents of the
documentation have not changed), and packagers may mourn the split of
content in `/usr/share/doc` from `/usr/share/doc/${package_name}` to
`/usr/share/doc/${pkg_config_id}` instead, but that seems to be the best
approach to fix this issue in GLib. gi-docgen’s behaviour does feel
fairly consistent and correct with the rest of how it works (single
output directory).

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

Fixes: #3287
2024-03-13 18:51:21 +00:00
Philip Withnall
e0c18a2f04 gstrfuncs: Mention slightly odd return types in docs
See the previous commit for details.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: #3286
2024-03-13 15:06:34 +00:00
Philip Withnall
6c3ad23634 gstrfuncs: Add missing (transfer none) annotations for several funcs
These unfortunately have `gchar*` return types rather than `const
gchar*`. This is a historical artifact which we can’t change: while
adding `const` would only be an API break and not an ABI break, it would
cause all sorts of C++ code which uses GLib to emit new cast warnings
(similarly, C code with const correctness compiler warnings enabled
would do the same).

The incorrect return type causes the GIR scanner to (reasonably) assume
the return value is allocated, which is wrong.

Fix that by explicitly adding `(transfer none)`.

Also add an explicit `(nullable)` because all three functions are.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Fixes: #3286
2024-03-13 14:48:07 +00:00
Changwoo Ryu
92eb8d2ddc Update Korean translation 2024-03-13 10:34:45 +00:00
Michael Catanzaro
d0dfd551b2 Merge branch 'needless-recompile' into 'main'
meson: Fix a needless recompilation of some gdbus tests

See merge request GNOME/glib!3962
2024-03-12 23:32:09 +00:00
Nirbheek Chauhan
92a97c4f48 meson: Fix a needless recompilation of some gdbus tests
The gdbus-example-objectmanager visibility header was being re-created
on reconfigure, causing a needless rebuild of gdbus tests that were
using the visibility header.

All other invocations of gen_visibility_macros are via custom_target.
2024-03-13 03:32:56 +05:30
Ask Hjorth Larsen
1f8d5a9cbf Update Danish translation 2024-03-12 21:58:43 +00:00
Ekaterine Papava
9bba53cf02 Update Georgian translation 2024-03-11 21:01:48 +00:00
Juliano de Souza Camargo
7480807e93 Update Brazilian Portuguese translation
(cherry picked from commit 36b81fbfb6)
2024-03-11 17:02:02 +00:00
Fran Dieguez
fcacaf33b1 Update Galician translation 2024-03-11 08:21:17 +00:00
Ekaterine Papava
a2021e4b26 Update Georgian translation 2024-03-10 12:30:08 +00:00