Commit Graph

22 Commits

Author SHA1 Message Date
Sebastian Wick
a973baad08 chase: Add glnx_chaseat which functions similar to openat2
The selling features are:

* Support for RESOLVE_BENEATH, RESOLVE_IN_ROOT and RESOLVE_NO_SYMLINKS
* Fallback from openat2 to open_tree to openat for compatibility
* Triggering of automounts
2026-03-17 18:40:38 +01:00
Simon McVittie
284b75d31b build: Fix function detection when using -Werror=return-type
Recent versions of openSUSE default to using -Werror=return-type for
package builds, which results in all of these function checks
incorrectly detecting the function as not being available.

Co-authored-by: Peng Yi
Resolves: https://gitlab.gnome.org/GNOME/libglnx/-/issues/4
Signed-off-by: Simon McVittie <smcv@debian.org>
2024-04-19 10:29:07 +01:00
Simon McVittie
f2ff19d7c8 build: Really check for close_range() as intended
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-02-09 16:50:04 +00:00
Simon McVittie
6ada39c384 backports: Add a backport of g_closefrom(), g_fdwalk_set_cloexec()
These will be new API in GLib 2.79.2.

The only code change in the implementation, other than the _glnx
wrappers, was to use `close()` instead of `g_close (fd, NULL)` in a
context where it must be async-signal safe.

The test-case needed some more adjustments to be backwards-compatible
with GLib from the distant past.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-02-09 15:29:52 +00:00
Will Thompson
8f2e676d9b Merge branch 'wip/smcv/warnings' into 'master'
build: Explicitly disable warnings for non-ISO C features

See merge request GNOME/libglnx!42
2022-10-10 13:43:00 +00:00
Simon McVittie
2e46d5b145 Merge branch 'wip/smcv/testing-helpers' into 'master'
Backport g_test_skip_printf(), etc.

See merge request GNOME/libglnx!38
2022-10-10 13:36:44 +00:00
Simon McVittie
45108f1852 build: Explicitly disable warnings for non-ISO C features
libglnx is intentionally not portable to non-Unix platforms or to
compilers that do not implement gcc/clang extensions, so it's
counterproductive to warn about these extensions, even if libglnx is used
by a parent project that generally (for the parts that don't use
libglnx) wants to be portable to any ISO C compiler.

Suggested by Will Thompson on !36.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-10-10 14:09:29 +01:00
Simon McVittie
c52b73d4ae Backport most of the test convenience helpers from GLib's GTest
This includes a test (who tests the tests themselves?). Run
as `${build}/tests/testing --tap` with semi-modern GLib, or
`${build}/tests/testing --verbose` with GLib < 2.38, to check that the
output is as reasonable as possible given the limitations of the GLib
version in use.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-08-19 10:59:24 +01:00
Simon McVittie
5a60c0bca5 Move assertion/test utilities to a separate header
A lot of recent convenience APIs can easily be backported, but they'll
clutter glnx-backports.h. In preparation, split these out.

Another reason to separate these is that when we start adding backports
of test utilities that need implementation code in the libglnx static
library, we'll want their implementations to be in a separate
translation unit, so that they don't get linked into production
executables, only into tests.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-08-19 10:56:36 +01:00
Simon McVittie
af02572e6b build: Reduce default warning level from 3 to 2
Warning level 2 is -Wall -Wextra, and warning level 3 adds -Wpedantic
(warnings about use of non-ISO extensions). libglnx is intentionally
using non-ISO features, so -Wpedantic is counterproductive.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-07-27 13:57:19 +01:00
Phaedrus Leeds
c59eb271b5 Merge branch 'wip/smcv/warnings' into 'master'
Fix and enable more compiler warnings

See merge request GNOME/libglnx!35
2022-05-10 18:08:28 +00:00
Simon McVittie
9f033ee2f6 meson: Build with more warnings by default
If we keep this module closer to warnings-clean, then it can be
submoduled into Meson projects that enable warnings by default without
having to override it to a lower warning-level.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-04-24 11:08:15 +01:00
Simon McVittie
eeea247ade meson: Always build with hidden symbol visibility
This copylib isn't intended to be part of anyone's ABI. In Autotools,
this is typically implemented by doing some ad-hoc compiler checks and
adding -fvisibility=hidden to the global CFLAGS of any library that
pulls in libglnx, but in Meson it's a build system feature.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-04-21 19:44:13 +01:00
Simon McVittie
b76cf458ce meson: Automatically link libglnx-dependent objects to gio-unix
If we don't do this, users of libglnx all have to add this dependency
themselves, otherwise they'll get errors like:

    fatal error: gio/gfiledescriptorbased.h: No such file or directory

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-04-21 19:43:25 +01:00
Simon McVittie
68191d8274 Update copyright holder for Endless' contributions
Will Thompson reports that all of Endless' IP was transferred to
Endless OS Foundation LLC.

Signed-off-by: Simon McVittie <smcv@debian.org>
2022-02-19 22:57:52 +00:00
Simon McVittie
81c6adb0f7 Declare copyright and licensing using REUSE
To fill in some gaps, I've had to make some assumptions:

* trivial changes (such as checking for an additional function or
  header file in libglnx.m4) are assumed to not be copyrightable
* Will Thompson and Matthew Leeds are assumed to be contributing on
  behalf of Endless Mobile Inc.
* files with no explicit licensing information are assumed to be
  under the license found in COPYING

Reference: https://reuse.software/
Signed-off-by: Simon McVittie <smcv@debian.org>
2022-02-19 22:57:48 +00:00
Phaedrus Leeds
15d4c3aa94 Merge branch 'not-config-h' into 'master'
Include libglnx-config.h instead of config.h

See merge request GNOME/libglnx!24
2022-02-18 13:21:02 +00:00
Simon McVittie
a4dcfe8d2f build: Use Meson built-in option c_std instead of -std=gnu99
This silences a Meson warning.

Signed-off-by: Simon McVittie <smcv@debian.org>
2021-07-02 14:19:15 +01:00
Simon McVittie
c306703c6f Include libglnx-config.h instead of config.h
This avoids colliding with a config.h generated by a parent Meson
project.

In the Meson build system, we generate libglnx-config.h by doing our
own checks, so we want to avoid it colliding.

In the Autotools build system, we assume that the parent project will
generate its own config.h that contains the results of LIBGLNX_CONFIGURE,
and create a forwarding header libglnx-config.h in the $(top_builddir)
(so that it is next to config.h).

Note that after updating libglnx in an Autotools non-recursive-Make
project (libostree, flatpak, flatpak-builder) it will be necessary to
re-run autogen.sh.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-06-28 15:53:32 +01:00
Simon McVittie
738ee7ace3 Make the Meson build work on older compilers
Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-05-10 16:53:15 +01:00
Simon McVittie
744bd1824f meson: Define HAVE_DECL_FOO to 0 if foo isn't declared
This matches what Autotools would do, and what our header is expecting.
It silences -Wundef.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-05-10 16:52:11 +01:00
Will Thompson
0f53dc35e4 Add meson.build files 2019-03-28 16:09:32 +00:00