summaryrefslogtreecommitdiff
path: root/glib
Commit message (Collapse)AuthorAgeFilesLines
* docs: unify "dynamic memory needed" explanationsPeter Eisenmann2023-05-163-17/+26
| | | | | All `_take` method constructors require dynamic memory, this unifies theses explanation texts.
* gstring: add g_string_new_takePeter Eisenmann2023-05-163-0/+71
| | | | | Adds a GString constructor that takes over ownership of an existing, dynamically allocated, string.
* tests: Fix assertion failures when running fileutils test as roothanhuihui2023-05-111-4/+17
|
* tests: Move a function to allow looking at CAP_DAC_OVERRIDEhanhuihui2023-05-111-40/+40
| | | | | This introduces no functional changes but allows `CAP_DAC_OVERRIDE` to be used in a subsequent commit.
* Merge branch 'fix-group-comment' into 'main'Philip Withnall2023-05-102-77/+159
|\ | | | | | | | | | | | | gkeyfile: Fix group comment management Closes #104 and #2927 See merge request GNOME/glib!3380
| * gkeyfile: Fix group comment managementGaël Bonithon2023-04-202-65/+147
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This removes the `comment` member of the GKeyFileGroup structure, which seemed intended to distinguish comments just above a group from comments above them, separated by one or more blank lines. Indeed: * This does not seem to match any specification in the documentation, where blank lines and lines starting with `#` are indiscriminately considered comments. In particular, no distinction is made between the comment above the first group and the comment at the beginning of the file. * This distinction was only half implemented, resulting in confusion between comment above a group and comment at the end of the preceding group. Instead, the same logic is used for groups as for keys: the comment above a group is simply the sequence of key-value pairs of the preceding group where the key is null, starting from the bottom. The addition of a blank line above groups when writing, involved in bugs #104 and #2927, is kept, but: * It is now added as a comment as soon as the group is added (since a blank line is considered a comment), so that `g_key_file_get_comment()` returns the correct result right away. * It is always added if comments are not kept. * Otherwise it is only added if the group is newly created (not present in the original data), in order to really keep comments (existing and not existing). Closes: #104, #2927
| * gkeyfile: Replace g_slice_*() with g_new*()/g_free_sized()Gaël Bonithon2023-04-201-13/+13
| |
* | Merge branch 'gtk-plus' into 'main'Philip Withnall2023-05-1014-31/+30
|\ \ | | | | | | | | | | | | Rename GTK+ to GTK (mostly comments and documentation) See merge request GNOME/glib!3429
| * | Fix style-check for {gconvert,gutils,gobject}.cArnaud Rebillout2023-05-102-4/+3
| | | | | | | | | | | | Also take this chance to change a 'Glib' to 'GLib'.
| * | Rename GTK+ to GTK (mostly comments and documentation)Arnaud Rebillout2023-05-1014-28/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GTK lost it's '+' suffix back in 2019, according to <https://mail.gnome.org/archives/gtk-devel-list/2019-February/msg00000.html> This commit can be re-generated with: git grep -l GTK+ \ | grep -v -e ^NEWS -e ^glib/tests/collate.c \ | xargs sed -i 's/GTK+/GTK/g' Most of the changes are in comments and documentation.
* | | Merge branch 'main' into 'main'Philip Withnall2023-05-102-2/+97
|\ \ \ | |/ / |/| | | | | | | | | | | | | | gtestutils: Improve g_assert_cmpuint Closes #2997 See merge request GNOME/glib!3424
| * | gtestutils: Style touchupEric Blake2023-05-091-6/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use more modern styling to the code added in the previous patch: - split 'label: stmt; stmt;' into multiple lines - add default: label with g_assert_not_reached() [yes, it's a bit weird adding an assertion inside code that handles assertions, but we should be okay since g_assertion_message_* are not public functions and should only be used by our macros] - use <inttypes.h> for shorter format strings Note, however, that using uint64_t in gtestutils.h is not feasible, since it would require adding an '#include <stdint.h>' with potential unintended namespace pollution to older clients. Signed-off-by: Eric Blake <eblake@redhat.com>
| * | gtestutils: Improve g_assert_cmpuintEric Blake2023-05-092-2/+78
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While x86_64 has enough precision in long double to do a round trip from guint64 to long double and back, this is platform-specific, and is a disservice to users trying to debug failing unit tests on other architectures where it loses precision for g_assert_cmp{int,uint,hex}. See also https://bugzilla.gnome.org/show_bug.cgi?id=788385 which mentions having to add casts to specifically silence the compiler on platforms where the precision loss occurs. Meanwhile, g_assert_cmpuint() does an unsigned comparison, but outputs signed values if the comparison fails, which is confusing. Fix both issues by introducing a new g_assertion_message_cmpint() function with a new 'u' numtype. For backwards compatibility, the macros still call into the older g_assertion_message_cmpnum() when not targetting 2.78, and that function still works when passed 'i' and 'x' types even though code compiled for 2.78 and later will never invoke it with numtype anything other than 'f'. Note that g_assert_cmpmem can also take advantage of the new code, even though in practice, comparison between two size_t values representing array lengths that can actually be compiled is unlikely to have ever hit the precision loss. The macros in signals.c test code does not have to worry about versioning, since it is not part of the glib library proper. Closes #2997 Signed-off-by: Eric Blake <eblake@redhat.com>
* | | Merge branch 'wip/p3732/timeout-seconds-once' into 'main'Philip Withnall2023-05-093-15/+45
|\ \ \ | | | | | | | | | | | | | | | | add g_timeout_add_seconds_once See merge request GNOME/glib!3383
| * | | gtimeout: use helper for seconds_full variantPeter Eisenmann2023-05-021-15/+1
| | | | | | | | | | | | | | | | Use timeout_add_full() helper to deduplicate code
| * | | add g_timeout_add_seconds_oncePeter Eisenmann2023-05-023-0/+44
| |/ / | | | | | | | | | | | | Add a new call combing behaviors of g_timeout_add_seconds and g_timeout_add_once.
* | | tests: Zero the rlimit in standalone tests which are expected to abortPhilip Withnall2023-05-022-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This should hopefully stop the kernel spending a lot of memory and disk bandwidth creating coredumps for them unnecessarily, which slows down the rest of the tests and generally wastes resources. Signed-off-by: Philip Withnall <pwithnall@endlessos.org> Fixes: #2939
* | | tests: Add copyright/licensing header to assert-msg-testPhilip Withnall2023-05-021-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is put together through git archaeology: ``` git log -- glib/tests/assert-msg-test.c tests/assert-msg-test.c ``` The following commits were too trivial to have meaningful copyright: - 8e59d8602ca5921d78245f5d2b405b517a5e7cf9 - 44c004c84e9080040ff4e0e90b322dda0561cf85 - 207b8cb8a50d68e207d28b59e588311a5cbd9772 - a1bee97d4f093db01dee834bf3292eabd5b13d17 Signed-off-by: Philip Withnall <pwithnall@endlessos.org> Helps: #1415
* | | tests: Reformat assert-msg-test.c to follow coding stylePhilip Withnall2023-05-021-3/+6
|/ / | | | | | | Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
* | gtestutils: Fix section marker in documentationArnaud Rebillout2023-05-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | Apparently 3 hashes is too many, and as a result this line is not displayed properly in the HTML documentation. 2 hashes seems to be just right, as can be seen with: $ git grep '^ \* ##' | wc -l 65 $ git grep '^ \* ###' | wc -l 1
* | gthreadpool: Document that g_thread_pool_new() will spawn a threadPhilip Withnall2023-04-281-3/+7
| | | | | | | | | | | | | | | | | | Otherwise it might look like it would only start spawning threads when jobs are enqueued. Signed-off-by: Philip Withnall <pwithnall@endlessos.org> Helps: #2958
* | gthreadpool: Clarify that item_free_func is not normally calledPhilip Withnall2023-04-271-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If you’re only quickly looking at the API signature, it looks like `item_free_func` will be called for all items enqueued to the thread pool. As it happens, it’s actually only called for the items which are still enqueued when the thread pool is destroyed. The user’s `GFunc` is responsible for freeing items which are successfully dequeued and processed during the lifetime of the thread pool. That’s a bit of a gotcha, so document it more explicitly. Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
* | Merge branch '98-current-path' into 'main'Marco Trevisan2023-04-271-10/+14
|\ \ | | | | | | | | | | | | | | | | | | gfileutils: Fix potential integer overflow in g_get_current_dir() Closes #98 See merge request GNOME/glib!3375
| * | gfileutils: Fix potential integer overflow in g_get_current_dir()Philip Withnall2023-04-141-10/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In practice, this will never happen. If `getcwd()` returns `ERANGE` whenever the working directory is ≥ `PATH_MAX`, though, the previous implementation of the loop would run until `max_len == G_MAXULONG`, and would then overflow when adding `1` to it for a nul terminator in the allocation. Avoid that problem by always keeping `buffer_len` as a power of two, and relying on `getcwd()` to write a nul terminator within the buffer space it’s given. It seems to do this on all platforms we care about, because the previous version of the code never explicitly wrote a nul terminator anywhere. Signed-off-by: Philip Withnall <pwithnall@endlessos.org> Fixes: #98
* | | Merge branch 'unix-fd-source-docs' into 'main'Philip Withnall2023-04-261-3/+6
|\ \ \ | | | | | | | | | | | | | | | | glib-unix: Improve documentation for g_unix_fd_source_new() See merge request GNOME/glib!3396
| * | | glib-unix: Improve documentation for g_unix_fd_source_new()Philip Withnall2023-04-251-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | In particular, document the type of the callback function. Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
* | | | Avoid having g_futex_simple() inadvertently modify errnoPeter Kjellerstedt2023-04-261-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If both __NR_futex and __NR_futex_time64 are defined, g_futex_simple() will first call futex_time64(). If that fails with ENOSYS, then futex_time() is called instead. However, errno was not saved and restored in this case, which would result in g_futex_simple() returning with errno set to ENOSYS, even if futex_time() succeeded.
* | | | Merge branch 'doc-indentation' into 'main'Philip Withnall2023-04-242-2/+2
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | Fix small issues in docs See merge request GNOME/glib!3393
| * | | | Fix small issues in docsArjan Molenaar2023-04-242-2/+2
| |/ / / | | | | | | | | | | | | | | | | This will make converting the docs to another format (say, rst) somewhat easier.
* | | | Merge branch 'context-checks' into 'main'Philip Withnall2023-04-241-2/+19
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | gmain: More explicitly document g_main_context_release() prereqs See merge request GNOME/glib!3314
| * | | | gmain: Add precondition assertions to g_main_context_release()Philip Withnall2023-04-241-1/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As with the previous commit. The logic has to be a little contorted here to avoid leaving the context locked after emitting the critical warning. Execution does (and should) continue after a critical warning by default, so we should do our best to recover. Inspired by https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3302. Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
| * | | | gmain: More explicitly document g_main_context_release() prereqsPhilip Withnall2023-04-241-1/+4
| |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The documentation was fairly clear before, but we can make it clearer: it’s a programming error to call `g_main_context_release()` if you have not received a true return value from `g_main_context_acquire()` before. Inspired by https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3302. Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
* | | | Add init macros for refcounting typesEmmanuele Bassi2023-04-241-0/+54
|/ / / | | | | | | | | | | | | | | | We need a way to initialise refcounted types placed in static storage, or on the stack. Using proper macros avoids knowing the magic constant used for grefcount and gatomicrefcount.
* | | Merge branch 'gmain-less-locks' into 'main'Philip Withnall2023-04-242-83/+206
|\ \ \ | | | | | | | | | | | | | | | | gmain: Avoid some lock/unlock dance during g_main_context_iterate See merge request GNOME/glib!3235
| * | | gmain: Do not dead-look if calling g_main_loop_run from a GSourceMarco Trevisan (Treviño)2023-04-192-1/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This should fail and warn but not leaving the context acquired and locked. Add tests.
| * | | gmain: Avoid locking dance in g_main_loop_run()Marco Trevisan (Treviño)2023-04-191-9/+8
| | | | | | | | | | | | | | | | | | | | We do it during initialization, this may be if necessary handled by GCond in case we need to acquire the lock.
| * | | gmain: Avoid some lock/unlock dance during g_main_context_iterateMarco Trevisan (Treviño)2023-04-191-73/+125
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A context iteration we're doing lots of lock/unlocks and that's fine to give other threads contexts a chance to run, but we're doing it also just to call other functions that require locking, and this can be avoided. Other threads can still have a chance to run while releasing the ownership of the context.
* | | | Merge branch 'mutex-tests-more' into 'main'Philip Withnall2023-04-242-2/+2
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | glib/tests/[rec-]mutex: Allow each thread to work See merge request GNOME/glib!3389
| * | | | glib/tests/[rec-]mutex: Allow each thread to workMarco Trevisan (Treviño)2023-04-202-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In non-perf mode, we were making only one thread to win the race to increase the value, but since we're launching more threads anyways let's allow more of them to have a chance to do something, to make the test more valuable, even if it's still quick enough.
* | | | | gvariant: Fix doc for g_variant_new_object_pathArnaud Rebillout2023-04-211-2/+2
| | | | | | | | | | | | | | | | | | | | The parameter is named 'object_path', not 'string'.
* | | | | gmacros: Do not redefine NULL on C++Marco Trevisan (Treviño)2023-04-191-3/+0
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | Even though having NULL as nullptr should be the standard for newer C++ versions, it may break some headers, so let's not touch it for now. Closes: https://gitlab.gnome.org/GNOME/glib/-/issues/2973
* | | | Merge branch 'valgrind-variable' into 'main'Marco Trevisan2023-04-172-4/+41
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | meson: Add glib_valgrind_suppressions variable to glib pkg-config file See merge request GNOME/glib!3361
| * | | | meson: cleanup pkg-config variables definitionsMarco Trevisan (Treviño)2023-04-171-8/+9
| | | | | | | | | | | | | | | | | | | | Use more readable and shorter syntax
| * | | | meson: Add tests for generated pkg-config filesMarco Trevisan (Treviño)2023-04-171-0/+31
| | | | | | | | | | | | | | | | | | | | Ensure things are generated as we expect and avoid we regress on that.
| * | | | meson: Add glib_valgrind_suppressions variable to glib pkg-config fileMarco Trevisan (Treviño)2023-04-141-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Various projects are running tests under valgrind, and they are using the GLib suppresions to avoid false-positive results. While this is stored in a well-known path for some years, and easy to figure out from the GLib prefix, it's better to expose it through a proper pkgconfig variable so that it's easy to get it from any build system.
* | | | | Merge branch 'no-usleep-on-0' into 'main'Philip Withnall2023-04-172-0/+27
|\ \ \ \ \ | |_|_|_|/ |/| | | | | | | | | | | | | | gtimer: Avoid doing anything on g_usleep (0) See merge request GNOME/glib!3381
| * | | | gtimer: Avoid doing anything on g_usleep (0)Marco Trevisan (Treviño)2023-04-142-0/+27
| |/ / / | | | | | | | | | | | | | | | | It's unlikely to happen, but still could be the case, so avoid do anything.
* | | | Merge branch 'work-around-ucrt-spawn-env-issue' into 'main'Philip Withnall2023-04-142-10/+231
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | Work around an UCRT issue with _wspawn() functions taking an envp block See merge request GNOME/glib!3289
| * | | | Add test for UCRT issue workaroundLuca Bacci2023-04-141-1/+150
| | | | |
| * | | | Work around an UCRT issue with _wspawn() functions taking an environment ↵Luca Bacci2023-04-141-9/+81
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | block argument We were working around that with a call to chdir("."). Internally chdir() sets up cmd shell-related environment variables, but only if the current working directory belongs to a volume with a drive letter. For example, if the current working directory is on a UNC volume like a network share, the call to chdir() won't help. Reference: https://developercommunity.visualstudio.com/t/UCRT-Crash-in-_wspawne-functions/10262748