From 6d3ede2e9fdafe01f11ab609276106fe24c92205 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 2 Jul 2020 11:32:09 +0100 Subject: [PATCH] libsysprof-capture: Avoid using GLIB_SIZEOF_VOID_P Use `UINTPTR_MAX` to calculate the size of a pointer instead. This assumes that all pointers are the same width. It also means that the sysprof-capture code uses the pointer size of the platform that libsysprof-capture was compiled on, rather than the pointer size of the platform that GLib was compiled on. They seem unlikely to differ. Signed-off-by: Philip Withnall Helps: #40 --- src/libsysprof-capture/sysprof-capture-types.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/libsysprof-capture/sysprof-capture-types.h b/src/libsysprof-capture/sysprof-capture-types.h index c5228395..c0d2e6e2 100644 --- a/src/libsysprof-capture/sysprof-capture-types.h +++ b/src/libsysprof-capture/sysprof-capture-types.h @@ -81,12 +81,14 @@ SYSPROF_BEGIN_DECLS #define SYSPROF_CAPTURE_ADDRESS_FORMAT "0x%016" PRIx64 -#if GLIB_SIZEOF_VOID_P == 8 +static_assert (sizeof (void *) == sizeof (uintptr_t), + "UINTPTR_MAX can’t be used to determine sizeof(void*) at compile time"); +#if UINTPTR_MAX == 0xFFFFFFFFFFFFFFFFu # define SYSPROF_CAPTURE_JITMAP_MARK SYSPROF_UINT64_CONSTANT(0xE000000000000000) -#elif GLIB_SIZEOF_VOID_P == 4 +#elif UINTPTR_MAX == 0xFFFFFFFF # define SYSPROF_CAPTURE_JITMAP_MARK SYSPROF_UINT64_CONSTANT(0xE0000000) #else -#error Unknown GLIB_SIZEOF_VOID_P +#error Unknown UINTPTR_MAX #endif #define SYSPROF_CAPTURE_CURRENT_TIME (sysprof_clock_get_current_time())