Commit Graph

30589 Commits

Author SHA1 Message Date
Marco Trevisan
044acfcb77 Merge branch 'wip/chergert/fix-mapped-file-get-contents' into 'main'
glib/mappedfile: g_mapped_file_get_contents() does not transfer

See merge request GNOME/glib!4180
2024-08-09 15:14:03 +00:00
Emmanuele Bassi
c865680f96 Merge branch 'fix-up-gapplication-docs-a-little' into 'main'
docs: Linkify a function

See merge request GNOME/glib!4181
2024-08-05 12:55:32 +00:00
Matthias Clasen
653cdb73d7 docs: Linkify a function
I answered a question on irc about withdrawing notifications, and
when I handed out a link to the GApplication docs, I noticed we
don't have this function name linkified. Fix that.
2024-08-05 08:23:45 -04:00
Christian Hergert
fab6595562 glib/mappedfile: g_mapped_file_get_contents() does not transfer
This fixes the annoations for g_mapped_file_get_contents() which looks
like it might transfer ownership (due to being a char*) but does not as
we're pointing into the mmap() region.
2024-08-02 14:20:36 -07:00
Marco Trevisan
ce5e11aef4 Merge branch 'ebassi/release-2-81-1' into 'main'
2.81.1

See merge request GNOME/glib!4179
2024-08-02 12:57:08 +00: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
Michael Catanzaro
474dbd91f7 Merge branch 'fix-macos-build' into 'main'
meson: Fix project not compiling in macOS

Closes #3419

See merge request GNOME/glib!4175
2024-07-28 16:27:57 +00:00
Roshan-R
c534037e12 meson: Fix project not compiling in macOS
Fixes: #3419
2024-07-28 19:50:30 +05:30
Michael Catanzaro
1e6c6ebaa5 Merge branch 'kqueue-gobject-dep' into 'main'
meson: Fix another kqueue build race on macOS

See merge request GNOME/glib!4174
2024-07-27 19:33:15 +00:00
Nirbheek Chauhan
a4483644e8 meson: Fix another kqueue build race on macOS
`gobject-visibility.h` is also needed at build time. To reproduce the
error, just run `ninja gio/kqueue/libkqueue.a`
2024-07-27 08:03:42 +05:30
Philip Withnall
44a145f2e3 Merge branch 'wip/pwithnall/3399-glib-gir-platform-differences-appinfo-content-types' into 'main'
gappinfo and gcontenttype: Make introspection annotations available on all platforms

See merge request GNOME/glib!4167
2024-07-26 15:51:28 +00:00
Simon McVittie
63690399f2 Merge branch 'wip/smcv/msys2-mingw32-allow-failure' into 'main'
CI: Mark msys2-mingw32 as allowing failures

See merge request GNOME/glib!4173
2024-07-26 15:50:54 +00:00
Simon McVittie
4b1ee1f738 Merge branch 'wip/smcv/bug3418-newlocale-errno' into 'main'
strfuncs: Don't let get_C_locale() clobber errno

Closes #3418

See merge request GNOME/glib!4170
2024-07-26 15:41:26 +00:00
Simon McVittie
16819a4024 CI: Mark msys2-mingw32 as allowing failures
Workaround for GNOME/glib#3420

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-07-26 16:31:36 +01:00
Simon McVittie
e807966b84 strfuncs: Don't let get_C_locale() clobber errno
Some callers of `g_ascii_strtoull()` and similar functions assume that
they can use this pattern, similar to what they might do for
Standard C `strtoull()`:

    errno = 0;
    result = g_ascii_strtoull (nptr, endptr, base);
    saved_errno = errno;

    if (saved_errno != 0)
      g_printerr ("error parsing %s\n", nptr);

This is based on the fact that it is non-trivial to tell whether
`strtoull()` and related functions succeeded (in which case the value
of `errno` is unspecified) or failed (in which case `errno` is valid).
For example, POSIX `strtoul(3)` suggests this pattern:

> Since 0, `ULONG_MAX`, and `ULLONG_MAX` are returned on error and are
> also valid returns on success, an application wishing to check for
> error situations should set `errno` to 0, then call `strtoul()` or
> `strtoull()`, then check `errno`.

However, `g_ascii_strtoull()` does not *only* call a function resembling
`strtoull()` (`strtoull_l()` or its reimplementation
`g_parse_long_long()`): it also calls `get_C_locale()`, which wraps
`newlocale()`. Even if `newlocale()` succeeds (which in practice we
expect and assume that it will), it is valid for it to clobber `errno`.
For example, it might attempt to open a file that only conditionally
exists, which would leave `errno` set to `ENOENT`.

This is difficult to reproduce in practice: I encountered what I
believe to be this bug when compiling GLib-based software for i386 in a
Debian 12 derivative via an Open Build Service instance, but I could
not reproduce the bug in a similar chroot environment locally, and I
also could not reproduce the bug when compiling for x86_64 or for a
Debian 10, 11 or 13 derivative on the same Open Build Service instance.
It also cannot be reproduced via the GTest framework, because
`g_test_init()` indirectly calls `g_ascii_strtoull()`, resulting in
the call to `newlocale()` already having happened by the time we enter
test code.

Resolves: https://gitlab.gnome.org/GNOME/glib/-/issues/3418
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-07-26 13:08:27 +01:00
Emmanuele Bassi
3aee3c4e46 Merge branch 'wip/pwithnall/3415-module-tests' into 'main'
tests: Run GModule tests in subprocesses

Closes #3415

See merge request GNOME/glib!4169
2024-07-24 19:52:57 +00:00
Emmanuele Bassi
055eef3994 Merge branch 'wip/pwithnall/3399-glib-gir-platform-differences-gthread' into 'main'
gthread: Make introspection comments platform-independent

Closes #3399

See merge request GNOME/glib!4168
2024-07-24 19:20:56 +00:00
Philip Withnall
460d284fce
gcontenttype: Add platform-independent top level API file
This file doesn’t contain any real implementation, it just call the
`impl` functions from the platform-specific files
`gcontenttype-{fdo,osx,win32}.[cm]`.

It serves as a location for the doc comments, introspection annotations
and API preconditions, and will be built on every platform. In
particular, this means that we get consistent GIR output for the
`g_content_type_*()` APIs regardless of whether GLib was built on Linux or
Windows or macOS.

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

Helps: #3399
2024-07-24 17:46:31 +02:00
Philip Withnall
7bec6327a2
gio: Rename gcontenttype.c to gcontenttype-fdo.c
This reflects its status as actually platform-dependent: it’s only built
on systems using the freedesktop.org content type system.

It makes the file naming match up with other platform-specific
implementations, such as `gcontenttype-win32.c` and
`gcontenttype-osx.m`.

A subsequent commit will introduce a platform-independent high level API
wrapper so that the introspection annotations from this file can be
reused between platforms.

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

Helps: #3399
2024-07-24 17:46:25 +02:00
Philip Withnall
bf630dd4fd
gio: Rename gosxcontenttype.m to gcontenttype-osx.m
To make it consistent with the other platform-specific content type
implementations.

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

Helps: #3399
2024-07-24 17:46:19 +02:00
Philip Withnall
21fdb3be24
gappinfo: Move all platform-independent API docs to gappinfo.c
Previously, some of the doc comments for platform-independent APIs were
in `gdesktopappinfo.c`, which is only built on Unix systems. This meant
the introspection annotations for those APIs were not used on non-Unix
systems, which caused platform differences in `Gio-2.0.gir`.

So, move those doc comments to `gappinfo.c` and put them next to some
new platform-independent wrapper functions which provide a consistent
entry point and location for the API preconditions.

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

Helps: #3399
2024-07-24 17:45:22 +02:00
Philip Withnall
84fe784b51
tests: Run GModule tests in subprocesses
While we try to unload the test modules that we load, at the end of each
test, it’s not always possible: musl, for example, explicitly doesn’t
support unloading modules (see
https://wiki.musl-libc.org/functional-differences-from-glibc.html#Unloading_libraries).

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

Fixes: #3415
2024-07-24 17:07:23 +02:00
Philip Withnall
bc59e28bf6
gthread: Make introspection comments platform-independent
Move various doc/introspection comments from `gthread-posix.c` (which is
platform-specific) to `gthread.c` (which is not). Having the
introspection annotations and doc comments in a platform-independent
file means that they are seen by the build process on all platforms, and
we don’t end up with unintrospectable APIs on some platforms, or
platform-specific annotation differences.

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

Helps: #3399
2024-07-24 16:47:47 +02:00
Philip Withnall
d1945c7abb
gdesktopappinfo: Add additional links to the Desktop Entry Spec
Might as well make it easy for people to look up what we’re talking
about.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-07-24 14:37:18 +02:00
Philip Withnall
c474d4065d
gdesktopappinfo: Port doc comments to gi-docgen syntax
Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3250
2024-07-24 14:23:18 +02:00
Philip Withnall
286c793e54 Merge branch 'gobject-naming-docs' into 'main'
docs: Clarify conventions about type naming and name mangling in GObject

See merge request GNOME/glib!4165
2024-07-24 10:18:17 +00:00
Philip Withnall
435aeddbc7 Merge branch '3399-glib-gir-platform-differences' into 'main'
gspawn: Move docs/annotations to be platform independent

See merge request GNOME/glib!4158
2024-07-24 09:18:58 +00:00
Simon McVittie
cc6f09f3f6 docs: Clarify an example in GObject concepts.md
Continue the existing example to make things more joined up and concrete.
2024-07-24 09:14:20 +00:00
Marco Trevisan
7855fc9fb6 Merge branch 'atomic-gcancellable' into 'main'
GCancellable: Use per-instance mutex logic instead of global critical sections

Closes #2309, #2313 e #774

See merge request GNOME/glib!2765
2024-07-24 07:29:19 +00:00
Marco Trevisan (Treviño)
54d9c26b34 gcancellable: Reference the object before locking when doing signal emission
On g_cancellable_cancel() we were increasing the GCancellable ref count
before emitting the ::cancelled signal, this is a safe thing to do but
it was happening while the cancellable was locked, and this may have
potentially waken up some toggle notifications.

To prevent this, reference the GCancellable just before locking.
2024-07-24 00:21:35 +02:00
Marco Trevisan (Treviño)
3a07b2abd4 GCancellable: Use per-instance mutex logic instead of global critical sections
GCancellable is meant to be used in multi-thread operations but all the
cancellable instances were sharing a single mutex to synchronize them
which can be less optimal when many instances are in place.
Especially when we're doing a lock/unlock dances that may leave another
thread to take the control of a critical section in an unexpected way.

This in fact was leading to some races in GCancellableSources causing
leaks because we were assuming that the "cancelled" callback was always
called before our dispose implementation.

As per this, use per-instance mutexes.

The lock is also now used only to protect the calls that may interact
with cancelled state or that depends on that, as per this we can just
reduce it to the cancel and reset case, other than to the connect one to
prevent the race that we could have when connecting to a cancellable
that is reset from another thread.

We don't really need to release the locks during callbacks now as they
are per instance, and there's really no function that we allowed to call
during a ::cancelled signal callback that may require an unlocked state.
This could been done in case with a recursive lock, that is easy enough
to implement but not really needed for this case.

Fixes: #2309, #2313
2024-07-24 00:21:35 +02:00
Marco Trevisan (Treviño)
0a8cb10f22 gio/tests: Ensure that a GCancellableSource can be used muliple times
Closes: #774
2024-07-24 00:21:35 +02:00
Philip Withnall
732b0f1204 Merge branch 'wip/g-static-assert-gi-scanner' into 'main'
gmacros: Define G_STATIC_ASSERT for GI Scanner

See merge request GNOME/glib!4166
2024-07-23 13:39:00 +00:00
Philip Withnall
35d76da8c8
docs: Clarify conventions about type naming and name mangling in GObject
These rules are not new, they’ve been around for a long time and are
needed to allow introspection machinery to be able to work reliably and
deterministically.

Unfortunately, they have not been documented canonically in one place
before.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-07-23 14:22:00 +02:00
Sebastian Wick
363f5ebafc gmacros: Define G_STATIC_ASSERT for GI Scanner
Using G_STATIC_ASSERT in headers which are introspected currently
requires guarding them behind `#ifndef __GI_SCANNER__` which is really
annoying. We can just define the macros to be noops in a way that the
scanner doesn't trip over them.

Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
2024-07-23 12:25:35 +02:00
Sebastian Wick
88da3a718d gmacros: Define G_PASTE/G_PASTE_ARGS for GI Scanner
They are guarded for the GI Scanner right now even though they should be
fine to expose and they are used in macros that are not guarded for the
GI Scanner.

Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
2024-07-23 12:19:32 +02:00
Philip Withnall
a8b1e818f3
docs: Improve typesetting of GObject naming conventions slightly
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-07-22 18:56:04 +02:00
Michael Catanzaro
d5f0f2e23e Merge branch 'g-gnuc-unused-docs' into 'main'
docs: Clarify that G_GNUC_UNUSED can’t be used on definitions

See merge request GNOME/glib!4164
2024-07-21 01:34:17 +00:00
Philip Withnall
0b8f69b28a
docs: Clarify that G_GNUC_UNUSED can’t be used on definitions
Only on declarations.

This has now bitten me multiple times.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-07-20 19:11:13 +02:00
Philip Withnall
d5c088e730 Merge branch 'wip/oholy/x-gvfs-trash' into 'main'
gfile: Add support for x-gvfs-trash mount option

See merge request GNOME/glib!4155
2024-07-20 10:00:02 +00:00
Philip Withnall
107b47226c Merge branch 'introspection-correct-gio-windows-pkg' into 'main'
introspection: Correct GIO-Windows pkg-config name

See merge request GNOME/glib!4159
2024-07-18 08:30:41 +00:00
Chun-wei Fan
297d808c6b introspection: Correct GIO-Windows pkg-config name
It's gio-windows-2.0.pc, not gio-win32-2.0.pc.

Otherwise, we get warnings/errors where the package cannot be located
but since we are linking to the same GIO library file, this did not
manifest itself.
2024-07-17 16:28:34 +08:00
Ondrej Holy
d9fec76b59 gfile: Add support for x-gvfs-trash mount option
Currently, the trash functionality is disabled for system internal mounts.
That might be a problem in some cases. The `x-gvfs-notrash` mount option
allows disabling the trash functionality for certain mounts. Let's add
support for the `x-gvfs-trash` mount option to allow the opposite.

See: https://issues.redhat.com/browse/RHEL-46828
2024-07-16 07:52:00 +02:00
Philip Withnall
d3cb9d638d Merge branch 'traverse-diagrams' into 'main'
docs(GNode): Traversal diagrams, color & dark-mode

See merge request GNOME/glib!4157
2024-07-15 15:58:45 +00:00
Philip Withnall
a931a75c4f docs(GNode): Traversal diagrams, color & dark-mode
* Create a dark-mode variant of each traversal diagram, with the
  traversal path colorized `--primary` blue, instead of the original
  black.
* Apply the same colorizations to the light-mode diagrams, but
  using the light-theme `--primary` blue.
* Add SPDX license/copyright comments to all eight SVG files.
* Add new files to documentation configs in `glib.toml.in`.
* Update documentation comment in `gnode.c` to embed both color
  variants via picture tags, instead of markdown image embeds.
* Add alt text to all four images.
* Add additional blank lines to documentation comment, so that
  a. First item in bulleted list does not get folded into
     preceding intro paragraph
  b. Intro paragraph and diagrams are not part of first paragraph
     in documentation. (This also gets them out of the top-level
     table-of-contents/index list, where they previously appeared
     in full.)
* (Accidental change I didn't realize I was making): Convert line
  endings in breadth-first diagram from CRLF to LF.
2024-07-15 15:58:45 +00:00
Philip Withnall
6161bbf3e4
gspawn: Add platform-independent top level API file
This file doesn’t contain any real implementation, it just call the
`impl` functions from the platform-specific files
`gspawn-{posix,win32}.c`.

It serves as a location for the doc comments, introspection annotations
and API preconditions, and will be built on every platform. In
particular, this means that we get consistent GIR output for the
`g_spawn_*()` APIs regardless of whether GLib was built on Linux or
Windows.

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

Helps: #3399
2024-07-15 16:40:55 +01:00
Philip Withnall
b6c12c61f3
gspawn: Rename gspawn.c to gspawn-posix.c
This is the first step towards separating the API documentation and
introspection annotations from the platform-specific implementation, so
we can guarantee that the APIs make it into `GLib-2.0.gir` regardless of
which platform the GIR is built on.

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

Helps: #3399
2024-07-15 16:04:51 +01:00
Philip Withnall
79c57b5b80 Merge branch 'gbsneto/doc-fixes-pt1' into 'main'
Port some GIO files to gi-docgen

See merge request GNOME/glib!4113
2024-07-11 21:01:39 +00:00
Georges Basile Stavracas Neto
a84c67da71 gio/appinfo: Directly link GdkAppLaunchContext
We can only use the [class@Foo.Bar] syntax for identifiers under
namespaces included by the current namespace. Naturally, we cannot
include the GDK namespace.

Use a direct link for this instead.
2024-07-11 16:23:06 +01:00