From f8c7069a46af185e0bfaa43d63d450c9a44787ba Mon Sep 17 00:00:00 2001 From: Alex Richardson Date: Wed, 16 Jun 2021 14:35:11 +0100 Subject: Fix XrmResource layout if pointers are bigger than long On CHERI-enabled architectures (e.g. Arm's Morello), pointers are twice the size of addresses (i.e. 128 bits for Morello, 64 bits for 32-bit RISC-V). However, XtArgVal is currently defined as long, so it cannot be used to store pointers on these architectures. Also add a _Static_assert() when compiling with C11 support to check that the offset of the last member matches that of XtResource. Signed-off-by: Alex Richardson --- include/X11/IntrinsicP.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/X11/IntrinsicP.h b/include/X11/IntrinsicP.h index 9f1ae40..21c5aca 100644 --- a/include/X11/IntrinsicP.h +++ b/include/X11/IntrinsicP.h @@ -56,14 +56,19 @@ SOFTWARE. * are not the same size on all systems. */ typedef struct { - long xrm_name; /* Resource name quark */ - long xrm_class; /* Resource class quark */ - long xrm_type; /* Resource representation type quark */ + XtIntPtr xrm_name; /* Resource name quark */ + XtIntPtr xrm_class; /* Resource class quark */ + XtIntPtr xrm_type; /* Resource representation type quark */ Cardinal xrm_size; /* Size in bytes of representation */ int xrm_offset; /* -offset-1 */ - long xrm_default_type; /* Default representation type quark */ + XtIntPtr xrm_default_type; /* Default representation type quark */ XtPointer xrm_default_addr; /* Default resource address */ } XrmResource, *XrmResourceList; +#if __STDC_VERSION__ >= 201112L +_Static_assert(XtOffsetOf(XrmResource, xrm_default_addr) == + XtOffsetOf(XtResource, default_addr), + "Field offset mismatch"); +#endif typedef unsigned long XtVersionType; -- cgit v1.2.1