Commit Graph

21779 Commits

Author SHA1 Message Date
Philip Withnall
c45ad011f4 tests: Add tests for deprecated GBookmarkFile API
Just to check that it correctly wraps the new replacement APIs.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #1931
2020-05-28 14:55:53 +01:00
Philip Withnall
6147cae1c6 gbookmarkfile: Deprecate GBookmarkFile APIs which use time_t
They use the `time_t` type, which is not year 2038 safe on 32-bit
systems, so have to be deprecated.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Fixes: #1931
2020-05-28 14:55:53 +01:00
Philip Withnall
9b82fd021a tests: Update GBookmarkFile tests to use new APIs
In preparation for deprecating the old APIs. This shouldn’t functionally
affect the tests.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #1931
2020-05-28 14:55:53 +01:00
Philip Withnall
fbc1456971 gbookmarkfile: Add Y2038-proof APIs to GBookmarkFile
These are alternatives to the existing `time_t`-based APIs, which will
soon be deprecated due to `time_t` only being Y2038-safe on 64-bit
systems.

The new APIs take a GDateTime instead.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #1931
2020-05-28 14:55:53 +01:00
Sebastian Dröge
f733eff2ee Merge branch 'fix-fedora-ci-build' into 'master'
Rebuild Fedora CI image

See merge request GNOME/glib!1488
2020-05-26 16:09:39 +00:00
Philip Withnall
2ba0f14b52 Merge branch 'w32reg-mui' into 'master'
MUI capabilities for GWin32RegistryKey

See merge request GNOME/glib!1341
2020-05-22 16:21:41 +00:00
Руслан Ижбулатов
f77a6a1626 GWin32AppInfo: Drop read_resource_string(), use GWin32RegistryKey
Now GWin32RegistryKey can internally do the same thing that
read_resource_string() does, and more.
2020-05-22 14:17:12 +00:00
Sebastian Dröge
2730e5dcc3 Merge branch 'fix-file-test' into 'master'
tests: Speed up the file test and make it more reliable

See merge request GNOME/glib!1508
2020-05-22 10:54:58 +00:00
Sebastian Dröge
743bbb90da Merge branch 'cancellable-test-fix' into 'master'
tests: Speed up the cancellable test

See merge request GNOME/glib!1506
2020-05-22 10:36:11 +00:00
Philip Withnall
26c433d26c tests: Speed up the file test and make it more reliable
Sometimes this test was timing out due to the file monitor notifications
taking longer than the arbitrary 2s delay before ending the test and
checking its results at the end of `iclosed_cb()`.

Avoid that timing-dependence by ending the test when the expected file
monitor notifications are seen, or after a 10s timeout (if so, the test
is failed).

This makes the test run 4× faster in the normal case, as it’s no longer
waiting for a timeout to elapse if the file monitor notifications come
in sooner.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-05-22 11:05:27 +01:00
Philip Withnall
43969bf41a tests: Port file test to use g_assert_*() rather than g_assert()
g_assert() can be compiled out with G_DISABLE_ASSERT, which renders the
test rather useless.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-05-22 11:04:34 +01:00
Florentina Mușat
4f0b0e1b57 Update Romanian translation 2020-05-22 09:10:42 +00:00
Philip Withnall
60dd272b6a docs: Bump gtk-doc requirement for unit tests to 1.32.1
gtk-doc 1.33 hasn’t been released yet, but when it is, it’ll contain
three fixes which are necessary for correctly detecting which symbols
are undocumented/undeclared/unused in GLib:
 • gtk-doc@b866a90b
 • gtk-doc@ca42972c
 • gtk-doc@b922e148

1.32.1 is the development version number which will eventually be
released as 1.33.

Until then, we can’t run the gtk-doc tests in CI because they reliably
fail spuriously. See !1488.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-05-22 09:57:33 +01:00
Philip Withnall
57ed909857 ci: Document access token permissions needed for uploading images
New, finer-grained permissions are now supported in GitLab.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-05-22 09:32:44 +01:00
Philip Withnall
e89f41d3bf ci: Rebuild Fedora Docker image for latest Dockerfile changes
See !1464.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-05-22 09:32:44 +01:00
Philip Withnall
cbcc0aa1ea ci: Handle missing suite information in test output JSON
The gtk-doc tests are hardcoded by Meson to output as `glib /
gio-doc-check`, `glib / gobject-doc-check`, etc., without an explicit
project name and suite. This causes the following exception in the
report parser:
```
Traceback (most recent call last):
  File ".gitlab-ci/meson-junit-report.py", line 50, in <module>
    (project_name, suite_name) = full_suite.split(':')
ValueError: not enough values to unpack (expected 2, got 1)
```

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-05-22 09:32:44 +01:00
Philip Withnall
74f1e58219 ci: Add python3-pip to Fedora dependencies
It’s needed to provide the `pip3` executable, which the `Dockerfile`
later uses.

Follow-up to !1464.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-05-22 09:32:44 +01:00
Philip Withnall
31099d97eb Merge branch 'fix-2107-windows-gpoll-stall' into 'master'
win32 gpoll: Fix wait for at least one thread to return

Closes #2107

See merge request GNOME/glib!1504
2020-05-22 08:11:00 +00:00
Philip Withnall
8f291487fe Merge branch 'lcopyfail' into 'master'
gobject: Handle runtime checks as such

See merge request GNOME/glib!1505
2020-05-20 16:49:17 +00:00
Philip Withnall
9f27f49e34 tests: Speed up the cancellable test
The test added for #1841 spawned 100000 threads. That was fine on a
desktop machine, but on a heavily loaded CI machine, it could result in
large (and unpredictable) slowdowns, resulting in the test taking over
120s in about 1 in 5 runs, and hence failing that CI pipeline due to a
timeout. When passing normally on CI, the test would take around 90s.

Here’s a histogram of time per iteration on a failing (timed out) test
run. Each iteration is one thread spawn:

  Iteration duration (µs) | Frequency
  ------------------------+----------
                     ≤100 |     0
                  100–200 | 30257
                  200–400 | 13696
                  400–800 |  1046
                 800–1000 |   123
                1000–2000 |   583
                2000–4000 |  3779
                4000–8000 |  4972
               8000–10000 |  1027
              10000–20000 |  2610
              20000–40000 |   650
              40000–80000 |    86
             80000–100000 |    10
            100000–200000 |     2
                  >200000 |     0

There’s no actual need for the test to spawn 100000 threads, so rewrite
it to reuse a single thread, and pass new data to that thread.

Reverting the original commit (e4a690f5dd) reproduces the failure on
100 out of 100 test runs with this commit applied, so the test still
works.

The test now takes 3s, rather than 11s, to run on my computer, and has
passed when run with `meson test --repeat 1000 cancellable`.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-05-20 17:21:14 +01:00
Edward Hervey
898baa07b1 gobject: Handle runtime checks as such
The various `g_strdup_printf()` returns values in the implementations of GValue
lcopy_func are runtime checks which could be disabled if one wants and therefore
should be handled as such with g_return_val_if_fail()
2020-05-20 17:37:46 +02:00
Руслан Ижбулатов
a22a15dc5a GWin32RegistryKey: add MUI capabilities to get_value()
An extra argument to g_win32_registry_key_get_value_w() and
g_win32_registry_key_get_value() indicates that RegLoadMUIStringW()
should be used instead of RegQueryValueExW(). It only works on
strings, and automatically resolves resource strings (the ones
that start with "@").

The extra argument is needed to find resource DLLs that are only
specified by their relative name.
2020-05-20 14:23:49 +00:00
majordaw
26991b6093 win32 gpoll: Fix wait for at least one thread to return
When timeout grater than 0 in g_poll function, the WaitForMultipleObjects
call will wait for all the threads to return, but when only one thread
got an event the others will sleep until the timeout elapses, and causes
a stall. Triggering the stop event in g_poll in this case is useless as
it is triggered when all the threads where already signaled or timed-out.

Closes: https://gitlab.gnome.org/GNOME/glib/issues/2107
2020-05-20 15:32:47 +02:00
Sebastian Dröge
e816e9c86f Merge branch 'docs-fix' into 'master'
docs: Add indexes for symbols added in 2.66

See merge request GNOME/glib!1503
2020-05-20 12:13:29 +00:00
Philip Withnall
9f421dd678 docs: Add indexes for symbols added in 2.66
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-05-20 12:20:28 +01:00
Sebastian Dröge
e992b9978e Merge branch 'value-interned' into 'master'
GValue: Add interned string support

Closes #2109

See merge request GNOME/glib!1497
2020-05-20 08:25:40 +00:00
Sebastian Dröge
1d61c97761 Merge branch '1323-aarch64-mem-barrier' into 'master'
gthread: Use C11-style memory consistency to speed up g_once()

Closes #1323

See merge request GNOME/glib!1364
2020-05-19 17:22:41 +00:00
Edward Hervey
73d7f35ce7 gbinding: Use new g_value_set_interned_string() API for performance
The property strings are interned already, so this potentially allows for faster
comparisons. The property strings were already not copied, as they were tagged
as static.
2020-05-19 17:52:55 +02:00
Edward Hervey
1a95ce84ed GValue: Add interned string support
This adds support to be able to explicitely stored interned strings into
G_TYPE_STRING GValue.

This is useful for cases where the user:
* *knows* the string to be stored in the GValue is canonical
* Wants to know whther the string stored is canonical

This allows:
* zero-cost GValue copy (the content is guaranteed to be unique and exist
  throughout the process life)
* zero-cost string equality checks (if both string GValue are interned, you just
  need to check the pointers for equality or not, instead of doing a strcmp).

Fixes #2109
2020-05-19 17:52:55 +02:00
Edward Hervey
c964749de6 test: Add string GValue tests
Tests creation, duplication, ownership and copies
2020-05-19 17:52:55 +02:00
Edward Hervey
e3efbd30a2 gvalue: Static strings should not be copied
When doing copies of GValue backed by static strings, the contents should not be copied
2020-05-19 17:52:55 +02:00
Philip Withnall
c1d7097d0a build: Drop unused G_ATOMIC_OP_MEMORY_BARRIER_NEEDED
See the previous commit.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #1323
2020-05-19 16:20:31 +01:00
Philip Withnall
e52fb6b1d3 gthread: Use C11-style memory consistency to speed up g_once()
The g_once() function exists to call a callback function exactly once,
and to block multiple contending threads on its completion, then to
return its return value to all of them (so they all see the same value).

The full implementation of g_once() (in g_once_impl()) uses a mutex and
condition variable to achieve this, and is needed in the contended case,
where multiple threads need to be blocked on completion of the callback.

However, most of the times that g_once() is called, the callback will
already have been called, and it just needs to establish that it has
been called and to return the stored return value.

Previously, a fast path was used if we knew that memory barriers were
not needed on the current architecture to safely access two dependent
global variables in the presence of multi-threaded access. This is true
of all sequentially consistent architectures.

Checking whether we could use this fast path (if
`G_ATOMIC_OP_MEMORY_BARRIER_NEEDED` was *not* defined) was a bit of a
pain, though, as it required GLib to know the memory consistency model
of every architecture. This kind of knowledge is traditionally a
compiler’s domain.

So, simplify the fast path by using the compiler-provided atomic
intrinsics, and acquire-release memory consistency semantics, if they
are available. If they’re not available, fall back to always locking as
before.

We definitely need to use `__ATOMIC_ACQUIRE` in the macro implementation
of g_once(). We don’t actually need to make the `__ATOMIC_RELEASE`
changes in `gthread.c` though, since locking and unlocking a mutex
guarantees to insert a full compiler and hardware memory barrier
(enforcing sequential consistency). So the `__ATOMIC_RELEASE` changes
are only in there to make it obvious what stores are logically meant to
match up with the `__ATOMIC_ACQUIRE` loads in `gthread.h`.

Notably, only the second store (and the first load) has to be atomic.
i.e. When storing `once->retval` and `once->status`, the first store is
normal and the second is atomic. This is because the writes have a
happens-before relationship, and all (atomic or non-atomic) writes
which happen-before an atomic store/release are visible in the thread
doing an atomic load/acquire on the same atomic variable, once that load
is complete.

References:
 * https://preshing.com/20120913/acquire-and-release-semantics/
 * https://gcc.gnu.org/onlinedocs/gcc-9.2.0/gcc/_005f_005fatomic-Builtins.html
 * https://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync
 * https://en.cppreference.com/w/cpp/atomic/memory_order#Release-Acquire_ordering

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Fixes: #1323
2020-05-19 16:17:39 +01:00
Sebastian Dröge
e4c3af9d4e Merge branch '602-introspect-thread' into 'master'
gthread: Add introspection annotations

Closes #602

See merge request GNOME/glib!1499
2020-05-19 15:15:00 +00:00
Philip Withnall
bfd8f8cbaf tests: Add multi-threaded test for g_once()
There were multi-threaded tests for g_once_init_{enter,leave}(), but not
for g_once(). Add one which tests multi-threaded contention for entering
and retrieving the value of the `GOnce`.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #1323
2020-05-19 16:06:07 +01:00
Philip Withnall
596fa49aa0 tests: Tidy up test naming in glib/tests/once.c
Make it a little clearer. This introduces no functional changes.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #1323
2020-05-19 16:06:07 +01:00
Sebastian Dröge
536e32c5a8 Merge branch '176-malloc-docs' into 'master'
gmem: Improve documentation to clarify abort-on-alloc-failure

Closes #176

See merge request GNOME/glib!1500
2020-05-19 14:41:27 +00:00
Philip Withnall
445aa65e90 gmem: Improve documentation to clarify abort-on-alloc-failure
Clarify that it applies to everything.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Fixes: #176
2020-05-19 15:12:16 +01:00
Philip Withnall
1cb2db8515 gthread: Add introspection annotations
It’s not expected that bindings will use `GThread` over their own
threading APIs (in fact that would generally be a bad idea, since
threads benefit from being integrated into language control flow
structures), but it can’t hurt to have the annotations right for
documentation purposes if nothing else.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Fixes: #602
2020-05-19 14:52:17 +01:00
Philip Withnall
81ee85c793 Merge branch 'th/g-ptr-array-new' into 'master'
array: add internal ptr_array_new() helper for creating GPtrArray

See merge request GNOME/glib!1498
2020-05-18 10:28:25 +00:00
Cheng-Chia Tseng
b86d6fee66 Update Chinese (Taiwan) translation 2020-05-17 17:09:06 +00:00
Emin Tufan Çetin
20fb5bf868 Update Turkish translation 2020-05-16 11:58:36 +00:00
Thomas Haller
1efa966b6f array: add internal ptr_array_new() helper for creating GPtrArray
Unify the creation of GPtrArray.

Maybe we will add yet another constructor for creating %NULL terminated
arrays. Unify the constructors by adding an internal helper method.

The alternative instead of adding a ptr_array_new() helper, would be to
let everybody call g_ptr_array_full(). For no strong reasons, choose
this approach because the compiler is more eager to inline the static
helper as it would inlining g_ptr_array_full().
2020-05-15 17:47:11 +02:00
Sebastian Dröge
f6d26ba772 Merge branch 'fix-1487-reversion' into 'master'
Fix GLIB_UNAVAILABLE_STATIC_INLINE declaration

See merge request GNOME/glib!1496
2020-05-15 13:10:03 +00:00
Philip Withnall
4364c51722 gmacros: Add missing GLIB_UNAVAILABLE_STATIC_INLINE declaration
This fixes building against GLib with
`GLIB_DISABLE_DEPRECATION_WARNINGS` defined.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
See: !1487
2020-05-15 12:00:03 +01:00
Philip Withnall
0fc7f409f6 Revert "Revert "glib: annotate static inline functions with G_AVAILABLE-type macros""
This reverts commit c0146be3a4.

The revert was originally added because the original change broke
gnome-build-meta. Now that the problem has been diagnosed, the original
commit can be fixed — see the commit which follows this one.

See: !1487
2020-05-15 11:59:06 +01:00
Philip Withnall
85f8efae0f Merge branch 'aleksm/mkenums-since' into 'master'
glib-mkenums: allow optional 'since' tag

See merge request GNOME/glib!1492
2020-05-14 16:10:33 +00:00
Philip Withnall
01fbeb601b Merge branch 'assert-no-errno' into 'master'
gtestutils: Add a new g_assert_no_errno() test macro

See merge request GNOME/glib!1204
2020-05-14 16:09:40 +00:00
Sebastian Dröge
12fbb286ae Merge branch 'fix-cpu-docker' into 'master'
ci: Update Android Docker image for aarch64 CPU naming change

See merge request GNOME/glib!1402
2020-05-14 15:12:48 +00:00
Sebastian Dröge
bc2bfdfa43 Merge branch '2082-get-rid-of-am-pm' into 'master'
gdatetime: Document that specific AM/PM formatting is discouraged

Closes #2082

See merge request GNOME/glib!1445
2020-05-14 15:07:12 +00:00