mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-12 08:00:53 +00:00
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:
@ -81,12 +81,14 @@ SYSPROF_BEGIN_DECLS
|
|||||||
|
|
||||||
#define SYSPROF_CAPTURE_ADDRESS_FORMAT "0x%016" PRIx64
|
#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)
|
# 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)
|
# define SYSPROF_CAPTURE_JITMAP_MARK SYSPROF_UINT64_CONSTANT(0xE0000000)
|
||||||
#else
|
#else
|
||||||
#error Unknown GLIB_SIZEOF_VOID_P
|
#error Unknown UINTPTR_MAX
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define SYSPROF_CAPTURE_CURRENT_TIME (sysprof_clock_get_current_time())
|
#define SYSPROF_CAPTURE_CURRENT_TIME (sysprof_clock_get_current_time())
|
||||||
|
|||||||
Reference in New Issue
Block a user