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 <withnall@endlessm.com>

Helps: #40
This commit is contained in:
Philip Withnall
2020-07-02 11:32:09 +01:00
parent 113d9d166a
commit 6d3ede2e9f

View File

@ -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 cant 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())