Commit Graph

26597 Commits

Author SHA1 Message Date
Marco Trevisan (Treviño)
f8fa9d3a2b ci: Open issues when scheduled pipelines fails
It's hard to track failures on scheduled pipelines, so make gitlab open
an issue for us if that happens.
2022-10-31 02:51:40 +01:00
Marco Trevisan (Treviño)
0ca5254c5d glib/gmacros: Always define NULL as nullptr in C++11 and newer 2022-10-31 01:00:06 +01:00
Simon McVittie
bb7d7c4616 docs: Soft-deprecate sized integer types in favour of (u)intN_t
C99 does not actually guarantee that the platform has 8-, 16-, 32- and
64-bit types, but it does guarantee that if the platform has them, then
(u)intN_t are defined to be examples of those types.

GLib goes beyond what C99 guarantees, and requires 8-, 16-, 32- and
64-bit types; combining that with C99's requirements means we can
assume that int8_t, uint64_t, etc. all exist.

Unfortunately, we cannot guarantee that GLib and the C99 toolchain have
chosen the *same* fixed-size type: for example, on a typical ILP32
or LLP64 platform like Windows or 32-bit Linux, each 32-bit type could
either be int or long, while on a LP64 platform like 64-bit Linux,
each 64-bit type could either be long or long long. The in-memory
representation is the same either way, but the choice of underlying type
matters when building printf format strings or issuing compiler warnings.
As a result, we can't just typedef gint32 as int32_t and so on.

Resolves: https://gitlab.gnome.org/GNOME/glib/-/issues/1484
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-10-28 11:08:33 +01:00
Simon McVittie
6a8f96510b docs: Clarify relationship between goffset and POSIX off_t
The important thing here is that we can't arbitrarily mix these, even if
they will often have the same in-memory representation.

Helps: https://gitlab.gnome.org/GNOME/glib/-/issues/1484
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-10-28 11:04:49 +01:00
Philip Withnall
9635fd4e40 Merge branch 'wip/smcv/sizes-and-pointers' into 'main'
Improve documentation and static assertions around g(s)size, g(u)intptr

See merge request GNOME/glib!3001
2022-10-28 09:18:51 +00:00
Philip Withnall
9f10881574 Merge branch 'wip/smcv/autofd' into 'main'
gstdio: Silence "Not available before" warnings for inline functions

Closes #2796

See merge request GNOME/glib!3026
2022-10-27 21:55:09 +00:00
Simon McVittie
da3fc59544 glib-init: Add more static assertions for gintptr, guintptr
Helps: https://gitlab.gnome.org/GNOME/glib/-/issues/1484
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-10-27 19:54:26 +01:00
Simon McVittie
589f29e005 docs: Soft-deprecate g(u)intptr in favour of (u)intptr_t
These have a status similar to size_t: they're Standard C types and
straightforward to use in portable code this decade, but we can't
guarantee that we have chosen the same underlying type that the platform
uses.

Helps: https://gitlab.gnome.org/GNOME/glib/-/issues/1484
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-10-27 19:54:24 +01:00
Simon McVittie
43d8545045 glib-init: Add more static assertions about gsize
Helps: https://gitlab.gnome.org/GNOME/glib/-/issues/1484
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-10-27 19:54:23 +01:00
Simon McVittie
de2602736d docs: Clarify the relationship between gssize, ssize_t and SSIZE_T
This is similar to the relationship between gsize and size_t, except
that size_t is a Standard C type but ssize_t is platform-specific
(specifically, ssize_t is a POSIX type, and on Windows the equivalent
is SSIZE_T), making it more awkward to use in portable code. As a
result, continuing to use gssize is more useful than continuing to use
gsize.

Helps: https://gitlab.gnome.org/GNOME/glib/-/issues/1484
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-10-27 19:54:20 +01:00
Simon McVittie
9f19eb454b docs: Soft-deprecate gsize in favour of standard size_t
We have chosen the underlying type that implements gsize to be the same
size as the standard C89 size_t (the top-level meson.build sets this up).

Unfortunately, we cannot guarantee that GLib and the C toolchain have
chosen the *same* fixed-size type: for example, on a typical ILP32
platform like 32-bit Windows or Linux, each of gsize and size_t
can either be int or long, while on a LP64 platform like 64-bit Linux,
each could either be long or long long. meson.build tries to choose the
same type to reduce compiler warnings, but it can only do this if the
compiler implements `-Werror`.

The in-memory representation is the same either way, but the choice of
underlying type matters when building printf format strings or issuing
compiler warnings, and can affect the C++ ABI of GLib-based software.
As a result, we can't just typedef gsize as size_t.

I've expanded the doc-comment to say a bit more about the implications
of the different types here, so that I can point to it from the
doc-comments of other types without repeating myself too much.

Helps: https://gitlab.gnome.org/GNOME/glib/-/issues/1484
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-10-27 19:54:08 +01:00
Marco Trevisan
d0b3021f7f Merge branch 'nirbheek/gmodule-suffix-deprecation' into 'main'
Improve g_module_open(), deprecate G_MODULE_SUFFIX

Closes #520 e #1413

See merge request GNOME/glib!2950
2022-10-27 16:27:42 +00:00
Nirbheek Chauhan
958d0f9b9b tests: Fix resources test on macOS
The content type detection is not very specific on macOS.
2022-10-27 20:26:53 +05:30
Nirbheek Chauhan
9fa3915236 tests: Fix fileutils test on macOS
It can return EROFS instead of EPERM too.
2022-10-27 20:26:53 +05:30
Nirbheek Chauhan
d941558ee9 Improve g_module_open(), deprecate G_MODULE_SUFFIX
G_MODULE_SUFFIX is deprecated now because you will get the wrong
results using it most of the time:

1. The suffix on macOS is usually 'dylib', but it's 'so' when using
   Autotools, so there's no way to get the suffix correct using
   a pre-processor macro.
2. Prefixes also vary in a platform-specific way. You may or may not have
   a 'lib' prefix for the name on Windows and on Cygwin the prefix is
   'cyg'.
3. The library name itself can vary per platform. For instance, you may
   want to load foo-1.dll on Windows and libfoo.1.dylib on macOS. This
   is for libraries, not modules, but that is still a use-case that
   people use the GModule API for.

g_module_build_path() does take care of (2) on Cygwin, but it
fundamentally cannot handle the possibility of multiple options for
the module name, since it does not do any I/O. Hence, it is also
deprecated.

Instead, g_module_open() has been improved so that it takes care of
all this by searching the filesystem for combinations of possible
suffixes and prefixes on each platform. Along the way, the
documentation for it was also improved to make it clearer what it
does.

Closes https://gitlab.gnome.org/GNOME/glib/-/issues/520

Closes https://gitlab.gnome.org/GNOME/glib/-/issues/1413
2022-10-27 20:26:53 +05:30
Simon McVittie
a62dd272d8 tests: Test that we can include all headers with an old MAX_VERSION
In principle we could script this so that each max-version.c is compiled
26 times, once per possible MAX_VERSION, but I haven't implemented
that here: just pinning to the oldest possible version is sufficient to
reproduce #2796.

These aren't included in the installed-tests, since they don't really
do anything at runtime (the important thing is that they compile
without warnings).

Reproduces: #2796
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-10-27 14:50:48 +01:00
Marco Trevisan
aed8e231c0 Merge branch 'variant-byteswap-fuzzing' into 'main'
fuzzing: Add a new fuzz test for g_variant_byteswap()

See merge request GNOME/glib!3025
2022-10-27 12:43:42 +00:00
Simon McVittie
c59d553890 gstdio: Silence "Not available before" warnings for inline functions
Whenever a static inline calls a GLib function that was added since
we started tracking versions, we need to silence the "Not available
before" warnings, otherwise compiling code that includes this header
with GLIB_VERSION_MAX_ALLOWED set to an old version will emit warnings,
even if the static inline is never actually called.

If the static inline is API, we also need to ensure it is annotated with
GLIB_AVAILABLE_STATIC_INLINE_IN_2_76 or similar, so that callers get
the appropriate "Not available before" warnings to alert them to their
unintended use of newer API.

g_clear_fd() calls a function that was introduced in 2.36. It already
issues its own warning if called with GLIB_VERSION_MAX_ALLOWED less
than 2.76.

Similarly, g_autofd uses internal function _g_clear_fd_ignore_error
which calls g_clear_fd(), but it issues its own warning if used with
GLIB_VERSION_MAX_ALLOWED less than 2.76.

Fixes: b3934133 "gstdio: Add g_clear_fd() and g_autofd"
Resolves: #2796
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-10-27 13:14:25 +01:00
Simon McVittie
d0ff4055af gstdio: Warn if g_autofd is used with GLIB_VERSION_MAX_ALLOWED < 2.76
Fixes: b3934133 "gstdio: Add g_clear_fd() and g_autofd"
Helps: #2796
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-10-27 13:13:48 +01:00
Philip Withnall
eda4b198c9 gvariant: Document the return transfer of g_variant_byteswap()
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-10-27 12:14:17 +01:00
Philip Withnall
3079ca90ab fuzzing: Add a new fuzz test for g_variant_byteswap()
The behaviour of `g_variant_byteswap()` is largely dominated by its call
to `g_variant_get_normal_form()`, but it does do an additional call to
`g_variant_serialised_byteswap()` which we should probably be fuzzing.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-10-27 12:13:13 +01:00
Philip Withnall
16169c8773 Merge branch 'python-testing' into 'main'
ci: Move shellcheck/black/flake8 checks to a new CI job which can fail

See merge request GNOME/glib!3023
2022-10-27 09:58:40 +00:00
Philip Withnall
424cf3a966 ci: Move shellcheck/black/flake8 checks to a new CI job which can fail
We were regressing on Python style too often. Since Python code style is
a lot easier to enforce than C code style, split it (and the shellcheck
checks) out from `style-check-diff` into a new CI job which is allowed
to fail the pipeline.

Only trigger it when .sh or .py files have changed, which should reduce
resource consumption.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-10-27 10:09:58 +01:00
Marco Trevisan
83beedddc9 Merge branch 'fix_coding_style_gitlab_ci_check-missing-install.tag.py' into 'main'
Fix coding style issue in .gitlab-ci/check-missing-install-tag.py

See merge request GNOME/glib!3022
2022-10-27 09:06:01 +00:00
Emmanuel Fleury
da178b1938 Fix coding style issue in .gitlab-ci/check-missing-install-tag.py 2022-10-27 09:51:28 +02:00
Philip Withnall
0f471fabfb Merge branch 'kgx' into 'main'
Add kgx (gnome console) to known terminals lists

See merge request GNOME/glib!3021
2022-10-26 23:16:20 +00:00
Maxime Gervais
ae65753b16 Add kgx (gnome console) known terminals lists 2022-10-27 00:21:39 +02:00
Philip Withnall
14fcafe2f7 Merge branch 'wip/smcv/equivalent-types' into 'main'
docs: Soft-deprecate types that are just aliases for a standard C type

See merge request GNOME/glib!3003
2022-10-26 21:59:02 +00:00
Philip Withnall
77180daca5 Merge branch 'wip/smcv/standard-va-copy' into 'main'
Soft-deprecate G_VA_COPY in favour of va_copy

See merge request GNOME/glib!2999
2022-10-26 21:34:57 +00:00
Philip Withnall
2ae9c405df Merge branch 'wip/smcv/autofd' into 'main'
gstdio: Add g_clear_fd() and g_autofd

See merge request GNOME/glib!3007
2022-10-26 21:25:31 +00:00
Simon McVittie
b393413321 gstdio: Add g_clear_fd() and g_autofd
Inspired by libglnx's glnx_close_fd() and glnx_autofd, these let us
have the same patterns as g_clear_object() and g_autoptr(GObject), but
for file descriptors. g_clear_fd() is cross-platform, while g_autofd
is syntactic sugar requiring a supported compiler (gcc or clang).

Now that g_close() checks for EBADF as a programming error, we can
implement the equivalent of glnx_autofd as an inline function without
needing to have errno and EBADF in the header file.

g_clear_fd() is like glnx_close_fd(), but with error checking.
The private _g_clear_fd_ignore_error() function used to implement
g_autofd is a closer equivalent of glnx_close_fd().

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-10-26 19:05:33 +01:00
Simon McVittie
65016fddd9 Replace all uses of G_VA_COPY with Standard C va_copy
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-10-26 18:07:55 +01:00
Simon McVittie
b8f37a543c glib: Always implement G_VA_COPY as va_copy()
C99 guarantees that va_copy() exists, so use it, instead of probing
for __va_copy(), va_copy(), or a reimplementation from first principles.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-10-26 18:07:55 +01:00
Simon McVittie
fe7eb71c43 docs: Soft-deprecate G_VA_COPY in favour of va_copy
We now require C99, which guarantees that va_copy is available.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-10-26 18:07:55 +01:00
Marco Trevisan
b9e68b0bd4 Merge branch 'support-xdg-terminal-exec' into 'main'
Add support for xdg-terminal-exec for handling desktop applications using 'Terminal=true'

See merge request GNOME/glib!2839
2022-10-26 17:03:12 +00:00
Marco Trevisan
0d425bc276 Merge branch 'fix-install-tag-check' into 'main'
ci: Fix check for missing install tag

See merge request GNOME/glib!3019
2022-10-26 16:51:17 +00:00
Simon McVittie
1464d6ab36 glib-init: Add static assertions for int, short, long type aliases
Helps: #1484
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-10-26 17:50:07 +01:00
Simon McVittie
d6ea9292d7 docs: Soft-deprecate types that are just aliases for a standard C type
There is usually no reason to use the GLib-specific type names here,
other than consistency. The GLib-specific one-word type names can
sometimes be a little more convenient when generating a family of
function names from macros.

Because these types are simple aliases for a hard-coded standard C type,
there should be no API or ABI issues caused by changing existing code to
use the standard C names: a `char **` can already be used interchangeably
with `gchar **`, and name-mangling for a C++ method that takes an `int`
parameter is equivalent to a `gint` parameter.

Helps: #1484
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-10-26 17:50:07 +01:00
Max Gautier
dd9bc7cf59 gio: test xdg-terminal-exec usage 2022-10-26 18:41:26 +02:00
Max Gautier
22e1b9bcc0 gio: add xdg-terminal-exec as a known terminal
Allow users to select their terminal of choice by using the
xdg-terminal-exec wrapper.

It is a temporary temporary solution while waiting for the
xdg-default-apps specification
(https://gitlab.freedesktop.org/xdg/xdg-specs/-/issues/54), in
accordance with this comment:
https://gitlab.gnome.org/GNOME/glib/-/issues/338#note_1076172
2022-10-26 18:41:26 +02:00
Max Gautier
b64347d279 gio: add support for terminal with no option
Introduce support for terminals executing commands without an option,
i.e., the command is passed directly as argument to the terminal emulator.
This is needed for xdg-terminal-exec.
2022-10-26 18:41:26 +02:00
Max Gautier
eb2d1d8fc8 gio: Refactor the known terminals search
Get rid of multiple conditionals branch by using a loop and storing the
options needed by particular terminal emulators directly in an array.
Remove intermediate variable term_argv as we don't need it.

Advantages:
- simpler logic, less branching
- the terminal emulator list is more readable, by virtue of being
  condensed in one array. Launch options to execute a terminal program
  are also more explicitly specified
- the logic become independent from the order
- one less allocation
2022-10-26 18:15:26 +02:00
Xavier Claessens
a4eb39dde8 ci: Fix failing tests not failing CI job 2022-10-26 11:55:56 -04:00
Xavier Claessens
9ba01dc7fc ci: Fix check for missing install tag
Better check the installation plan json file instead of parsing logs.
2022-10-26 11:55:56 -04:00
Xavier Claessens
b8a0ffa1b9 meson: Add missing install tags 2022-10-26 11:55:56 -04:00
Marco Trevisan (Treviño)
bd2cb39073 meson: Remove stpcpy() workaround for old meson versions and windows
This is now supported by the meson version we depend on.
2022-10-26 17:39:25 +02:00
Marco Trevisan (Treviño)
98059d088f gmodule/meson: Use stdout to communicate return value pf dlsym test code 2022-10-26 17:39:25 +02:00
Marco Trevisan (Treviño)
4a33e2a176 meson: Undefine STAP_HAS_SEMAPHORES and _STD_HAS_SEMAPHORES as autotools did 2022-10-26 17:39:25 +02:00
Marco Trevisan (Treviño)
e955cd4842 gio: Install empty glib gio modules dir on install
This requires to keep the relative path around not to have to play with
paths too much at python level.
2022-10-26 17:39:23 +02:00
Marco Trevisan
1590e7636c Merge branch 'ebassi/version-header-install' into 'main'
Install gversionmacros.h in the right place

See merge request GNOME/glib!3018
2022-10-26 15:04:01 +00:00