From 994b0535ef36ca4027e4a8789129f028dbe3e873 Mon Sep 17 00:00:00 2001 From: Laurent Bigonville Date: Thu, 2 Jan 2020 12:39:52 +0100 Subject: [PATCH 1/2] Fix endianness detection when writing a frame Properly detect endianness at compilation time This fixes the tests on big-endian machines Fix: https://gitlab.gnome.org/GNOME/sysprof/issues/7 --- src/libsysprof-capture/sysprof-capture-writer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libsysprof-capture/sysprof-capture-writer.c b/src/libsysprof-capture/sysprof-capture-writer.c index 6c9362ec..956340e8 100644 --- a/src/libsysprof-capture/sysprof-capture-writer.c +++ b/src/libsysprof-capture/sysprof-capture-writer.c @@ -499,7 +499,7 @@ sysprof_capture_writer_new_from_fd (int fd, header->magic = SYSPROF_CAPTURE_MAGIC; header->version = 1; -#ifdef G_LITTLE_ENDIAN +#if G_BYTE_ORDER == G_LITTLE_ENDIAN header->little_endian = TRUE; #else header->little_endian = FALSE; From 8a86d5f1a0510474abc1d02f37f7731cf3483f63 Mon Sep 17 00:00:00 2001 From: Laurent Bigonville Date: Thu, 2 Jan 2020 12:41:47 +0100 Subject: [PATCH 2/2] test: Fix detection of pagesize at runtime Not all architectures have a page size of 4k, detect it at runtime Fix: https://gitlab.gnome.org/GNOME/sysprof/issues/21 --- src/tests/test-capture.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tests/test-capture.c b/src/tests/test-capture.c index 4605fa0f..5f8eb3d0 100644 --- a/src/tests/test-capture.c +++ b/src/tests/test-capture.c @@ -28,6 +28,7 @@ #include #include "sysprof-platform.h" +#include "sysprof-capture-util-private.h" static void copy_into (GHashTable *src, @@ -54,7 +55,7 @@ test_reader_basic (void) writer = sysprof_capture_writer_new ("capture-file", 0); g_assert (writer != NULL); - g_assert_cmpint (sysprof_capture_writer_get_buffer_size (writer), ==, 4096*64); + g_assert_cmpint (sysprof_capture_writer_get_buffer_size (writer), ==, _sysprof_getpagesize()*64); sysprof_capture_writer_flush (writer);