31262 Commits

Author SHA1 Message Date
Philip Withnall
62c1ae7161
glib.supp: Ignore once-per-thread leak from SysprofCollector
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-02-04 10:47:43 +00:00
Philip Withnall
e96bc30c16 Merge branch 'ebassi/goption-flag-deprecated' into 'main'
Add G_OPTION_FLAG_DEPRECATED

See merge request GNOME/glib!4046
2025-02-03 15:37:23 +00:00
Emmanuele Bassi
b145330b75 Add G_OPTION_FLAG_DEPRECATED
Generate a deprecation notice in the `--help` output for deprecated
options. This helps with the documentation of command line utilities.

Put the deprecation notice near the argument, to allow application
developers to add a notice on the deprecation on their own, and
explain what to use instead.
2025-02-03 15:37:23 +00:00
Philip Withnall
b9a4039271 Merge branch 'main' into 'main'
Add support for QNX8.0

See merge request GNOME/glib!4466
2025-02-03 15:10:06 +00:00
Philip Withnall
cac9100960 Merge branch 'ebassi/gtype-refcount' into 'main'
Drop TypeNode reference counting

See merge request GNOME/glib!3255
2025-02-03 14:38:24 +00:00
Emmanuele Bassi
dc86ad1925 Drop TypeNode reference counting
We don't allow unloading types, both static and dynamic, since 2013. The
code that deals with reference counting is mostly dead code, and makes
reasoning about the type system more complicated than necessary.

Since type classes and interfaces can only be instantiated, we introduce
explicit getter functions that create a GTypeClass or a GTypeInterface
vtable; the ref() and unref() API gets a "soft" deprecation (explicitly
not using `GOBJECT_DEPRECATED_IN_*` yet), to allow people to
progressively port their code.
2025-02-03 14:38:24 +00:00
Felix Xing
e99e27848e Add checking for <sys/ucred.h>
A new header check is added for non-standard <sys/ucred.h>. Some platforms, like Linux, might support <sys/param.h>, <sys/mount.h>, and <fstab.h> but not this. Which can cause compilation to fail for gio/gunixmounts.c
2025-02-03 09:19:17 -05:00
Philip Withnall
0621d0ddb8 Merge branch 'glib-function-pointer-requirements' into 'main'
Document function pointer cast requirements

Closes #3595

See merge request GNOME/glib!4469
2025-02-03 11:40:12 +00:00
Demi Obenour
9eb0828bd8 Document function pointer cast requirements
Helps: #3596
Fixes: #3595
2025-02-03 11:40:12 +00:00
Michael Catanzaro
9b1e0a583a Merge branch 'gi-static-vfuncs' into 'main'
Support static vfuncs in GIRepository

See merge request GNOME/glib!4457
2025-02-01 14:10:57 +00:00
Felix Xing
a177c46b19 Add support for QNX8.0
This request brings support to the latest version of QNX software. _g_get_unix_mount_points (void) for getfsent() system also works on QNX. To avoid duplicating codes, it will be reused.
2025-01-31 09:18:02 -05:00
Philip Withnall
9c7a57dcc5 Merge branch 'issue-3587-2' into 'main'
gosxappinfo: Fix leak

See merge request GNOME/glib!4464
2025-01-28 15:40:26 +00:00
Andre Miranda
62d8d0b6ec gosxappinfo: Fix leak
Slightly reworked by Philip Withnall (any mistakes his).
2025-01-28 12:03:10 +00:00
Philip Withnall
fcc610791b Merge branch 'issue-3587' into 'main'
gosxappinfo: Correctly launch list of files

Closes #3587

See merge request GNOME/glib!4462
2025-01-24 12:29:54 +00:00
Andre Miranda
8b64bb8751 gosxappinfo: Correctly launch list of files
Fixes #3587
2025-01-24 12:29:54 +00:00
Michael Catanzaro
0c38fd3c14 Merge branch 'docs-updates' into 'main'
docs: Update the release documentation for the new release workflow

See merge request GNOME/glib!4461
2025-01-23 16:00:56 +00:00
Philip Withnall
9e3c017df8
docs: Update various outdated links which pointed to wiki.gnome.org
wiki.gnome.org has been retired but for some reason none of the old
pages were given HTTP redirects, so everyone has to update all their
links manually everywhere.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-01-23 14:00:46 +00:00
Philip Withnall
d11dac3836
docs: Update the release documentation for the new release workflow
Make it more closely match
https://handbook.gnome.org/maintainers/making-a-release.html again.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-01-23 13:59:48 +00:00
Philip Withnall
884925d02e
2.83.3
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2.83.3
2025-01-23 13:20:40 +00:00
Philip Withnall
2adc87bbd8 Merge branch 'extension-docs' into 'main'
docs: Document more extension points

See merge request GNOME/glib!4458
2025-01-22 23:33:32 +00:00
Michael Catanzaro
82c179e624 Merge branch 'garray_unref_docs_clarify' into 'main'
docs: Clarify that g_array_unref() works like g_ptr_array_unref().

See merge request GNOME/glib!4460
2025-01-22 23:01:22 +00:00
Philip Withnall
58c4ab46f2
docs: Port GIO overview to gi-docgen linking syntax and fix a few typos
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-01-22 22:48:43 +00:00
Logan Rathbone
14adec6a54 docs: Clarify that g_array_unref() works like g_ptr_array_unref().
This makes the documentation for this function more consistent with that
of g_ptr_array_unref(), which makes it clear that it acts like
g_(ptr_)array_free with free_segment=TRUE.
2025-01-22 13:29:50 -05:00
Matthias Clasen
d760bfef00 docs: Document more extension points
GIO is more extensible than we know! Document more of the existing
extension points, their included implementations and their purpose.
2025-01-21 12:00:42 +00:00
Philip Chimento
7471ab20d1 girepository: Add test for static vfunc info
This is a test for the functionality in the previous commit. It depends
on g-ir-scanner being able to scan static vfuncs, and is otherwise
skipped.

The g-ir-scanner functionality is in
https://gitlab.gnome.org/GNOME/gobject-introspection/-/merge_requests/361
2025-01-19 13:49:55 -08:00
Marco Trevisan (Treviño)
7ea9840cf4 girepository: Read static vfunc attribute exposing via callable is_method()
Read the static attribute for virtual functions, and make sure that
g_callable_info_is_method() returns false for such cases.
2025-01-19 13:49:55 -08:00
Philip Chimento
fe142e3b32 girepository: Add baseline tests for gi_callable_info_is_method()
This tests existing functionality.
2025-01-18 14:27:24 -08:00
Philip Chimento
3d71dcaa64 gicallableinfo: Fix inaccuracy in is_method docs
The docs say that gi_callable_info_is_method() on a GICallbackInfo
always returns TRUE. But the source code says it always returns FALSE.
2025-01-18 14:16:55 -08:00
Michael Catanzaro
26bc1d08ec Merge branch 'gmacros-initialize-variable' into 'main'
gmacros: zero-initialize int G_PASTE (_g_boolean_var_, uniq)

Closes #3582

See merge request GNOME/glib!4456
2025-01-17 20:21:45 +00:00
Johannes Penßel
88a095f62e gmacros: zero-initialize int G_PASTE (_g_boolean_var_, uniq) 2025-01-17 20:21:44 +00:00
Michael Catanzaro
6e896f5673 Merge branch 'th/gdataset-index' into 'main'
[th/gdataset-index] add a lookup index (GHashTable) to `GData`

See merge request GNOME/glib!3885
2025-01-16 17:46:53 +00:00
Philip Withnall
6c660596ea Merge branch 'document-deprecated-flags-none' into 'main'
gioenums: Add deprecation for FLAGS_NONE

See merge request GNOME/glib!4454
2025-01-13 19:42:10 +00:00
Maximiliano
9d3c384565 gioenums: Add deprecation for FLAGS_NONE
g-ir won't pick it if it is not in its own doc block.

Requires
https://gitlab.gnome.org/GNOME/gobject-introspection/-/merge_requests/512,
otherwise the deprecated tag won't be set in the introspection data.
2025-01-13 19:42:09 +00:00
Philip Withnall
ce7e867e57 Merge branch 'nielsdg/main-loop-docs' into 'main'
docs: Use gi-docgen syntax in main-loop.md

See merge request GNOME/glib!4455
2025-01-13 18:34:10 +00:00
Philip Withnall
b65e950b3e
docs: More gi-docgen linking in main-loop.md
Port the rest of the document to gi-docgen syntax, so we don’t have to
track partially-ported files.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: #3250
2025-01-13 17:47:12 +00:00
Niels De Graef
bd148fd04d docs: Use gi-docgen syntax in main-loop.md
The "Main Loop" documentation wasn't actually linking to `GMainContext`
properly, so let's fix this.
2025-01-12 15:33:19 +01:00
Michael Catanzaro
7129521966 Merge branch 'dev' into 'main'
corrected Memory management of signal handlers anchor

Closes #3563

See merge request GNOME/glib!4453
2025-01-10 15:29:36 +00:00
arujjval
b67d6ec9ff
corrected Memory management of signal handlers anchor 2025-01-10 12:51:45 +05:30
Thomas Haller
3437414dd4 gdataset: use lookup index in g_datalist_id_remove_multiple()
In order to reuse datalist_find(), we turn the loops around. First loop
over the keys, and then (internally in datalist_find()) loop over the
entries.
2025-01-08 00:36:52 +01:00
Thomas Haller
af4a43b064 gdataset: handle up to G_MAXUINT32 entries
GData is a thread safe container. For that reason, it probably is anyway
not suitable to add 4 billion entries. That is even with the new index,
where we now scale with O(1).

Still, the code should not just break down at half of what we
theoretically could add.

Handle overflow and huge sizes correctly.
2025-01-08 00:36:52 +01:00
Thomas Haller
9abc4d9be6 gdataset: use hash lookup in g_datalist_get_data()
g_datalist_get_data() tries to avoid g_quark_try_string() and instead
do the lock-less g_quark_to_string(). For small number of entries that
may perform better. At least, this was an optimization from the past.

However, if we have a GHashTable index, and presumably a larger number
of entries, we should use the index instead. Unfortunately, that requires
us again to use g_quark_try_string() and take a global lock.
2025-01-08 00:36:52 +01:00
Thomas Haller
0746df4906 gdataset: add GHashTable lookup index to GData
GData tracks the entries in a linear array, and performs a linear
search. That is very good, as long as the number of entries is small.
However, when it grows, performance gets worse. It's not clear what the
exact threshold is, or what the recommended maximum is.

Also, GData is used to attach arbitrary user data to GObject. Which is a
great feature, that a user might want to use. In that case, they may be
less concerned about performance to get the benefits of the feature, and
thus add more data than is best (though, it's unclear how much is too
much).

Also, GObject adds entries in its qdata. Hence, also for basic GObject
operations, it's important that this performs well. Note that access to
GData happens while holding a lock, we want to minimize the time while
holding that lock.

This patch ensures that access to GData is O(1) (and reasonably fast).
It thus allows to use GData in ways that wasn't advised previously.

There are alternatives, like using a binary search tree or always use a GHashTable.
Instead, we keep the linear buffer. Only when the buffer grows to
ALLOC_THRESHOLD_INDEX entries, we will start generating and maintaining
a GHashTable index. So the common case where objects have few entries
does not change. The memory overhead is only there, when the list grows.

ALLOC_THRESHOLD_INDEX is set to 64 entries. We will allocate such a
large buffer when adding the 33rd entry. During shrink, we will drop the
buffer again when shrinking down to 16 entries.

The reason for not always using the GHashTable is to save the memory in
common cases where there are few entries.

We use g_hash_table_add() to exploit the GHashTable optimization. We
also let it point to the GDataElt from the linear array. The benefit is
that we don't require individual allocations. The downside is that
during reallocation we need to regenerate the entire index.

In my tests this actually performs well. For example, following are
timings for calling g_dataset_id_get_data() in a loop. This is the
lookup time for an entry that doesn't exist. Obviously, the linear
search would scale always best when we would only lookup the first entry
in the list.

   num-entries     time-before   time-after
             1           0.144        0.145
             2           0.146        0.146
             5           0.149        0.150
            10           0.155        0.157
            20           0.172        0.170
            32           0.248        0.254
            33           0.249        0.184  <== index in use
            40           0.284        0.183
            50           0.317        0.189
            75           0.370        0.184
           100           0.442        0.183
           300           1.044        0.186
          1000           3.170        0.184
         10000          31.597        0.189
2025-01-08 00:36:52 +01:00
Thomas Haller
cc53252c5b gdataset: add datalist_realloc() helper
This will be more useful next.

Also, try to detect whether realloc() actually moved the pointer. If it
doesn't, we can optimize a bit (not use g_datalist_unlock_and_set()).
Next, we will do more useful optimization in this case.

Note that we cannot just compare dangling pointers. That's would be
undefined behavior. In practice, we probably often compare dangling
pointers, and this tends to work just fine. Still avoid this and compare
only the guintptr values.
2025-01-08 00:36:52 +01:00
Thomas Haller
9a8e2ab263 gdataset: extract helper function for struct size 2025-01-08 00:36:52 +01:00
Thomas Haller
2900575283 gdataset: extract datalist_destroy() helper function for releasing GData
Avoid duplicated code.

Also, the "if (data->data[i].data && " check is unnecessary. The data
pointer is never NULL, because g_datalist_id_set_data() will treat that
as indication to remove the entry.
2025-01-08 00:36:52 +01:00
Thomas Haller
6063cdb79f gdataset/tests: improve "/datalist/id-remove-multiple/resize" test 2025-01-08 00:36:51 +01:00
Michael Catanzaro
127d38b0d3 Merge branch 'scan-build-warnings' into 'main'
Add several assertions to help static analysis and fix some GIR annotations

See merge request GNOME/glib!4449
2025-01-03 21:26:29 +00:00
Philip Withnall
92528d3802 Merge branch 'le-be-swap-gcc' into 'main'
Fix GCC version detection for GUINT*_SWAP_LE_BE

See merge request GNOME/glib!4450
2025-01-03 18:54:26 +00:00
Sam James
be57844b38
Fix GCC version detection for GUINT*_SWAP_LE_BE
The #if condition as-written fails for any major >= 5 if minor < 3, e.g.
GCC 14.2 and so on.

Use the idiom described in the GCC docs [0] to avoid this.

[0] https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html

Fixes: 57878d6042366070e80a109bf113ac03abb86cfd
2025-01-01 17:47:30 +00:00
Philip Withnall
e70144bf5b
gtestutils: Add missing colon in GIR annotation
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-12-31 13:06:13 +00:00