Commit Graph

594 Commits

Author SHA1 Message Date
Chun-wei Fan
5642331603 GLib tests: Add test for g_win32_clear_com()
This mimicks the test for g_clear_object() in gobject/tests/reference.c.

We use the system's wincodec library for our sample here.
2024-12-13 10:45:09 +08:00
Philip Withnall
67b5a37f2b
2.83.2
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-12-11 17:19:24 +00:00
Philip Withnall
322d74b141
2.83.1
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-12-11 14:51:36 +00:00
John Ralls
9bbb1acd7d Raise minimum supported macOS version to 10.13 (High Sierra).
Allows removing all macOS version ifdefs.

Closes https://gitlab.gnome.org/GNOME/glib/-/issues/3441
2024-11-20 18:15:34 -08:00
Gleb Popov
02172bda73 Enable GNetworkMonitorNetlink on FreeBSD 2024-10-29 21:18:36 +03:00
Sebastian Dröge
f221864d6e glib: Don't require GLIB_DOMAIN to be a NUL-terminated string
The length might be passed explicitly in the field instead, and the
string might not have a NUL-terminator as happens for example when
passed from the Rust bindings.

This might lead to out of bounds reads.

Thanks to Sebastian Wiesner for noticing this.
2024-10-22 19:08:25 +03:00
Alan Coopersmith
5aabd288ad build: update _XOPEN_SOURCE setting for modern Solaris & illumos
Previously the build was requesting interfaces matching SUSv1/Unix95,
as implemented in Solaris 2.6 and later.  This changes it to try the
most recent version supported, and limits to the versions supported
by OS versions that meson supports.  This includes these _XOPEN_SOURCE
versions:

800 (2024): supported by illumos starting in July 2024
700 (2008): supported by Solaris 11.4 & illumos from 2014-2024
600 (2001): supported by Solaris 10-11.3 & illumos prior to 2014

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2024-10-14 17:41:32 -07:00
Alan Coopersmith
ef7b2c9a34 build: define __EXTENSIONS__ when building on Solaris & illumos
Like _GNU_SOURCE on glibc, this tells the header to define functions
not included in the requested standards versions.  This is needed to
build glib/tests/utils-c-89 with -std=c89 and utils-c-89 with -std=c99
and still be able to call functions like isnan() and realpath().

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2024-10-13 16:45:34 -07:00
Philip Withnall
4416d9dcce Merge branch '3488-introspection-checks' into 'main'
build: Check for gobject-introspection-1.0 as well as g-ir-scanner

Closes #3488

See merge request GNOME/glib!4329
2024-10-07 13:46:04 +00:00
Carlo Bramini
2986cd3793 Meson: fix support for aarch64-w64-mingw32 (Windows on ARM64)
This patch fixes a build error when compiling with GCC cross compiler for Windows on ARM64.
See issue #3490 for details.

Signed-off-by: Carlo Bramini carlo_bramini@users.sourceforge.net
Fixes: #3490
Closes #3490
2024-10-04 11:43:45 +02:00
Philip Withnall
04abc6b6c1
build: Check for gobject-introspection-1.0 as well as g-ir-scanner
Both are needed in practice to build the GIR files.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Fixes: #3488
2024-10-03 13:39:30 +01:00
Philip Withnall
f6d7878a54 Merge branch 'speed-up-query-exists' into 'main'
gio: Add a query_exists vfunc to GFile

See merge request GNOME/glib!4272
2024-10-01 15:45:04 +00:00
Matthias Clasen
65ad41d8a4 gio: Implement query_exists for local files
We can’t quite use `access()` for this, like `g_file_test()` does, as
`g_file_query_info()` considers a broken symlink to exist, so we need to
match that by passing `AT_SYMLINK_NOFOLLOW`.

We also use the `AT_EACCESS` flag, which makes the `faccessat()` call
cheaper on Hurd.

Systems without `faccessat()` will continue to use the
`g_file_query_info()`-based implementation of `g_file_query_exists()`.

(Commit message rewritten by Philip Withnall.)
2024-10-01 16:27:29 +01:00
Benjamin Gilbert
23009aadc6 build: switch back to c_std=gnu99 pending ObjC fix
It's better to warn by default on MSVC (which we were already doing before
we bumped to 1.4.0) than to fail by default on macOS.

Fixes: 51e3e7d9ae ("build: Bump Meson dependency to 1.4.0")
2024-09-25 07:45:06 -07:00
Gleb Popov
dae3b8bd15 Introduce a special mode of operating for the inotify GFileMonitor backend
libinotify-kqueue is a library that implements inotify interface in terms of
kqueue/kevent API available on Mac OS and *BSD systems. The original kqueue
backend seems to be a predecessor version of the code that is currently present
in libinotify-kqueue. Under the hood the library implements a sophisticated
filesystem changes detection algorithm that is derived from the glib backend
code.

Updating the native glib kqueue backend requires substantial work, because code
bases have diverged greatly. Another approach is taken, instead. libinotify-kqueue
can serve as a drop-in replacement for Linux inotify API, thus allowing to
reuse the inotify backend code. The compatibility, however, comes at cost, since
the library has to emulate the inotify descriptor via an unix domain socket.
This means that delivering an event involves copying the data into the kernel
and then pulling it back.

The recent libinotify-kqueue release adds a new mode of operation called "direct".
In this mode the socket pipe is replaced with another kqueue that is used to
deliver events via a kevent(EVFILT_USER) call.
Employing the direct mode requires minor changes to the client code compared
to using plain inotify API, but in return it allows for reusing libinotify's
algorithms without a performance penalty. Luckily, all required changes are
consolidated in one file called inotify-kernel.c

This puts us in the best of possible worlds. On one hand we share a lot of code
with glib inotify backend, which is far more thoroughly tested and widely used.
On the other we support a range of non-Linux systems and consolidate the business
logic in one library. I plan to do the same trick for QFileSystemWatcher which
will give us the same behaviour between Gtk and Qt applications.

The glib test suite passes for both old kqueue backend and new libinotify-kqueue
one. However, the AppStream FileMonitor tests are failing with the old backend,
but pass with the new one, so this is still an observable improvement.

Relevant libinotify-kqueue PR: https://github.com/libinotify-kqueue/libinotify-kqueue/pull/19
2024-09-19 09:54:56 +03:00
Gleb Popov
c7e2ae30f0 Add Meson option that allows selecting GFileMonitor's backend implementation
The option defaults to 'auto' which keeps the current selection behavior, but
also allows user to override the choice.

Also make the chosen backend is reported to the code via CPP defines.
2024-09-18 12:01:27 +03:00
Philip Withnall
7a7d8d548a Merge branch 'wfloat-conversion' into 'main'
build: Enable -Wfloat-conversion and fix warnings

See merge request GNOME/glib!4126
2024-09-17 17:57:11 +00:00
Philip Withnall
0134888d50
build: Bump gvdb subproject dependency and disable tests
This brings in https://gitlab.gnome.org/GNOME/gvdb/-/merge_requests/23,
which is needed for the following few commits.

Unfortunately, one of the other commits it brings in introduces a
sort-of-dependency-loop between GIO and GVDB. To avoid that, we have
to disable the GVDB tests. See
https://gitlab.gnome.org/GNOME/gvdb/-/merge_requests/25 for details.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-09-12 21:15:42 +01:00
Benjamin Gilbert
51e3e7d9ae build: Bump Meson dependency to 1.4.0
Meson 1.5.1 is available in the fd.o SDK and in Debian testing, so the
glib Meson policy says we can update.  Update the minimum only as far as
1.4.0 because we don't yet have a need for 1.5.0.

This allows us to:

- Use file.full_path() to avoid deprecation warnings on str.format(file).
- Set c_std=gnu99,c99 to avoid deprecation warnings with gnu99 on MSVC.

Update all the CI builds to use the latest 1.4.x patch release, 1.4.2.

The FreeBSD runner cannot be updated via `gitlab-ci.yml`, so will be
broken for now.

Similarly, the macOS build will not work unless `-Dc_std=gnu99` is
specified at configure time, due to
https://github.com/mesonbuild/meson/issues/13639.
2024-09-12 19:15:05 +01:00
Evan Welsh
93271385f9 ci: Set gobject-introspection version and build gobject-introspection in tests
The minimum version is now 1.80.0
2024-08-26 12:07:25 +01:00
Philip Withnall
ea44c0e4e0
build: Post-release version bump
This opens up the development cycle for 2.84.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-08-26 10:42:32 +01:00
Philip Withnall
fd8ede0b66
build: Check for epoll_create1 rather than epoll_create in meson.build
Because `epoll_create1()` is what the code in `giounix-private.c`
actually uses.

Spotted by Xuntao Chi.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Fixes: #3450
2024-08-25 15:28:21 +01:00
Emmanuele Bassi
77da866407 Post-release version bump to 2.81.2 2024-08-02 12:52:54 +01:00
Emmanuele Bassi
95eafc0738 2.81.1
Signed-off-by: Emmanuele Bassi <ebassi@gnome.org>
2024-08-02 12:41:55 +01:00
Ernesto de Gracia Herranz
38faeca62e replace package.version.Version by internal code
This drops the dependency on the Python `packaging` module.

Signed-off-by: Ernesto de Gracia Herranz <ernestodgh@jfrog.com>
2024-07-04 11:04:38 +00:00
Philip Withnall
692a50b78e
build: Enable -Wfloat-conversion by default
GLib now compiles without emitting any float conversion warnings, so
let’s keep it that way.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3405
2024-06-28 14:44:01 +01:00
Philip Withnall
5fdd6507b4 Merge branch 'ebassi/c11-toolchain-req-docs' into 'main'
docs: Update toolchain requirement to C11

See merge request GNOME/glib!4082
2024-06-14 12:35:06 +00:00
Marco Trevisan (Treviño)
5b0ae99e9a build: Add -Wno-typedef-redefinition to CFLAGS
Without the -Wno-typedef-redefinition option, clang complains if a typedef
gets redefined in gnu99 mode (since this is officially a C11 feature). This
also happened with old versions of GCC.

So, don't break the build on such warn, since we want to support
toolchains that supports C11 anyways.
2024-06-14 12:35:21 +01:00
Philip Withnall
74c6c4c221 Merge branch 'fix-introspection-windows' into 'main'
Introspection: Fix running g-ir-scanner 1.80.x+ on Windows

See merge request GNOME/glib!3988
2024-06-13 20:12:33 +00:00
Emmanuele Bassi
10fd218666 Build HTML versions of the man pages
And install them in the same directory as the API reference, so it's
possible to link them.

Fixes: #2896
2024-06-02 15:15:31 +00:00
Philip Withnall
60845fce0a Merge branch 'dont-rm-rf-root' into 'main'
gtestutils: Don't follow symlinks when deleting tests' tempdir

Closes #3290

See merge request GNOME/glib!4018
2024-05-23 23:08:39 +00:00
Will Thompson
5f6dda5bdc gtestutils: Don't follow symlinks when deleting tests' tempdir
Previously, when cleaning up the temporary directory tree created by
passing G_TEST_OPTION_ISOLATE_DIRS, any symbolic links in that tree
would be followed recursively. If the test case has created a symbolic
link in its temporary directory to a directory outside that tree, this
could lead to unexpected data loss; in particular, if the test case
author has (unwisely) created a symbolic link to /, they could lose all
data on the system.

On systems that have the ftw.h header, replace the current rm_rf()
implementation with one that uses nftw() to perform a depth-first
traversal (FTW_DEPTH) without following symbolic links (FTW_PHYS), and
without crossing mount points (FTW_MOUNT) in case a test has mounted
some other filesystem in the temporary directory.

The callback logs any error to the standard error stream, but returns 0
rather than -1 to allow nftw() to keep walking the tree rather than
terminating immediately. Suppose we are trying to clean up the following
tree:

    tmpdir/
      a/
        f/ (directory not readable for some reason)
        g/
          p
      b/
        c
        d

Since tmpdir/a/f is not readable, we can expect to fail to delete
tmpdir/a/f, tmpdir/a and tmpdir; but it is preferable to (attempt) to
delete the rest of the tree rather than failing outright. The cost is
that three errors will be logged (for tmpdir/a/f, tmpdir/a and tmpdir).

nftw() is part of POSIX.1-2001, SUSv1, and glibc ≥ 2.1, so should be
available on effectively every platform except Windows. (And Windows
does not enable symbolic links by default so the developer error is less
likely to occur there.)

The macOS ftw(3) manpage says:

> These functions are provided for compatibility with legacy code.  New
> code should use the fts(3) functions.

fts(3) does not seem to be part of any standard, but it does seem to be
equally widely supported. The Linux manpages do not indicate that
nftw() is deprecated.

Fixes: https://gitlab.gnome.org/GNOME/glib/-/issues/3290
2024-05-22 22:43:42 +01:00
Emmanuele Bassi
4fcdbd6f84 build: Use C89 for the standard version check
The '90' version is for ISO C90, but Meson does not understand it. As
far as GCC and Clang are concerned, `-std=c89` is exactly the same as
`-std=c90`. As of VS 2017, MSVC supports `/std:c11` as the minimum
version of the C standard, with C89 (plus Microsoft extensions) being
the default.

See:

- GCC: https://gcc.gnu.org/onlinedocs/gcc-14.1.0/gcc/C-Dialect-Options.html
- MSVC: https://learn.microsoft.com/en-us/cpp/build/reference/std-specify-language-standard-version?view=msvc-170#c-standards-support-1
2024-05-22 17:04:51 +01:00
Michael Catanzaro
153cda6669 Convert systemtap from bool to feature option type
Now systemtap can be enabled by default in distros that use
-Dauto_features=enabled or for developers who already have systemtap
installed, while it's still disabled for developers who do not have
systemtap installed. See #3354
2024-05-17 15:22:41 -05:00
Michael Catanzaro
ed020a688a Convert dtrace from bool to feature option type
Now dtrace can be enabled by default in distros that use
-Dauto_features=enabled or for developers who already have dtrace
installed, while it's still disabled for developers who do not have
dtrace installed. See #3354
2024-05-17 15:22:41 -05:00
Chun-wei Fan
ef73ce4f7f Introspection: Fix running g-ir-scanner 1.80.x+ on Windows
Since we are now building introspection files for GLib while building
GLib, so we want to make sure that we indeed load the freshly-built
DLLs when running g-ir-scanner, so we add the various needed subdirs
(and if needed, subprojects), to set the GI_EXTRA_BASE_DLL_DIRS
envvar so that g-ir-scanner will look for the newly-built GLib DLLs.

Ideally, upstream g-ir-scanner will need to be updated accordingly to do
something similar to what we are doing here, but this is needed until
the time that we require a g-ir-scanner that contains the update.

This will also fix the g-ir-scanner erroring out when there is no
pre-existing GLib on the system, as the needed DLLs are now found.

Related issue: https://gitlab.gnome.org/GNOME/gobject-introspection/-/issues/499
Related MR in G-I:
https://gitlab.gnome.org/GNOME/gobject-introspection/-/merge_requests/458
2024-05-17 18:37:32 +08:00
Marco Trevisan (Treviño)
0eb6c85606 build: Define glib_sanitizers variable to easily get the sanitizers in use
It's an array containing the list of sanitizers in use, normally it
contains a value, but in some cases may have more than one (e.g.
'address' and 'undefined').

And so use it to avoid repeated checks
2024-05-10 02:15:52 +02:00
Fabrice Fontaine
4e6dc4dee0 link with -latomic when needed
Some architecture such as sparc and some flavors of arm needs -latomic
to avoid the following build failure:

gthread-posix.c:(.text+0xda8): undefined reference to `__atomic_compare_exchange_4'

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2024-05-02 17:54:52 +02:00
Philip Withnall
b2f27beb34
build: Enable -Wnull-dereference warning
This enables `NULL` pointer dereference checking in the compiler. This
isn’t as good as static analysis, but it should hopefully catch some
simple errors without too high a false positive rate.

If the false positive rate is too high to be useful, we can always
disable it again.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #1767
2024-04-12 18:44:56 +01:00
L. E. Segovia
ffa639f0b7 glib/gthread-posix: Fix name of the futex_time64(2) test in the Meson log 2024-04-02 00:00:21 -03:00
Calvin Walton
013980d839 Use the python found by meson as the interpreter for installed scripts
The python interpreter found by `/usr/bin/env python3` is not
necessarily the same installation as the one that's found by meson's
`pymod.find_installation('python')`. This means that even though meson
is checking that the python installation it found includes the
'packaging' module, the scripts might not have access to that module
when run.

For distribution packaging, it's usually desirable to have python script
interpreters be fully specified paths, rather than use `/usr/bin/env`,
to ensure the scripts run using the expected python installation (i.e.
the one where the python 'packaging' dependency is installed).

The easiest way to fix this is to set the script interpreter to the
`full_path()` of the python interpreter found by meson. The specific
python interpreter that will be used can be selected through the use of
a meson machine file by overriding the "python" program. Many
distributions already have this set up using meson packaging helpers.
2024-03-25 15:17:59 -04:00
Philip Withnall
1c5f5a6914 Merge branch 'wip/chergert/gpoll-for-gmain' into 'main'
Use ppoll() when possible for more precise timeouts

See merge request GNOME/glib!3958
2024-03-22 00:17:21 +00:00
Christian Hergert
368cb7eb7b glib/gmain: use ppoll() when possible
If our GPollFunc is set to g_poll() then we can optionally use a poll()
alternative with higher precision. ppoll() provides poll() equivalence
but with timeouts in nanoseconds.

With more precise polling timouts, frame clocks and other timing sensitive
APIs are not restricted to a minimum of 1 millisecond timeout.
2024-03-21 23:46:20 +00:00
Philip Withnall
0cb5a86745 build: Post-release version bump
This opens up the development cycle for 2.82.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-03-20 11:54:39 +00:00
Philip Withnall
763cc3b238
2.80.0
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-03-07 21:35:05 +00:00
Philip Withnall
0d31fc6df3
2.79.3
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-02-27 10:11:38 +00:00
Kleis Auke Wolthuizen
72d76922dc girepository: Fix static build under Windows
Properly define `GI_STATIC_COMPILATION` when static build is enabled.
Use `library()` instead of `shared_library()` to allow selecting static builds.
2024-02-21 12:38:40 +01:00
Philip Withnall
342fa9c161
2.79.2
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-02-12 23:36:25 +00:00
Philip Withnall
a7a6b93cf6 Merge branch 'th/meson-werror-fixes-2' into 'main'
[th/meson-werror-fixes-2] more workarounds for compiler warnings in meson compiler checks

See merge request GNOME/glib!3904
2024-02-08 10:28:01 +00:00
Philip Withnall
01cf3a03c2 Merge branch 'wip/smcv/lint' into 'main'
Incorporate some lint checks into `meson test`

See merge request GNOME/glib!3898
2024-02-08 01:03:01 +00:00