Commit Graph

18604 Commits

Author SHA1 Message Date
Emmanuele Bassi
51065370a0 Merge branch '1041-atomic-bad-function-cast' into 'master'
Allow g_atomic_pointer_get() to be used by projects which enable -Wbad-function-cast

Closes #1041

See merge request GNOME/glib!166
2018-07-10 21:24:54 +00:00
Philip Withnall
194df27f5a gatomic: Tweak __atomic_load*() calls to work with -Wbad-function-cast
When compiling third-party projects with -Wbad-function-cast, the inline
g_atomic_pointer_get() implementation which uses C11 __atomic_load*()
calls on GCC was causing compilation errors like:

   error: cast from function call of type ‘long unsigned int’ to non-matching type ‘void *’

While we don’t want to compile all of GLib with -Wbad-function-cast, we
should support its headers being included in projects which do enable
that warning.

It doesn’t seem to be possible to cast away the warning (e.g. by casting
the function’s result through (void)), so we have to assign to an
intermediate integer of the right size first.

The same has to be done for the bool return value from
__sync_bool_compare_and_swap(). In that case, casting from bool to
gboolean raises a -Wbad-function-cast warning, since gboolean is
secretly int.

The atomic tests have been modified to enable -Wbad-function-cast to
catch regressions of this in future. The GLib build has conversely been
modified to set -Wno-bad-function-cast, just in case people have it set
in their environment CFLAGS.

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

https://gitlab.gnome.org/GNOME/glib/issues/1041
2018-07-10 17:49:16 +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
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
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
Xavier Claessens
c5321810f4 Merge branch '1432-reentrant' into 'master'
Resolve "Meson: Do we need -D_REENTRANT ?"

Closes #1432

See merge request GNOME/glib!149
2018-07-04 15:41:08 +00:00
Xavier Claessens
814d6a5956 Meson: Remove FIXME about _REENTRANT
As per discussion in GLib and Meson issues, this flag is not needed
anymore with modern gcc/clang. We only support GCC on Solaris now. This
might break the Sun/Oracle compilers on Solaris but Meson does not
suppor them (yet) anyway.

https://gitlab.gnome.org/GNOME/glib/issues/1432
https://github.com/mesonbuild/meson/issues/3810
2018-07-04 10:34:35 -04:00
Xavier Claessens
ed8c74461f ci: Install meson 0.47.0 on Windows envs 2018-07-03 16:01:55 -04:00
Xavier Claessens
deccba2807 Meson: Use subdir_done() now that it has been fixed 2018-07-03 11:06:48 -04:00
Xavier Claessens
95fa229f34 Meson: Fix warnings introduced in 0.47.0 2018-07-03 11:00:54 -04:00
Xavier Claessens
543a9c4f33 ci: Fix dist-job missing gobject/gio documentation
This requires meson >= 0.47.0 otherwise building the doc fails:
https://github.com/mesonbuild/meson/issues/3379

While at it, no need to to pass --prefix --libdir to meson, other CIs
don't have them.
2018-07-03 11:00:54 -04:00
Xavier Claessens
9d73ea8975 ci: Update meson to 0.47.0 in docker image 2018-07-03 11:00:54 -04:00
Olivier Blin
25b23978e1 regex: Require PCRE 8.31
PCRE >= 8.31 is required for PCRE_INFO_MAXLOOKBEHIND usage, introduced
in commit 6fbb146342 (2013/07).

regex can also make use of the PCRE_NO_AUTO_POSSESS feature from PCRE
8.34, but this is optional and properly guarded already.
2018-07-02 16:29:46 +02:00
Daniel Șerbănescu
6ee43d69fe Update Romanian translation 2018-07-01 15:06:57 +00:00
Xavier Claessens
2a1404ac21 Merge branch '977-checksum-constants' into 'master'
gchecksum: Use G_GUINT64_CONSTANT for SHA-512 constants

Closes #977

See merge request GNOME/glib!146
2018-06-29 20:17:55 +00:00