Commit Graph

18824 Commits

Author SHA1 Message Date
Philip Withnall
03bad78947 garray: Fix -Wsign-compare warnings
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-07-10 14:15:42 +02:00
Philip Withnall
4a53ed2073 Merge branch 'wip/hughsie/g_ref_string_new_len' into 'master'
Add a g_ref_string_new_len() to allow creating from non-NUL byte arrays

See merge request GNOME/glib!158
2018-07-09 17:30:12 +00:00
Richard Hughes
dad58d7392 Add a g_ref_string_new_len() to allow creating from non-NUL byte arrays
A lot of GLib APIs provide a string length and explicitly say that the strings
are not NUL terminated. For instance, parsing XML using GMarkupParser or
reading packed binary strings from mmapped data files.
2018-07-09 15:59:39 +01:00
Philip Withnall
92e059280f glib: Don’t use time(NULL) to get current time
Use either g_get_real_time() or g_date_time_new_now_local(). This means
we don’t need to worry about time_t being 32b in future (the year 2038
problem), and it makes the need for error handling a bit more explicit.
Improve the error handling in several cases.

Based on a patch by Niels De Graef
(https://gitlab.gnome.org/GNOME/glib/merge_requests/142).

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

https://gitlab.gnome.org/GNOME/glib/issues/1402
2018-07-09 13:28:02 +02:00
Philip Withnall
4deb94f067 Merge branch '1201-inotify-linking' into 'master'
Resolve "Linking failure on midipix with slibtool"

Closes #1201

See merge request GNOME/glib!157
2018-07-09 11:16:29 +00:00
Emmanuele Bassi
2585099a5d Merge branch 'refcount-box' into 'master'
Reference counted data allocations

See merge request GNOME/glib!92
2018-07-09 09:39:30 +00:00
Philip Withnall
9d6a69b73e gio: Link inotify file monitor to GLib and GObject
Apparently this is needed for building PE libraries. It makes no
difference on Linux, where linking of the GLib symbols in the inotify
file monitor code is done lazily.

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

https://gitlab.gnome.org/GNOME/glib/issues/1201
2018-07-09 10:38:04 +01:00
Emmanuele Bassi
822b511cb6 Update rcbox annotations for acquire/release functions
The accepted behaviour for reference counting functions can be described
as such:

 - acquire: takes a pointer to a memory area and returns the same
   pointer with its reference count increased; this means that the
   returned value's ownership is fully transfered from the callee
   to the caller
 - release: takes a pointer to a memory area and drops the reference
   count; this means that the caller transfers the ownership of the
   argument to the callee

These annotations are mostly meant for documentation purposes: high
level language bindings are unlikely to use them, as they have their own
reference counting semantics on top of GLib's own, and they should not
expose this API to their own consumers.
2018-07-09 10:11:42 +01:00
Emmanuele Bassi
0d00667d01 Increase coverage of atomic refcounted data
We are not testing the API directly, and this leads to holes in the code
coverage.
2018-07-09 10:11:42 +01:00
Emmanuele Bassi
37687941eb Increase coverage for GRefString
We still have some holes in the code coverage of the GRefString test
suite.
2018-07-09 10:11:42 +01:00
Emmanuele Bassi
cfe962a5dc Add missing trasfer annotation for g_ref_string_new()
We don't have one, but we ought to.
2018-07-09 10:11:42 +01:00
Emmanuele Bassi
18605db3ac Allow empty strings to be refcounted 2018-07-09 10:11:42 +01:00
Emmanuele Bassi
c342105e76 Add systemtap probes to refcounted data
Probes allow us to debug refcounting bugs.
2018-07-09 10:11:42 +01:00
Emmanuele Bassi
4248b4b300 Fix the implementation of interned refstrings
The global hash table we use for interned strings should not own a
reference on the strings themselves, as otherwise we'd leak them all
over the place.

Instead, it should keep a "weak" reference to them; once the last
strong reference goes away, we drop remove the weak reference from the
hash table.
2018-07-09 10:11:42 +01:00
Emmanuele Bassi
501a8e96e8 Add missing copyright notice 2018-07-09 10:11:42 +01:00
Emmanuele Bassi
61ca2e4c85 Check for overflow when allocating RcBox
Since we're over-allocating the passed block size, we need to check that
we're not overflowing gsize when computing the actual allocation size.
2018-07-09 10:11:42 +01:00
Emmanuele Bassi
7c4ac58938 Allow NULL clear function when releasing references
Both g_rc_box_release_full() and g_atomic_rc_box_release_full() should
allow passing NULL as the clear function, to conform to the existing
coding practices in GLib.

Additionally, this allows us to reimplement release() in terms of
release_full(), and improve test coverage.
2018-07-09 10:11:42 +01:00
Emmanuele Bassi
68304ae583 Improve docs for g_rc_box/g_atomic_rc_box
Especially the preconditions and the annotations for the returned
values.
2018-07-09 10:11:42 +01:00
Emmanuele Bassi
3bc0499eb2 Rename g_arc_box to g_atomic_rc_box
Makes the API more self-explanatory.
2018-07-09 10:11:42 +01:00
Emmanuele Bassi
32ecb86f5b Add length accessor for GRefString
Since we store the size of the allocation in the underlying ArcBox, we
can get a constant time getter for the length of the string.
2018-07-09 10:11:42 +01:00
Emmanuele Bassi
43b7a8f158 Add size accessor to RcBox and ArcBox
It may be useful to know how big a reference counted allocation is
outside of internal checks.
2018-07-09 10:11:42 +01:00
Emmanuele Bassi
00a723f597 Add reference counted strings
The last part of the reference counting saga.

Now that we have:

 - reference counter types
 - reference counted allocations

we can finally add reference counted strings using reference counted
allocations to avoid creating a new String type, and reimplementing
every single string-based API.
2018-07-09 10:11:42 +01:00
Emmanuele Bassi
4b33b03dd3 Improve the RcBox and ArcBox documentation
Use better examples, split up into sections, and mention use with
g_autoptr().
2018-07-09 10:11:42 +01:00
Emmanuele Bassi
8990c3c4d3 Make g_rc_box_dup()/g_arc_box_dup() more generic
It's more useful to have a dup() function that copies any blob of memory
into a reference counted allocation, than to have a dup() that only
copies a reference counted allocation.
2018-07-09 10:11:42 +01:00
Emmanuele Bassi
b607927a43 Add atomically refcounted data
GArcBox is the atomic reference counting version of GRcBox. Unlike
GRcBox, the reference acquisition and release on GArcBox are guaranteed
to be atomic, and thus they can be performed from different threads.

This is similar to Rust's Arc<Box<T>> combination of traits.
2018-07-09 10:11:42 +01:00
Emmanuele Bassi
c5d2417d07 Add refcounted data
It is useful to provide a "reference counted allocation" API that can
add reference counting semantics to any memory allocation. This allows
turning data structures that usually are placed on the stack into memory
that can be placed on the heap without:

 - adding a public reference count field
 - implementing copy/free semantics

This mechanism is similar to Rust's Rc<Box<T>> combination of traits,
and uses a Valgrind-friendly overallocation mechanism to store the
reference count into a private data segment, like we do with GObject's
private instance data.
2018-07-09 10:11:42 +01:00
Philip Withnall
884c4f4eb6 ci: Add allow_failure: true to FreeBSD runner
The FreeBSD runner is not stable yet. See
https://gitlab.gnome.org/Infrastructure/GitLab/issues/286.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Reviewed-by: nobody
2018-07-09 09:53:33 +01:00
Daniel Mustieles
419d4e610d Updated Spanish translation 2018-07-09 08:49:29 +02:00
Philip Withnall
f9589218dc Merge branch 'pcre-meson-dependency' into 'master'
meson: Add libpcre dependency version, as in configure.ac

See merge request GNOME/glib!155
2018-07-08 18:43:39 +00:00
Philip Withnall
6fea3289db Merge branch 'wip/lantw/ci-on-freebsd' into 'master'
Fix tests and add CI for FreeBSD

See merge request GNOME/glib!57
2018-07-08 18:41:30 +00:00
Philip Withnall
4256d99c3d meson: Add libpcre dependency version, as in configure.ac
Prompted by https://gitlab.gnome.org/GNOME/glib/merge_requests/148.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-07-08 14:34:53 +01:00
Philip Withnall
ddf03f64a4 Merge branch 'gresource-autocleanup' into 'master'
gio: Add missing autocleanup definition for GResource

Closes #1435

See merge request GNOME/glib!156
2018-07-08 10:41:25 +00:00
Adrian Perez de Castro
657be4f5fc
gio: Add missing autocleanup definition for GResource
Fixes #1435
2018-07-07 19:44:19 +03:00
Emin Tufan Çetin
17d86afa01 Update Turkish translation 2018-07-07 07:33:08 +00:00
Philip Withnall
3e74d587cf tests: Mark refcount/properties2 test as slow
It often takes a bit more than 30s to run on my local machine.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-07-06 15:01:58 +01:00
Philip Withnall
6438e2c731 tests: Mark gdbus-threading test as slow
It often takes a bit more than 30s on my local machine to run.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-07-06 15:01:40 +01:00
Philip Withnall
b1e0f09e7d tests: Add missing unit test to GLib tests list
It must have been accidentally omitted during the Meson port.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-07-06 14:58:57 +01:00
Philip Withnall
5422838e8d tests: Move two tests from GIO uninstalled helpers to test cases list
These are built and run as tests in the autotools build, and use GTest.
They are tests.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-07-06 14:58:25 +01:00
Philip Withnall
d31270e24c Merge branch 'pcre-8.31' into 'master'
regex: Require PCRE 8.31

See merge request GNOME/glib!148
2018-07-06 13:02:43 +00:00
Emmanuele Bassi
950b589b92 Merge branch '1332-drop-perl-dependency' into 'master'
build: Drop Perl dependency on autotools

Closes #1332

See merge request GNOME/glib!153
2018-07-06 12:59:14 +00:00
Philip Withnall
7c8aaa7e0d Merge branch 'ci-coverage-include-baseline' into 'master'
CI: Include coverage data of code which isn't executed by the test suite.

See merge request GNOME/glib!152
2018-07-06 12:28:52 +00:00
Philip Withnall
fde68be4b7 Merge branch 'meson-doc-ci' into 'master'
ci: Fix dist-job missing gobject/gio documentation

See merge request GNOME/glib!123
2018-07-06 12:22:24 +00:00
Philip Withnall
21f7566923 build: Drop Perl dependency on autotools
We don’t have the same dependency in the Meson build, and we don’t
depend on Perl any more. See #1332. The last remaining Perl script,
gen-unicode-tables.pl, is only ever run manually when we update our
Unicode character database. It will be ported to Python in due course.

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

https://gitlab.gnome.org/GNOME/glib/issues/1332
2018-07-06 13:07:10 +01:00
Christoph Reiter
69ae2f4242 CI: Include coverage data of code which isn't executed by the test suite.
See comment in !151. Using the "--initial" option of lcov we collect
the coverage of all compiled files and merge them later into the final
report. This way we can see which files are built but never executed
by the test suite.

Because the --initial switch also collects files in the ccache directory
we have to point it to the build directory instead, which in turn breaks
--no-external. Instead of using --no-external in the collection step,
filter out any files not in the source tree in the final coverage job
through a path filter.
2018-07-06 09:36:01 +02:00
Philip Withnall
cfc26b5a41 tests: Rework slow test handling for GIO tests
Make it follow the same pattern as in glib/tests/meson.build, using a
slow_tests array.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-07-05 17:14:53 +01:00
Philip Withnall
cf4f6d4808 tests: Ensure GIO tests which need dbus-daemon are run
The tests array was being wiped out by an assignment instead of an
append. This adds another 19 tests to what’s typically being run
already.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-07-05 13:26:48 +01:00
Philip Withnall
eeb5015ebe build: Make actions and gdbus-export GIO tests as slow
Increase their timeout.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-07-05 13:26:48 +01:00
Philip Withnall
a0cebdf4b6 tests: Use Unicode typography in gdbus-export test
This was missed in !137 because some of the GIO tests weren’t being run
under Meson (see following commits).

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-07-05 13:14:22 +01:00
Stef Walter
92a01e2280 gdbus-connection-loss: Fix leak in test
https://gitlab.gnome.org/GNOME/glib/issues/786
2018-07-05 13:13:59 +01:00
Philip Withnall
ab87af1734 gresource: Fix potential array overflow if using empty paths
Adds tests to cover this case and similar cases for various GResource
methods in future.

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

https://gitlab.gnome.org/GNOME/glib/issues/927
2018-07-05 12:03:10 +01:00