gtk/testsuite
Simon McVittie 214f5a6f98 gskpathop: Introduce a type to represent an aligned graphene_point_t
When we allocate a graphene_point_t on the stack, there's no guarantee
that it will be aligned at an 8-byte boundary, which is an assumption
made by gsk_pathop_encode() (which wants to use the lowest 3 bits to
encode the operation). In the places where it matters, force the
points on the stack and embedded in structs to be nicely aligned.

By using a distinct type for this (a union with a suitable size and
alignment), we ensure that the compiler will warn or error whenever we
can't prove that a particular point is, in fact, suitably aligned.
We can go from a `GskAlignedPoint *` to a `graphene_point_t *`
(which is always valid, because the `GskAlignedPoint` is aligned)
via &aligned_points[0].pt, but we cannot go back the other way
(which is not always valid, because the `graphene_point_t` is not
necessarily aligned nicely) without a cast.

In practice, it seems that a graphene_point_t on x86_64 *is* usually
placed at an 8-byte boundary, but this is not the case on 32-bit
architectures or on s390x.

In many cases we can avoid needing an explicit reference to the more
complicated type by making use of a transparent union. There's already
at least one transparent union in GSK's public API, so it's presumably
portable enough to match GTK's requirements.

Increasing the alignment of GskAlignedPoint also requires adjusting how
a GskStandardContour is allocated and initialized. This data structure
allocates extra memory to hold an array of GskAlignedPoint outside the
bounds of the struct itself, and that array now needs to be aligned
suitably. Previously the array started with at next byte after the
flexible array of gskpathop, but the alignment of a gskpathop is only
4 bytes on 32-bit architectures, so depending on the number of gskpathop
in the trailing flexible array, that pointer might be an unsuitable
location to allocate a GskAlignedPoint.

Resolves: https://gitlab.gnome.org/GNOME/gtk/-/issues/6395
Signed-off-by: Simon McVittie <smcv@debian.org>
2024-07-28 17:31:41 +01:00
..
a11y tests: Fix signature of GtkTestATContext::update-selection-bound handlers 2024-07-27 00:59:03 +01:00
css css: Fix relative font sizes 2024-07-26 08:45:58 -04:00
gdk Merge branch 'wip/smcv/ubsan-half-float' into 'main' 2024-07-28 02:59:59 +00:00
gsk gskpathop: Introduce a type to represent an aligned graphene_point_t 2024-07-28 17:31:41 +01:00
gtk Tests: add GtkPicture builder test 2024-07-26 18:30:58 -04:00
headless ci: Build testsuite for macOS 2024-02-17 14:31:51 +01:00
introspection ci: Build testsuite for macOS 2024-02-17 14:31:51 +01:00
reftests reftests: Avoid some deprecated css 2024-06-27 21:03:14 -04:00
tools tests: Update for the new setting 2024-04-19 12:56:34 -04:00
meson.build testsuite: Use catch as testwrapper 2024-07-01 22:29:36 -04:00
testutils.c testsuite: fix memleak 2023-06-05 05:33:07 +02:00
testutils.h testsuite: Make function arguments const 2021-11-30 14:12:10 +01:00