Commit Graph

25200 Commits

Author SHA1 Message Date
Matthias Clasen
0415bf9412 Add g_datalist_id_remove_multiple
This is more efficient than calling
g_datalist_id_remove() multiple times
in a row, since it only takes the locks
once.

Allow up to 16 keys to be removed in one go.
That is enough for the use we have in GObject,
and it avoids any danger of blowing the stack.
2022-05-23 09:19:45 -04:00
Matthias Clasen
1c4f6da1f7 Add a finalization performance test 2022-05-23 08:49:04 -04:00
Philip Withnall
7de0fcd628 Merge branch 'gobject-speedups2' into 'main'
Avoid g_type_peek_value_table

See merge request GNOME/glib!2674
2022-05-23 11:00:23 +00:00
Matthias Clasen
f2a085d8ea Avoid g_type_peek_value_table
In several places we do paired calls of g_value_init
and g_value_unset, both of which peek the value table.
We can avoid half of that cost by remembering the value
table, instead of looking it up again.

This uses the new G_VALUE_COLLECT_INIT2 macro.
2022-05-23 06:35:55 -04:00
Matthias Clasen
aaef7f30b3 value: Add G_VALUE_COLLECT_INIT2
Add a variant of the G_VALUE_COLLECT_INIT() macro
that provides the GTypeValueTable to the caller.
2022-05-23 05:57:36 -04:00
Christian Kirbach
bc61ae7f83 Update German translation
(cherry picked from commit 92177755ed)
2022-05-22 21:50:00 +00:00
Philip Withnall
f0f2c0107e Merge branch 'update-closure-annotations-2' into 'main'
Rename user data parameters to user_data

See merge request GNOME/glib!2679
2022-05-22 13:37:37 +00:00
Charles Monzat
568eeda6c9 Update French translation
Cherry-pick of 4d6e03745e from glib-2-72
2022-05-22 10:36:27 +02:00
TestingPlant
da7a31a052 Rename user data parameters to user_data
The user data parameters in callbacks need to be named user_data to
generate correct closure attributes in the introspection data. This
updates parameters missed in GNOME/glib!2633.
2022-05-22 01:06:37 +00:00
Asier Sarasua Garmendia
b49f36f69f Update Basque translation 2022-05-21 06:00:03 +00:00
Jordi Mas
0605602d1f Update Catalan translation 2022-05-20 18:01:10 +02:00
Matthias Clasen
0a3a0894f9 Merge branch 'gtype-speedups' into 'main'
gtype: small optimization

See merge request GNOME/glib!2672
2022-05-20 13:43:17 +00:00
Philip Withnall
1f42078ace Merge branch 'param-speedups' into 'main'
param: Avoid strcmps

See merge request GNOME/glib!2673
2022-05-20 13:15:39 +00:00
Matthias Clasen
e80d2bc1ca Add a test for g_type_is_a
Check that the macro and function versions
of g_type_is_a work the same.
2022-05-20 09:08:09 -04:00
Matthias Clasen
22f51b87a2 gtype: Speed up g_type_is_a
As noticed by Christian Hergert: We can reduce
some overhead by checking for exact type
equality first. According to Christian, around
3% of g_type_is_a calls are exact equalities.
2022-05-20 09:08:09 -04:00
Matthias Clasen
55700948eb param: Drop a pointless function
There is nothing to validate for boxed
parameters, so we don't need a validate
function for these.
2022-05-20 08:20:56 -04:00
Matthias Clasen
51215bf7b8 param: Avoid strchrs
Using prefixed property names like GtkWidget::visible
is very deprectated and basically never done. So avoid
paying the strchr cost before doing the first lookup.
2022-05-20 08:20:56 -04:00
Matthias Clasen
91dafa85fc param: Avoid strcmps
Most of the time, we are dealing with static strings,
and we can compare them directly and avoid the strcmp.

Note that triggering this optimization requires
properties to be marked as G_PARAM_STATIC_NAME.
2022-05-20 08:20:56 -04:00
Philip Withnall
4173d44abe Merge branch 'static-param-strings-docs' into 'main'
docs: Use G_PARAM_STATIC_STRINGS in examples and explain it more

See merge request GNOME/glib!2675
2022-05-20 12:20:26 +00:00
Philip Withnall
3c14b6846d docs: Standardise property ID enums in examples
Drop the redundant `PROP_0` (which isn’t a real property) and initialise
the first member of the enum instead.

Add a typedef so that the enum type can be used in `switch` statements
in `get_property()` and `set_property()` vfuncs. This allows
`-Wswitch-enum` to be used to improve type safety.

The examples here don’t have `get_property()` or `set_property()`
vfuncs, but people might copy/paste the code to somewhere which does.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-05-20 12:57:36 +01:00
Philip Withnall
8f9c5090db docs: Use G_PARAM_STATIC_STRINGS in examples and explain it more
Make it a bit clearer in the documentation that using
`G_PARAM_STATIC_STRINGS` everywhere is a good thing.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-05-20 12:57:36 +01:00
Matthias Clasen
c492f4aec2 gtype: small optimization
These warnings are never seen at runtime, so they
are evidently very unlikely. Tell the compiler that.
2022-05-20 07:20:19 -04:00
Philip Withnall
608eb52690 Merge branch 'nonchar-testcase2' into 'main'
Add another Unicode testcase

See merge request GNOME/glib!2671
2022-05-19 17:54:53 +00:00
Matthias Clasen
ad3c339ce4 Add another Unicode testcase
It turns out I typoed the character code when
I added the previous one.

See https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2669
2022-05-19 12:39:33 -04:00
Daniel Mustieles
6b5b1cd314 Updated Spanish translation 2022-05-19 10:34:16 +02:00
Philip Withnall
0efd0e12c8 Merge branch 'nonchar-testcase' into 'main'
Add a Unicode testcase

See merge request GNOME/glib!2669
2022-05-18 23:57:02 +00:00
Matthias Clasen
240675d5f4 Add a Unicode testcase
This verifies that GString is not to blame for the bug
in https://github.com/harfbuzz/harfbuzz/issues/3590
2022-05-18 19:24:04 -04:00
Philip Withnall
fdc11d7cdb Merge branch 'issue-2653' into 'main'
gio: fix gunixfdlist.h location after move to common gio

Closes #2653

See merge request GNOME/glib!2668
2022-05-18 22:32:08 +00:00
Marc-André Lureau
294b562f34 gio: fix gunixfdlist.h location after move to common gio
Fixes commit 5efb84f24a ("gio: add GUnixFDList on win32")

Fixes: https://gitlab.gnome.org/GNOME/glib/-/issues/2653

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-05-18 18:19:03 +02:00
Hugo Carvalho
b90bf35000 Update Portuguese translation 2022-05-18 15:06:54 +00:00
Philip Withnall
bfe349983a Merge branch 'spawn-outparams' into 'main'
g_spawn_async_with_pipes_and_fds uses out parameters as inputs

See merge request GNOME/glib!2632
2022-05-18 14:40:23 +00:00
Philip Withnall
caf6d99fbe Merge branch 'win32-fd' into 'main'
gio: various unix/fd-related enablement on win32

See merge request GNOME/glib!2656
2022-05-18 14:01:43 +00:00
Sebastian Dröge
0be6aa1b22 Merge branch 'reuse-fuzzing' into 'main'
fuzzing: Add copyright/licensing headers to fuzzing files

See merge request GNOME/glib!2666
2022-05-18 09:09:55 +00:00
Sebastian Dröge
2e1b0931fe Merge branch 'reuse-more' into 'main'
glib/gio/tests: Add SPDX license headers automatically

See merge request GNOME/glib!2665
2022-05-18 09:09:24 +00:00
Philip Withnall
b82e3ffcbe fuzzing: Mark .corpus and .dict files as not copyrightable
They are lists of keywords, and don’t contain original copyrightable
content.

This can’t be indicated by a copyright header inside the files, as the
format doesn’t easily allow for that.

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

Helps: #1415
2022-05-18 09:50:05 +01:00
Philip Withnall
e66277943d fuzzing: Add copyright/licensing headers to fuzzing files
The files have only been touched by a subset of three people: pdknsk,
Philip Withnall, and Marc-André Lureau. Their copyrights are assigned to
pdknsk, Endless OS Foundation and Red Hat.

The default license for GLib at the time of writing these files was (and
still is) LGPL-2.1-or-later.

`driver.c` came from LLVM and is under a different license:
https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/fuzzer/standalone/StandaloneFuzzTargetMain.c.
That doesn’t affect the license of GLib overall, since it’s only used
for testing during development.

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

Helps: #1415
2022-05-18 09:49:26 +01:00
Philip Withnall
1771449e54 tests: Add SPDX license headers automatically
Add SPDX license (but not copyright) headers to all files which follow a
certain pattern in their existing non-machine-readable header comment.

This commit was entirely generated using the command:
```
git ls-files glib/tests/*.c | xargs perl -0777 -pi -e 's/\n \*\n \* This library is free software; you can redistribute it and\/or\n \* modify it under the terms of the GNU Lesser General Public/\n \*\n \* SPDX-License-Identifier: LGPL-2.1-or-later\n \*\n \* This library is free software; you can redistribute it and\/or\n \* modify it under the terms of the GNU Lesser General Public/igs'
```

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

Helps: #1415
2022-05-18 09:21:02 +01:00
Philip Withnall
c613d32b92 tests: Add SPDX license headers automatically
Add SPDX license (but not copyright) headers to all files which follow a
certain pattern in their existing non-machine-readable header comment.

This commit was entirely generated using the command:
```
git ls-files gio/tests/*.c | xargs perl -0777 -pi -e 's/\n \*\n \* This library is free software; you can redistribute it and\/or\n \* modify it under the terms of the GNU Lesser General Public/\n \*\n \* SPDX-License-Identifier: LGPL-2.1-or-later\n \*\n \* This library is free software; you can redistribute it and\/or\n \* modify it under the terms of the GNU Lesser General Public/igs'
```

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

Helps: #1415
2022-05-18 09:20:07 +01:00
Philip Withnall
70ee43f1e9 glib: Add SPDX license headers automatically
Add SPDX license (but not copyright) headers to all files which follow a
certain pattern in their existing non-machine-readable header comment.

This commit was entirely generated using the command:
```
git ls-files glib/*.[ch] | xargs perl -0777 -pi -e 's/\n \*\n \* This library is free software; you can redistribute it and\/or\n \* modify it under the terms of the GNU Lesser General Public/\n \*\n \* SPDX-License-Identifier: LGPL-2.1-or-later\n \*\n \* This library is free software; you can redistribute it and\/or\n \* modify it under the terms of the GNU Lesser General Public/igs'
```

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

Helps: #1415
2022-05-18 09:19:02 +01:00
Philip Withnall
5942cd7984 gio: Add SPDX license headers automatically
Add SPDX license (but not copyright) headers to all files which follow a
certain pattern in their existing non-machine-readable header comment.

This commit was entirely generated using the command:
```
git ls-files gio/*.[ch] | xargs perl -0777 -pi -e 's/\n \*\n \* This library is free software; you can redistribute it and\/or\n \* modify it under the terms of the GNU Lesser General Public/\n \*\n \* SPDX-License-Identifier: LGPL-2.1-or-later\n \*\n \* This library is free software; you can redistribute it and\/or\n \* modify it under the terms of the GNU Lesser General Public/igs'
```

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

Helps: #1415
2022-05-18 09:18:52 +01:00
Philip Withnall
25d2925f3f Merge branch 'compiler-toolchain-reqs' into 'main'
docs: Add compiler and toolchain requirements from the wiki

See merge request GNOME/glib!2664
2022-05-18 07:57:46 +00:00
Philip Withnall
54a7e8a3a4 docs: Update supported platforms list
This just updates the list to reflect what we currently have in CI,
rather than any radical changes.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-05-18 08:36:50 +01:00
Philip Withnall
446e016923 docs: Formatting improvements to supported-platforms.md
This doesn’t change the content.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-05-18 08:36:50 +01:00
Philip Withnall
aa60b45ff8 docs: Add compiler and toolchain requirements from the wiki
These files are Markdown-ified versions of the following wiki pages:
 * https://wiki.gnome.org/Projects/GLib/CompilerRequirements
 * https://wiki.gnome.org/Projects/GLib/SupportedPlatforms

Keeping the files in version control with the rest of the documentation
means they should be easier to find, and easier to remember to keep up
to date.

They have not been modified other than to change to Markdown and tweak
the formatting. Content updates to them will be done in future commits.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-05-18 08:36:36 +01:00
Sebastian Dröge
d2f1e55a57 Merge branch 'reuse' into 'main'
docs: Initial REUSE licensing support

See merge request GNOME/glib!2663
2022-05-18 06:53:22 +00:00
Philip Withnall
31c1641073 docs: Add REUSE-compliant dep5 file for the license of a few directories
This bulk-adds licensing information for a load of test directories and
the `po/` directory, since it’s impractical or impossible to add
licensing information for those files otherwise.

For the test files, in particular, adding the licensing headers would
affect the tests. Adding `.license` files alongside would cause them to
get interpreted by the test runner, which is undesirable.

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

Helps: #1415
2022-05-17 17:23:34 +01:00
Philip Withnall
2dc8184590 tests: Add some SPDX license headers
These cover the files which Debian has already worked out the licensing
information for, in
https://salsa.debian.org/gnome-team/glib/-/blob/debian/master/debian/copyright.

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

Helps: #1415
2022-05-17 17:23:34 +01:00
Philip Withnall
46698ffcbd docs: Add all used licenses in a REUSE-compatible directory
This is the result of running `reuse download --all`.

This isn’t yet necessarily a comprehensive list of all licenses used in
GLib, as the majority of files in GLib are currently missing machine
readable copyright and licensing headers.

It’s a start though.

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

Helps: #1415
2022-05-17 17:23:34 +01:00
Marc-André Lureau
bb890b57d2 gobject/gsignalgroup: fix memory leaks on error
Spotted by ASAN during the tests:

Direct leak of 72 byte(s) in 1 object(s) allocated from:
    #0 0x7ff0b4562077 in calloc (/lib64/libasan.so.8+0xba077)
    #1 0x7ff0b3e8b508 in g_malloc0 ../glib/gmem.c:155
    #2 0x7ff0b375052f in g_closure_new_simple ../gobject/gclosure.c:220
    #3 0x7ff0b375b422 in g_cclosure_new ../gobject/gclosure.c:976
    #4 0x7ff0b37d159e in g_signal_group_connect_full ../gobject/gsignalgroup.c:790
    #5 0x7ff0b37d159e in g_signal_group_connect ../gobject/gsignalgroup.c:886
    #6 0x4045d8 in test_signal_group_invalid ../gobject/tests/signalgroup.c:331
    #7 0x7ff0b3f369a5 in test_case_run ../glib/gtestutils.c:2930
    #8 0x7ff0b3f369a5 in g_test_run_suite_internal ../glib/gtestutils.c:3018
    #9 0x7ff0b3f364ed in g_test_run_suite_internal ../glib/gtestutils.c:3035
    #10 0x7ff0b3f364ed in g_test_run_suite_internal ../glib/gtestutils.c:3035
    #11 0x7ff0b3f37879 in g_test_run_suite ../glib/gtestutils.c:3112
    #12 0x7ff0b3f37995 in g_test_run ../glib/gtestutils.c:2231
    #13 0x40253c in main ../gobject/tests/signalgroup.c:664
    #14 0x7ff0b2de758f in __libc_start_call_main (/lib64/libc.so.6+0x2d58f)

Direct leak of 72 byte(s) in 1 object(s) allocated from:
    #0 0x7f012addf077 in calloc (/lib64/libasan.so.8+0xba077)
    #1 0x7f012a708508 in g_malloc0 ../glib/gmem.c:155
    #2 0x7f0129fcd52f in g_closure_new_simple ../gobject/gclosure.c:220
    #3 0x7f0129fd8422 in g_cclosure_new ../gobject/gclosure.c:976
    #4 0x7f012a04e5ae in g_signal_group_connect_full ../gobject/gsignalgroup.c:791
    #5 0x7f012a04e5ae in g_signal_group_connect ../gobject/gsignalgroup.c:887
    #6 0x4043cc in test_signal_group_invalid ../gobject/tests/signalgroup.c:308
    #7 0x7f012a7b39a5 in test_case_run ../glib/gtestutils.c:2930
    #8 0x7f012a7b39a5 in g_test_run_suite_internal ../glib/gtestutils.c:3018
    #9 0x7f012a7b34ed in g_test_run_suite_internal ../glib/gtestutils.c:3035
    #10 0x7f012a7b34ed in g_test_run_suite_internal ../glib/gtestutils.c:3035
    #11 0x7f012a7b4879 in g_test_run_suite ../glib/gtestutils.c:3112
    #12 0x7f012a7b4995 in g_test_run ../glib/gtestutils.c:2231
    #13 0x40253c in main ../gobject/tests/signalgroup.c:664
    #14 0x7f012966458f in __libc_start_call_main (/lib64/libc.so.6+0x2d58f)

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-05-17 17:34:06 +02:00
Marc-André Lureau
15ce3c9b37 glib/tests/spawn-path-search: fix stack-buffer-overflow
==24477==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffde020de20 at pc 0x7f2e6f6413f1 bp 0x7ffde020c9d0 sp 0x7ffde020c180
READ of size 4101 at 0x7ffde020de20 thread T0
    #0 0x7f2e6f6413f0 in __interceptor_strlen.part.0 (/lib64/libasan.so.8+0x4c3f0)
    #1 0x7f2e6ef4abee in g_build_path_va ../glib/gfileutils.c:1908
    #2 0x7f2e6f085956 in g_test_build_filename_va ../glib/gtestutils.c:4294
    #3 0x7f2e6f086684 in g_test_build_filename ../glib/gtestutils.c:4365
    #4 0x403a33 in test_search_path_heap_allocation ../glib/tests/spawn-path-search.c:422
    #5 0x7f2e6f0839a5 in test_case_run ../glib/gtestutils.c:2930
    #6 0x7f2e6f0839a5 in g_test_run_suite_internal ../glib/gtestutils.c:3018
    #7 0x7f2e6f0834ed in g_test_run_suite_internal ../glib/gtestutils.c:3035
    #8 0x7f2e6f084879 in g_test_run_suite ../glib/gtestutils.c:3112
    #9 0x7f2e6f084995 in g_test_run ../glib/gtestutils.c:2231
    #10 0x40145f in main ../glib/tests/spawn-path-search.c:488
    #11 0x7f2e6e31258f in __libc_start_call_main (/lib64/libc.so.6+0x2d58f)
    #12 0x7f2e6e312648 in __libc_start_main_alias_1 (/lib64/libc.so.6+0x2d648)
    #13 0x401524 in _start (/home/elmarco/src/gnome/glib/build/glib/tests/spawn-path-search+0x401524)

Address 0x7ffde020de20 is located in stack of thread T0 at offset 4256 in frame
    #0 0x40387f in test_search_path_heap_allocation ../glib/tests/spawn-path-search.c:401

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-05-17 17:34:06 +02:00