Commit Graph

28887 Commits

Author SHA1 Message Date
Philip Withnall
74502f51a6 Merge branch 'mime-type-leak' into 'main'
glib.supp: Suppress the global_mime_dirs allocations

See merge request GNOME/glib!3702
2023-11-08 15:24:39 +00:00
Philip Withnall
2787a86693 Merge branch 'ebassi/girepository' into 'main'
Move libgirepository into GLib

Closes #455, #457, #49, #13, #318, #298, #38, #200, #96, #244, #175, and #218

See merge request GNOME/glib!3642
2023-11-08 12:24:03 +00:00
Emmanuele Bassi
ebb0346380 gir: Do not include builtin directories in pkgconfig.generate()
It's deprecated since Meson 0.62, and breaks the build with fatal
warnings enabled for Meson.
2023-11-08 12:04:12 +00:00
Philip Withnall
342b654e35 Merge branch 'main' into 'ebassi/girepository'
This needs to be done as a merge rather than a rebase because !3642 cannot be rebased.

Conflicts:
  meson_options.txt
2023-11-08 11:54:28 +00:00
Philip Withnall
8f36997aaa Merge branch 'wip/pwithnall/macos-gio-tool-fix' into 'main'
tests: Fix gio-tool.py test on macOS

See merge request GNOME/glib!3701
2023-11-08 11:26:27 +00:00
Philip Withnall
31906961d1 glib.supp: Suppress the global_mime_dirs allocations
These are one-time allocations which are still reachable at the end of
the process. They cause warnings like this in valgrind:
```
==14408== 128 bytes in 1 blocks are definitely lost in loss record 1,287 of 1,403
==14408==    at 0x4847A40: realloc (vg_replace_malloc.c:1649)
==14408==    by 0x48CCD6E: g_realloc (gmem.c:201)
==14408==    by 0x48F4CB1: g_string_expand (gstring.c:82)
==14408==    by 0x48F4D59: g_string_sized_new (gstring.c:113)
==14408==    by 0x48F4D91: g_string_new (gstring.c:134)
==14408==    by 0x48A5805: g_build_path_va (gfileutils.c:1929)
==14408==    by 0x48A62D1: g_build_filename_va (gfileutils.c:2222)
==14408==    by 0x48A63FE: g_build_filename (gfileutils.c:2316)
==14408==    by 0x491CD89: g_build_user_data_dir (gutils.c:1879)
==14408==    by 0x491CDCF: g_get_user_data_dir (gutils.c:1920)
==14408==    by 0x4B51E53: _g_content_type_set_mime_dirs_locked (gcontenttype.c:145)
==14408==    by 0x4B51F33: g_content_type_set_mime_dirs (gcontenttype.c:194)
==14408==    by 0x40C222: main (desktop-app-info.c:1880)
```

For example in https://gitlab.gnome.org/GNOME/glib/-/jobs/3278564

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2023-11-08 11:03:58 +00:00
Philip Withnall
d59bac3f32 tests: Fix gio-tool.py test on macOS
Content types are different on macOS.

This fixes commit 9028c9bdf.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: #3158
2023-11-08 10:29:43 +00:00
Emmanuele Bassi
db5c42fad0 gir: Rename gir_writer_write()
Use g_ir_writer_write(), as a dual of g_ir_parser_parse_*().

Also, don't abuse C++ reserved keywords for argument names.
2023-11-08 00:23:35 +00:00
Emmanuele Bassi
9a6c518d31 gir: Rename girwriter.h to girwriter-private.h
It's a private header.
2023-11-08 00:16:58 +00:00
Emmanuele Bassi
b0f4a6bcc4 gir: Rename girnode.h to girnode-private.h
It's a private header.
2023-11-08 00:09:04 +00:00
Emmanuele Bassi
f9580e90c4 gir: Rename girparser.h to girparser-private.h
It's a private header.
2023-11-08 00:07:11 +00:00
Emmanuele Bassi
48984375dc gir: Rename girmodule.h to girmodule-private.h
It's private header.
2023-11-08 00:06:01 +00:00
Emmanuele Bassi
51f518e749 Replace GI_AVAILABLE_IN_2_* with GI_AVAILABLE_IN_ALL
This is the first release of GIRepository 2.0.
2023-11-08 00:02:12 +00:00
Emmanuele Bassi
ba24fc659d Remove deprecated API
There's no point in releasing a new library with deprecated API.
2023-11-07 23:57:18 +00:00
Emmanuele Bassi
b3dfaf5e97 gir: Use pragma once for the inclusion guard 2023-11-07 18:23:17 +00:00
Emmanuele Bassi
85d93fb581 Merge branch 'codegen-deps-fixes' into 'main'
meson: Add missing dependencies for utility files for gdbus-codegen

See merge request GNOME/glib!3689
2023-11-07 15:21:27 +00:00
Philip Withnall
e87f8e9c5a Merge branch '3158-info-critical' into 'main'
gio-tool-info: Fix critical warning when --attributes are specified and add basic unit tests

Closes #3158

See merge request GNOME/glib!3684
2023-11-07 14:37:11 +00:00
Philip Withnall
9028c9bdf3 gio-tool-info: Fix critical warning when --attributes are specified
When `--attributes` is specified and doesn’t include `standard::name` in
its list, `gio` would print a critical warning from the (mandatory) call
to `g_file_info_get_name()`.

Fix that by making the call to `g_file_info_get_name()` optional.

Add a unit test too.

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

Fixes: #3158
2023-11-07 13:51:56 +00:00
Philip Withnall
3e0a99a059 tests: Add a very basic test suite for gio-tool
It gives nowhere near full coverage, but it’s something we can build on
in future.

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

Helps: #3158
Helps: #2950
2023-11-07 13:51:56 +00:00
Philip Withnall
077104e63b tests: Run processes under test with G_DEBUG=fatal-warnings
Modify all the similar Python test wrappers to set
`G_DEBUG=fatal-warnings` in the environment of the program being tested,
so we can catch unexpected warnings/criticals.

Adding this because I noticed it was missing, not because I noticed a
warning/critical was being ignored.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>
2023-11-07 13:51:56 +00:00
Philip Withnall
120e0ee649 tests: Set a default timeout value for GIO Python tests
Otherwise every test has to set one explicitly, which is a bit tedious.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>
2023-11-07 13:51:56 +00:00
Philip Withnall
96ee1ea086 gio-tool: Print help output to stdout when --help is passed
If the help output is explicitly requested by the user, it’s
conventional for it to be printed to stdout rather than stderr.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>
2023-11-07 13:51:56 +00:00
Philip Withnall
7c97b93837 gio-tool: Factor out repetitive lists of subcommands
Store their details in an array which can be iterated over instead.

This introduces no functional changes, just a cleanup which will allow
following commits to be neater.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>
2023-11-07 13:51:56 +00:00
Philip Withnall
c17090275c Merge branch 'th/main-sources-dict-as-set' into 'main'
gmain: optimize "context->sources" hash table to use as set

See merge request GNOME/glib!3664
2023-11-06 15:05:43 +00:00
Philip Withnall
a766945766 Merge branch 'main' into 'main'
fix: about libproc.h and PROC_PIDLISTFD_SIZE

See merge request GNOME/glib!3687
2023-11-06 14:46:52 +00:00
CaiJingLong
7b80f73d29 fix: about libproc.h and PROC_PIDLISTFD_SIZE 2023-11-06 14:46:52 +00:00
Philip Withnall
113063e413 Merge branch 'socket-ready-fixes' into 'main'
Socket & readiness fixes

See merge request GNOME/glib!3668
2023-11-06 14:35:23 +00:00
Philip Withnall
534edd070d Merge branch '2810-thread-pool-slow' into 'main'
tests: Fix a race in thread-pool-slow

Closes #2810

See merge request GNOME/glib!3694
2023-11-06 14:18:20 +00:00
Sergey Bugaev
a3d02ad565 gmain: Correct g_source_get_ready_time () doc
Mention that ready time being equal to the current time means the source
will fire immediately.

Related to https://gitlab.gnome.org/GNOME/glib/-/issues/3148

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2023-11-06 15:14:07 +03:00
Sergey Bugaev
150965a9b3 gsocket: Fix detecting timeouts
If she socket is dispatched at exactly the previously set ready time,
it should already be considered to have timed out. This can easily
happen in practice when using a low resolution timer.

This fixes a test failure on GNU/Hurd, see
https://gitlab.gnome.org/GNOME/glib/-/issues/3148

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2023-11-06 15:14:02 +03:00
Sergey Bugaev
6b7b211338 gio: Add G_IO_ERROR_DESTINATION_UNSET
...and map EDESTADDRREQ to it.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2023-11-06 15:04:01 +03:00
Thomas Haller
b067c43b00 gmain: optimize "context->sources" hash table to use as set
Instead of tracking a "(guint,GSource*)" tuple in the "context->sources"
dictionary, only track pointers to the "source_id".

With this we use the GHashTable as Set (g_hash_table_add()), which is
optimized and avoids storing a separate value array.

It's simple enough to do, because there are literally 5 references to
"context->sources". It's easy to review those usages and reason that the
handling is correct.

While at it, in g_main_context_find_source_by_id() move the check for
SOURCE_DESTROYED() inside the lock. It's not obvious that doing this
without a lock was correct in every case. But doing the check with
a lock should be fast enough to not worry about whether it's absolutely
necessary.
2023-11-06 08:48:12 +01:00
Thomas Haller
501bdb51e4 glib: add internal G_CONTAINER_OF() macro
"container_of()" is a popular macro that works together with
G_STRUCT_OFFSET()/offsetof().

For internal use only.
2023-11-06 08:48:12 +01:00
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
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