Commit Graph

2300 Commits

Author SHA1 Message Date
Christoph Reiter
11fcc2f1ac build: simplify alloca checks. See #1313
The goal of this commit is to reduce differences between the autotools and meson build.

With autotools AC_FUNC_ALLOCA was used which defines HAVE_ALLOCA_H, HAVE_ALLOCA,
C_ALLOCA. meson tried to replicate that with has_function() but alloca can be a macro
and and is named _alloca under Windows. Since we require a working alloca anyway
and only need to know if the header exists replace AC_FUNC_ALLOCA with a simple
AC_CHECK_HEADERS.

There is still one user of HAVE_ALLOCA in the embedded gnulib, but since alloca is
always provided through galloca.h just force define HAVE_ALLOCA there and add a comment.

The docs were mentioning alloca as an example for cross compiling. Since that variable no
longer exists now replace it with another one.
2018-08-24 10:57:10 +02:00
Xavier Claessens
f046801217 Meson: Update cross compilation doc
(Modified by Philip Withnall <withnall@endlessm.com> to improve
formatting on original.)

Closes #1363
2018-08-07 16:52:49 +01:00
Philip Withnall
c0f8792d6b docs: Add missing API indexes for old versions
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-07-30 21:13:48 +01:00
Philip Withnall
40fc18521b docs: Fix glib-sections.txt includes for g_atomic_rc_* API
These were not changed when g_arc_*() was renamed to g_atomic_rc_*().

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-07-30 21:12:43 +01:00
Philip Withnall
f9705f7a0c docs: Don’t distribute generated man pages
They should either be generated at build time, or ignored completely,
depending on the presence of --[enable|disable]-man.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-07-30 20:04:13 +01: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
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
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
Xavier Claessens
88d13b4d09 doc: Remove glib.types since glib has not GType 2018-06-28 09:55:56 -04:00
Xavier Claessens
124779be88 doc: Remove gobject.types since gtkdoc-scan rebuild it anyway
I'm not sure why gobject.cI was needed but that looks like hack around
old gtkdoc bug. Works fine without it.
2018-06-28 09:55:56 -04:00
Xavier Claessens
71bc8e797b doc: Remove gio.types since gtkdoc-scan rebuild it anyway
meson.build was already passing --rebuild-types option but not
Makefile.am. Copy the IGNORE_HFILES list from meson.build because it was
outdated in Makefile.am and it's causing build issues when using the
generated gio.types file because it would contain win32 types when
building on linux.
2018-06-28 09:55:56 -04:00
Will Thompson
2e7d22a3bd
gvariant-text: fix bytestring example
ord('a') == 97 == 0x61 != 0x97.

    >>> GLib.Variant.parse(None, "[byte 0x97, 0x98, 0x99, 0]", None, None)
    GLib.Variant('ay', b'\227\230\231')
    >>> GLib.Variant.parse(None, "[byte 0x61, 0x62, 0x63, 0]", None, None)
    GLib.Variant('ay', b'abc')
2018-06-22 10:01:58 +01:00
Philip Withnall
ca98ce4280 Merge branch 'master' into 'master'
Use posix_spawn for optimized process launching

See merge request GNOME/glib!95
2018-06-21 17:10:43 +00:00
Daniel Drake
156d009696 gdesktopappinfo: add g_desktop_app_info_launch_uris_as_manager_with_fds variant
Add an app-launching function which allows standard file descriptors
to be passed to the child process.

This will be used by gnome-shell to pass systemd journal descriptors
as stdout/stderr. gnome-shell's child_setup function can then be
eliminated, which will enable use of the posix_spawn optimized
gspawn codepath for desktop app launching.
2018-06-21 11:44:59 -05:00
Daniel Drake
3524de16e4 gspawn: Add g_spawn_async_with_fds variant
Add a new process spawning function variant which allows the caller
to pass specific file descriptors for stdin, stdout and stderr.
It is otherwise identical to g_spawn_async_with_pipes.

Allow the same fd to be passed in multiple parameters. To make this
workable, the child process logic that closes the fd after the first time
it has been dup2'ed needed tweaking; we now just set those fds to be
closed upon exec using the CLOEXEC flag. Add a test for this case.

This will be used by gnome-shell to avoid performing equivalent
dup2 actions in a child_setup function. Dropping use of child_setup will
enable use of an upcoming optimized process spawning codepath.
2018-06-21 11:43:32 -05:00
segfault
76b4d0ab3f Add support for TCRYPT volumes to GMountOperation
Add G_ASK_PASSWORD_TCRYPT flag to GAskPasswordFlags and add the
following properties to GMountOperation:

- hidden_volume [1]
- system_volume [2]
- pim [3]

[1] https://www.veracrypt.fr/en/Hidden%20Volume.html
[2] https://www.veracrypt.fr/en/System%20Encryption.html
[3] https://www.veracrypt.fr/en/Personal%20Iterations%20Multiplier%20(PIM).html
2018-06-21 15:32:04 +02:00
Emmanuele Bassi
df28cfe0b5 Merge branch '896-variant-type-docs' into 'master'
Documentation and typing improvements for GVariant bytes

Closes #896

See merge request GNOME/glib!117
2018-06-19 14:15:37 +00:00
Philip Withnall
5e46a97ac6 gvariant: Document differences between GVariant bytestrings and arrays
https://gitlab.gnome.org/GNOME/glib/issues/896
2018-06-15 13:17:25 +01:00
Olivier Crête
8e65417c6e docs: Change Bugzilla references to GitLab
Including modifications by Philip Withnall <withnall@endlessm.com>
2018-06-15 13:04:39 +01:00
Philip Withnall
8916874ee6 codegen: Add --interface-info-[body|header] modes
These generate basic .c and .h files containing the GDBusInterfaceInfo
for a D-Bus introspection XML file, but no other code (no skeletons,
proxies, GObjects, etc.).

This is useful for projects who want to describe their D-Bus interfaces
using introspection XML, but who wish to implement the interfaces
manually (for various reasons, typically because the skeletons generated
by gdbus-codegen are too simplistic and limiting). Previously, these
projects would have had to write the GDBusInterfaceInfo manually, which
is painstaking and error-prone.

The new --interface-info-[body|header] options are very similar to
--[body|header], but mutually exclusive with them.

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

https://bugzilla.gnome.org/show_bug.cgi?id=795304
2018-06-14 18:57:53 +01:00
Philip Withnall
d8c003dea6 Merge branch 'G_SOURCE_FUNC-macro' into 'master'
Add G_SOURCE_FUNC cast macro which suppresses -Wcast-function-type

See merge request GNOME/glib!82
2018-06-14 09:34:12 +00:00
Will Thompson
039fa6897b
Add G_SOURCE_FUNC cast macro which suppresses -Wcast-function-type
This is the workaround suggested by
https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wcast-function-type

This warning is not enabled by default during the GLib build, but
applications may want to opt into it.
2018-06-14 10:11:12 +01:00
Emmanuele Bassi
9e5a53d576 Add reference counting types
We have a common pattern for reference counting in GLib, but we always
implement it with ad hoc code. This is a good chance at trying to
standardise the implementation and make it public, so that other code
using GLib can take advantage of shared behaviour and semantics.

Instead of simply taking an integer variable, we should create type
aliases, to immediately distinguish the reference counting semantics of
the code; we can handle mixing atomic reference counting with a
non-atomic type (and vice versa) by using differently signed values for
the atomic and non-atomic cases.

The gatomicrefcount type is modelled on the Linux kernel refcount_t
type; the grefcount type is added to let single-threaded code bases to
avoid paying the price of atomic memory barriers on reference counting
operations.
2018-06-11 14:59:39 +01:00
Ondrej Holy
8df517b457 docs: Document g_unix_mount_for
g_unix_mount_for() has been added into GLib before some time,
however, it is missing in the docs.
2018-06-06 12:24:12 +02:00
Christoph Reiter
3aa23078ac build: Remove the --disable-mem-pools build option and the DISABLE_MEM_POOLS macro
It's mostly not used anymore and doesn't do what it says it does.

The docs state that it affects GList, GSList, GNode, GMemChunks, GSignal,
GType n_preallocs and GBSearchArray while:

* GList, GSList and GNode use GSlice and are not affected
* GMemChunks is gone
* GType npreallocs is ignored

It also states that it can be used to force the usage of g_malloc/g_free,
which is handled by G_SLICE=always-malloc now.

The only places where it's used is in signal handling through GBSearchArray
and in GValueArray (deprecated). Since it's unlikely that anyone wants to
reduce allocation sizes just for those cases remove the build option.
2018-06-02 09:45:55 +02:00
Christoph Reiter
118332dd5c Remove unused ENABLE_GC_FRIENDLY_DEFAULT and its build option
ENABLE_GC_FRIENDLY_DEFAULT was supposed to set the default for the gc friendliness
while still allowing to force enable it at runtime with G_DEBUG=gc-friendly.

With commit 943a18b564 (6 years ago) things were changed to always set it
according to the content of G_DEBUG in glib_init(), making the default unused.

Since nobody complained since then just remove the macro and the build option.
2018-05-31 07:19:12 +02:00
Emmanuele Bassi
0b4c2eefce Add fuzzy floating point comparison macro
Add a test macro that allows comparing two floating point values for
equality within a certain tolerance.

This macro has been independently reimplemented by various projects:

 * Clutter
 * Graphene
 * colord

https://gitlab.gnome.org/GNOME/glib/issues/914
2018-05-29 10:02:47 +01:00
Emmanuele Bassi
24e98e38d6 Add a macro for checking approximate values
A macro like this is useful to avoid direct comparisons between floating
point values.

https://gitlab.gnome.org/GNOME/glib/issues/914
2018-05-29 09:55:47 +01:00
Philip Withnall
6730309826 Merge branch 'wip/hadess/g-drive-identifier' into 'master'
gio: Add G_DRIVE_IDENTIFIER_KIND_UNIX_DEVICE

See merge request GNOME/glib!10
2018-05-28 16:31:42 +00:00
Bastien Nocera
4c84eac38e gio: Add G_DRIVE_IDENTIFIER_KIND_UNIX_DEVICE
It's a synonym of G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE.
It doesn't change anything except not feeling dirty from using a wrongly
prefixed constant for the object type.

See: #182
2018-05-28 17:13:30 +02:00
Xavier Claessens
3145d88f4b Add mingw64 cross build CI
Fixes #1387.
2018-05-28 09:22:55 -04:00
Pavlo Solntsev
9e62a425bd doc: Interface for derivable object 2018-05-25 12:50:21 -05:00
Ondrej Holy
d0821da524 gio: Add g_unix_mount_get_options
GVfsUDisks2VolumeMonitor handles x-gvfs-hide/x-gvfs-show mount options
used to overwrite our heuristics whether the mount should be shown, or
hidden. Unfortunately, it works currently only for mounts with
corresponding fstab entries, because the options are read over
g_unix_mount_point_get_options. Let's introduce g_unix_mount_get_options
to allow reading of the options for all sort of mounts (e.g. created
over pam_mount, or manually mounted).

(Minor fixes to the documentation by Philip Withnall
<withnall@endlessm.com>.)

https://bugzilla.gnome.org/show_bug.cgi?id=668132
2018-05-16 11:31:42 +01:00
Christian Hergert
ede5c3f8d9 macros: add G_GNUC_NO_INLINE function attribute
https://bugzilla.gnome.org/show_bug.cgi?id=795180
2018-05-09 12:25:06 +01:00
Philip Withnall
6acece5074 ghash: Add g_hash_table_steal_extended()
This is a combination of g_hash_table_lookup_extended() and
g_hash_table_steal(), so that users can combine the two to reduce code
and eliminate a pointless second hash table lookup by
g_hash_table_steal().

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

https://bugzilla.gnome.org/show_bug.cgi?id=795302
2018-05-08 12:41:13 +01:00
Georges Basile Stavracas Neto
b9b642de06 fileutils: Add g_canonicalize_filename
Getting the canonical filename is a relatively common
operation when dealing with symbolic links.

This commit exposes GLocalFile's implementation of a
filename canonicalizer function, with a few additions
to make it more useful for consumers of it.

Instead of always assuming g_get_current_dir(), the
exposed function allows passing it as an additional
parameter.

This will be used to fix the GTimeZone code to retrieve
the local timezone from a zoneinfo symlink.

(Tweaked by Philip Withnall <withnall@endlessm.com> to drop g_autofree
usage and add some additional tests.)

https://bugzilla.gnome.org/show_bug.cgi?id=111848
2018-04-30 21:54:31 +01:00
Allison Lortie
ad3b2f2387 gmessages: clarify what log levels are for
For a long time we've had it as 'common knowledge' that criticals are
for programmer errors and warnings are for external errors, but we've
never documented that.  Do so.

(Modified by Philip Withnall <withnall@endlessm.com> to apply cleanly to
master; rearranged to fit in with current master documentation.)

https://bugzilla.gnome.org/show_bug.cgi?id=741049
2018-04-23 13:01:17 +01:00
Philip Withnall
cf24867b93 gtimezone: Add g_time_zone_new_offset() convenience constructor
This includes tests.

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

https://bugzilla.gnome.org/show_bug.cgi?id=676923
2018-04-13 15:25:26 +01:00
Philip Withnall
8945227743 gtimezone: Add g_time_zone_get_identifier() accessor
This is a non-trivial accessor which gets the identifier string used to
create the GTimeZone — unless the string passed to g_time_zone_new() was
invalid, in which case the identifier will be `UTC`.

Implementing this required reworking how timezone information was loaded
so that the tz->name is always set at the same time as tz->t_info, so
they are in sync. Previously, the tz->name was unconditionally set to
whatever was passed to g_time_zone_new(), and then not updated if the
tz->t_info was eventually set to the default UTC information.

This includes tests for the new g_time_zone_get_identifier() API, and
for the g_date_time_get_timezone() API added in the previous commit.

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

https://bugzilla.gnome.org/show_bug.cgi?id=795165
2018-04-12 13:25:16 +01:00
Philip Withnall
9ddd17d304 gdatetime: Add g_date_time_get_timezone() accessor
This is a trivial method to get the GTimeZone for the GDateTime.

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

https://bugzilla.gnome.org/show_bug.cgi?id=795165
2018-04-12 13:25:16 +01:00
Mohammed Sadiq
abf28c71b0 docs: Fix typo in examples 2018-04-10 20:01:40 +05:30
Руслан Ижбулатов
6635922072 Platform-dependent header ignore list for gio docs
This is a bit awkward. A more elegant solution would have
ignored *all* headers and then *un-ignored* some of them
if some conditions were met.

Sadly, we cannot really ignore all headers and then "unignore"
them: that's not how arrays in Meson work.

https://bugzilla.gnome.org/show_bug.cgi?id=794557
2018-03-28 11:52:25 +00:00
Frank Dana
523c62aaa6 Remove duplicated option in gio.xml
The gio(1) man page entry for the tree subcommand lists '-h' twice under its Options, because that flag was duplicated in the source xml.

https://bugzilla.gnome.org/show_bug.cgi?id=794473
2018-03-21 14:35:02 +00:00
Emmanuele Bassi
c5c3fa83c9 docs: Use appropriate tags for commands
The glib-compile-resources documentation refers to various command line
tools, and those should be wrapped in the <command> DocBook tag.

https://bugzilla.gnome.org/show_bug.cgi?id=794284
2018-03-14 14:09:24 +00:00
Emmanuele Bassi
7fd17c4337 Support whitespace stripping for JSON resources
Similarly to how glib-compile-resources can call xmllint to eliminate
whitespace in XML files to reduce their size inside a GResource, we can
use json-glib-format to achieve the same result.

The mechanism for using json-glib-format is the same, with a separate
environment variable if we want to direct glib-compile-resources to a
version of json-glib-format that is not the one in the PATH.

https://bugzilla.gnome.org/show_bug.cgi?id=794284
2018-03-14 11:46:17 +00:00
Emmanuele Bassi
9453b97e09 docs: Add G_ENABLE_DIAGNOSTIC
We need to mention this environment variable, so that developers have a
fighting chance of actually using it.

https://bugzilla.gnome.org/show_bug.cgi?id=732184
2018-02-15 11:25:53 +00:00
Allison Lortie
1574321e51 GKeyFile: add API for getting locale of a string
g_key_file_get_locale_string() returns a translated string from the
keyfile.  In some cases, it may be useful to know the locale that that
string came from.

Add a new API, g_key_file_get_locale_for_key(), that returns the locale
of the string.

Include tests.

(Modified by Philip Withnall to rename the API and fix some minor review
issues. Squash in a separate test case commit.)

https://bugzilla.gnome.org/show_bug.cgi?id=605700
2018-02-06 15:51:33 +00:00