Commit Graph

26614 Commits

Author SHA1 Message Date
Michael Catanzaro
e4975341bc Merge branch 'mcatanzaro/gthread-posix-errno' into 'main'
gthread-posix: need to #include <errno.h>

See merge request GNOME/glib!3157
2022-12-20 23:27:00 +00:00
Michael Catanzaro
03cb4261e0 gthread-posix: need to #include <errno.h>
a79c6af23e uses errno without the required
header.
2022-12-20 17:11:29 -06:00
Marco Trevisan
cbee90b8a4 Merge branch 'wip/pwithnall/freebsd-again' into 'main'
Revert "ci: Temporarily only run the FreeBSD 13 CI on a schedule"

See merge request GNOME/glib!3151
2022-12-20 00:22:52 +00:00
Marco Trevisan
38e01b03b6 Merge branch 'tests-isolated-tmpdir' into 'main'
gtestutils: Use $G_TEST_TMPDIR as temporary directory when defined

See merge request GNOME/glib!2886
2022-12-19 21:32:56 +00:00
Marco Trevisan (Treviño)
ca0f04d1c6 gtestutils: Use $G_TEST_TMPDIR as temporary directory when defined
During tests in which we are isolating directories, we may still create
temporary files in the global temporary directory without cleaning them
because the value returned by g_get_tmp_dir() is cached when we isolate
the tests directory to the global TMPDIR.

To ensure that we're always isolating the temporary directories, let's
unset the cached temporary directory once we've defined $G_TEST_TMPDIR
so that the returned value of g_get_tmpdir() can be recomputed using the
test isolated temporary directory.
2022-12-19 21:37:19 +01:00
Marco Trevisan
e82a257db9 Merge branch 'ebassi/garray-revert' into 'main'
Revert "garray: Add support adding literal values"

Closes #2846

See merge request GNOME/glib!3154
2022-12-19 18:33:17 +00:00
Emmanuele Bassi
6337bdaa37 Revert "garray: Add support adding literal values"
Reverts the following commits:

- ab621e15b5.
- 85d9fb8e6c.

Too many build breaking regressions.

Fixes: #2846
2022-12-19 17:19:50 +00:00
Philip Withnall
ffbb1a34d4 Revert "ci: Temporarily only run the FreeBSD 13 CI on a schedule"
This reverts commit 4f5bd5439e.

The FreeBSD CI runner is back!

See https://gitlab.gnome.org/Infrastructure/GitLab/-/issues/594#note_1620930
2022-12-19 13:59:47 +00:00
Emmanuele Bassi
5701a15ae3 Merge branch 'wip/pwithnall/debugging-macos-ci' into 'main'
tests: Fix stall/deadlock in slice-concurrent on macOS CI

See merge request GNOME/glib!3152
2022-12-19 13:53:52 +00:00
Philip Withnall
d0f456a504 Merge branch 'futex64' into 'main'
glib/gthread-posix: Conditionally use `futex` and/or `futex_time64` syscalls...

See merge request GNOME/glib!3120
2022-12-19 13:19:07 +00:00
Philip Withnall
bebf13d5d6 Merge branch 'close-range-freebsd' into 'main'
gspawn.c: prefer close_range() on FreeBSD if available

See merge request GNOME/glib!3144
2022-12-19 13:08:15 +00:00
Alexander Richardson
0ec83bb650 gspawn.c: prefer close_range() on FreeBSD if available 2022-12-19 13:08:13 +00:00
Philip Withnall
d3a26bb4de Merge branch 'activation-token' into 'main'
gdesktopappinfo: Set XDG_ACTIVATION_TOKEN/activation-token startup ID key

Closes #2709

See merge request GNOME/glib!3090
2022-12-19 13:05:57 +00:00
Ilya Fedin
627f2738e0 gdesktopappinfo: Set XDG_ACTIVATION_TOKEN/activation-token startup ID key
See:
 * https://gitlab.freedesktop.org/xdg/xdg-specs/-/blob/master/desktop-entry/desktop-entry-spec.xml#L1061-1068
 * https://wayland.app/protocols/xdg-activation-v1
 * https://gitlab.freedesktop.org/wayland/wayland-protocols/-/blob/main/staging/xdg-activation/x11-interoperation.rst

Fixes: #2709
2022-12-19 12:45:02 +00:00
Philip Withnall
b4ecb604aa tests: Use a thread-local GRand in each slice-concurrent test thread
This prevents stalls/deadlocks/timeouts on macOS. I don’t know why, as I
don’t have access to a macOS machine to test — this MR was put together
via testing on CI.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-12-19 11:32:59 +00:00
Philip Withnall
94d53af427 tests: Fix operator precedence in slice-concurrent
This regressed in commit 9f558a2c50.

Not sure if it makes a functional difference to the test, though.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-12-19 09:57:39 +00:00
Philip Withnall
953f4fc25f Merge branch 'th/gtype-cast-align-warning' into 'main'
gtype: avoid "-Wcast-align" warning with optimized G_TYPE_CHECK_INSTANCE_CAST()

See merge request GNOME/glib!3139
2022-12-19 09:30:56 +00:00
Philip Withnall
ba90e9ab22 Merge branch 'ghash-unsigned-nnodes' into 'main'
ghash: Use unsigned types for number of nodes and occupied ones

See merge request GNOME/glib!3148
2022-12-19 09:24:30 +00:00
Philip Withnall
3ec55201d0 Merge branch 'wroy-main-patch-88172' into 'main'
Fix g_array_append_val compilation on Windows

Closes #2845

See merge request GNOME/glib!3150
2022-12-17 23:23:58 +00:00
William Roy
85d9fb8e6c Fix g_array_append_val compilation on Windows 2022-12-17 23:23:58 +00:00
Marco Trevisan (Treviño)
e9979b540f meson: Add test to check for strict cast alignments if supported 2022-12-16 20:48:47 +01:00
Thomas Haller
938a1caf89 gtype: avoid "-Wcast-align" warning with optimized G_TYPE_CHECK_INSTANCE_CAST()
We can get a "-Wcast-align", if the target type that we cast to ("ct") has a
larger alignment than GTypeInstance.

That can happen on i686 architecture, if the GObject type has larger
alignment than the parent struct (or GObject). Since on i686, embeding
a "long long" or a "long double" in a struct still does not increase
the alignment beyond 4 bytes, this usually only happens when using the
__attribute__() to increase the alignment (or to have a field that has
the alignment increased).

It can happen on x86_64 when having a "long double" field.

The compiler warning is hard to avoid but not very useful, because it purely
operates on the pointer types at compile time. G_TYPE_CHECK_INSTANCE_CAST()
instead asserts (in non-optimized mode) that the pointer really points
to the expected GTypeInstance (and if that's the case, then the alignment
should be suitable already).

This is like in commit ed553e8e30 ('gtype: Eliminate -Wcast-align warnings
with G_TYPE_CHECK_INSTANCE_CAST'). But also fix the optimized code path.

With the unpatched G_TYPE_CHECK_INSTANCE_CAST() macro, the unit test would
now show the problem (with gcc-9.3.1-2.fc30.i686 or
gcc-12.2.1-4.fc37.x86_64):

  $ export G_DISABLE_CAST_CHECKS=1
  $ export CFLAGS='-Wcast-align=strict'
  $ meson build
  $ ninja -C build
  ...
  In file included from ../gobject/gobject.h:26,
                   from ../gobject/gbinding.h:31,
                   from ../glib/glib-object.h:24,
                   from ../gobject/tests/objects-refcount1.c:2:
  ../gobject/tests/objects-refcount1.c: In function ‘my_test_dispose’:
  ../gobject/gtype.h:2523:42: warning: cast increases required alignment of target type [-Wcast-align]
   2523 | #  define _G_TYPE_CIC(ip, gt, ct)       ((ct*) ip)
        |                                          ^
  ../gobject/gtype.h:517:66: note: in expansion of macro ‘_G_TYPE_CIC’
    517 | #define G_TYPE_CHECK_INSTANCE_CAST(instance, g_type, c_type)    (_G_TYPE_CIC ((instance), (g_type), c_type))
        |                                                                  ^~~~~~~~~~~
  ../gobject/tests/objects-refcount1.c:9:37: note: in expansion of macro ‘G_TYPE_CHECK_INSTANCE_CAST’
      9 | #define MY_TEST(test)              (G_TYPE_CHECK_INSTANCE_CAST ((test), G_TYPE_TEST, GTest))
        |                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~
  ../gobject/tests/objects-refcount1.c:96:10: note: in expansion of macro ‘MY_TEST’
     96 |   test = MY_TEST (object);
        |          ^~~~~~~
2022-12-16 20:48:06 +01:00
Marco Trevisan (Treviño)
8465c1a055 ghash: Use unsigned types for number of nodes and occupied ones
It has always been considered an unsigned value, and we also returned it
straight as int in g_hash_table_size(), but it was actually used as an
int.

So use the same type of g_hash_table_size(). Not using more standard
unsigned not to risk that it may different from the guint typedef.
2022-12-16 19:33:01 +01:00
Philip Withnall
abd76e0286 Merge branch 'ghash-keys+values-arrays' into 'main'
ghash: Add APIs to get (and steal) hash table keys and values as GPtrArray

See merge request GNOME/glib!3130
2022-12-16 18:32:10 +00:00
Philip Withnall
a8826215b0 Merge branch 'fix-cancellable-connect-race' into 'main'
GCancellable: Ensure it is always cancelled on connect callback

See merge request GNOME/glib!2764
2022-12-16 18:11:03 +00:00
Philip Withnall
cc113b710a Merge branch 'array-direct-insert' into 'main'
garray: Add support adding literal values

See merge request GNOME/glib!3129
2022-12-16 17:57:24 +00:00
Marco Trevisan (Treviño)
3cad948f46 gdbusdaemon: Simplify name listing code using only arrays 2022-12-16 18:45:37 +01:00
Marco Trevisan (Treviño)
52900ed6b0 gdbusobjectskeleton: Get the ifaces via array instead of list 2022-12-16 18:45:36 +01:00
Marco Trevisan (Treviño)
036dabcff9 gdbus-tool: Steal set values passing the ownership to an array 2022-12-16 18:45:36 +01:00
Marco Trevisan (Treviño)
1eb7f3177d gdbusobjectmanagerclient: Simplify g-name-owner changes code
We can avoid further copies and unneeded ref/unrefs.
2022-12-16 18:45:36 +01:00
Marco Trevisan (Treviño)
0e56d2f5db gdbusmessage: Get message headers keys as arrays
We eventually need to return them as an array anyways.
Sadly we can't just reuse such memory because each element is a pointer and
not a guchar, but still we can be cheaper in various operations.
2022-12-16 18:45:36 +01:00
Marco Trevisan (Treviño)
1e699edf0e gdbusaddress: Use simpler hash table keys as arrays
We don't really need the lists overhead here, so let's just use the simpler
forms.
2022-12-16 18:45:36 +01:00
Marco Trevisan (Treviño)
5d5d12112b gdbusaddress: Use simpler hash table keys as arrays
We don't really need the lists overhead here, so let's just use the simpler
forms.
2022-12-16 18:45:36 +01:00
Marco Trevisan (Treviño)
e733a3db10 gdbusconnection: Avoid copying connection registered set values twice 2022-12-16 18:45:36 +01:00
Marco Trevisan (Treviño)
d68e7bc84a ghash: Add functions to steal all keys and values preserving ownership
Add functions to steal all the keys or values from a ghash (especially
useful when it's used as a set), passing the ownership of then to a
GPtrArray container that preserves the destroy notify functions.
2022-12-16 18:45:36 +01:00
Marco Trevisan (Treviño)
d2c3f7f513 ghash: Add APIs to get hash table keys and values as GPtrArray
GPtrArray's are faster than lists and provide more flexibility, so add
APIs to get hash keys and values using these containers too.

Given that we know the size at array initialization we can optimize the
allocation quite a bit, making it faster than the API using GList both at
creation time and for consumers.
2022-12-16 18:45:36 +01:00
Marco Trevisan (Treviño)
ab621e15b5 garray: Add support adding literal values
GArray's g_array_append_val(), g_array_prened_val() and g_array_insert_val()
macros required an user to use literals to add a new value.

This could be inconvenient at times, but it's possible to avoid this with
recent compilers, in fact in case glib_typeof is defined we can take
advantage of it, to initialize a temporary variable to store the literal
value and pass its address to the actual function.
2022-12-16 18:13:28 +01:00
Philip Withnall
aee72d3dce Merge branch 'concurrent-rand' into 'main'
tests/slice-concurrent.c: avoid using rand() from multiple threads

See merge request GNOME/glib!3141
2022-12-16 17:00:56 +00:00
Alexander Richardson
9f558a2c50 tests/slice-concurrent.c: avoid using rand() from multiple threads 2022-12-16 17:00:56 +00:00
Philip Withnall
58521101b3 Merge branch 'wip/smcv/gvariant-big-endian' into 'main'
gvariant-serialiser: Convert endianness of offsets

Closes #2839

See merge request GNOME/glib!3136
2022-12-16 13:32:39 +00:00
Simon McVittie
0e3b21000d Merge branch 'posix_memalign-requirements' into 'main'
tests/gvariant.c: ensure posix_memalign alignment argument is correct

See merge request GNOME/glib!3145
2022-12-16 13:24:52 +00:00
Simon McVittie
ba2137b0d9 gvariant-serialiser: Convert endianness of offsets
The array of offsets is little-endian, even on big-endian architectures
like s390x.

Fixes: ade71fb5 "gvariant: Don’t allow child elements to overlap with each other"
Resolves: https://gitlab.gnome.org/GNOME/glib/-/issues/2839
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-12-16 13:03:37 +00:00
Simon McVittie
8b80c451a5 Merge branch 'wip/pwithnall/temporarily-disable-freebsd' into 'main'
ci: Temporarily only run the FreeBSD 13 CI on a schedule

See merge request GNOME/glib!3147
2022-12-16 13:01:59 +00:00
Simon McVittie
79cddc6c75 Merge branch 'varargs-missing-argument' into 'main'
tests/gdbus-method-invocation: Fix missing g_variant_new() argument

See merge request GNOME/glib!3142
2022-12-16 12:53:37 +00:00
Philip Withnall
4f5bd5439e ci: Temporarily only run the FreeBSD 13 CI on a schedule
Rather than on every commit, because the CI runner is currently broken:
https://gitlab.gnome.org/Infrastructure/GitLab/-/issues/594.

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

Helps: !3136
2022-12-16 12:34:03 +00:00
Alex Richardson
994f96fb2b tests/gdbus-method-invocation: Fix missing g_variant_new() argument
I noticed this when running the test on an Arm Morello system where varargs
have bounds. g_variant_new() was trying to read an integer using va_arg(),
but since there was no argument it resulted in a bounds errors there.
On most other architectures this will just read whatever value is contained
in the next argument register and is not something that ASan can detect, so
it never resulted in test failures.
2022-12-16 10:28:50 +00:00
Alex Richardson
58f70cebb6 Fix test_aligned_mem for Morello
On Arm Morello sizeof(void*) is 16 bytes so we fail the check for
`(alignment % sizeof (void *)) != 0))` in gmem.c.
2022-12-15 23:50:23 +00:00
Alex Richardson
34236af33c tests/gvariant.c: ensure posix_memalign alignment argument is correct
posix_memalign() requires the alignment to be a multiple of sizeof(void*),
and a power of 2. Passing 8 does not fulfil both of those constraints on
Arm Morello which resulted in a "posix_memalign failed" test failure.

Co-authored-by: Graeme Jenkinson <graeme@capabilitieslimited.co.uk>
2022-12-15 23:50:23 +00:00
Marco Trevisan (Treviño)
cdda03a690 GCancellable: Ensure it is always cancelled on connect callback
When a cancellable is cancelled when we call g_cancellable_connect we
used to immediately call the provided callback, while this is fine we
actually had race in case the cancellable was about to be reset or in
the middle of a cancellation.

In fact it could happen that when we released the mutex, another thread
could reset the cancellable just before the callback is actually called
and so leading to call it with g_cancellable_cancelled() == FALSE.

So to handle this, make disconnect and reset function to wait for
connection emission to finish, not to break their assumptions.

This can be tested using some "brute-force" tests where multiple threads
are racing to connect and disconnect while others are cancelling and
resetting a cancellable, ensuring that all works as we expect.
2022-12-15 19:30:43 +01:00
Marco Trevisan (Treviño)
f520066563 gutils: Add a private API to unset the cached temporary directory
We may need to avoid using a cached temp directory for testing purposes,
so let's provide an internal API to perform such task.

This implies removing GOnce and going with mutex-based version, but
that's still using atomic logic in most unix implementations anyways.
2022-12-15 17:29:00 +01:00