From d2c4f3841d1cba17c99f76812ffcb75a6c402202 Mon Sep 17 00:00:00 2001 From: Jiaxun Yang Date: Mon, 18 Jan 2021 14:38:05 +0800 Subject: tests: Rename PAGE_SIZE definitions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As per POSIX specification of limits.h [1], OS libc may define PAGE_SIZE in limits.h. Self defined PAGE_SIZE is frequently used in tests, to prevent collosion of definition, we give PAGE_SIZE definitons reasonable prefixs. [1]: https://pubs.opengroup.org/onlinepubs/7908799/xsh/limits.h.html Signed-off-by: Jiaxun Yang Reviewed-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20210118063808.12471-7-jiaxun.yang@flygoat.com> Signed-off-by: Thomas Huth --- tests/migration/stress.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'tests/migration/stress.c') diff --git a/tests/migration/stress.c b/tests/migration/stress.c index de45e8e..b7240a1 100644 --- a/tests/migration/stress.c +++ b/tests/migration/stress.c @@ -27,7 +27,7 @@ const char *argv0; -#define PAGE_SIZE 4096 +#define RAM_PAGE_SIZE 4096 #ifndef CONFIG_GETTID static int gettid(void) @@ -158,11 +158,11 @@ static unsigned long long now(void) static void stressone(unsigned long long ramsizeMB) { - size_t pagesPerMB = 1024 * 1024 / PAGE_SIZE; + size_t pagesPerMB = 1024 * 1024 / RAM_PAGE_SIZE; g_autofree char *ram = g_malloc(ramsizeMB * 1024 * 1024); char *ramptr; size_t i, j, k; - g_autofree char *data = g_malloc(PAGE_SIZE); + g_autofree char *data = g_malloc(RAM_PAGE_SIZE); char *dataptr; size_t nMB = 0; unsigned long long before, after; @@ -174,7 +174,7 @@ static void stressone(unsigned long long ramsizeMB) * calloc instead :-) */ memset(ram, 0xfe, ramsizeMB * 1024 * 1024); - if (random_bytes(data, PAGE_SIZE) < 0) { + if (random_bytes(data, RAM_PAGE_SIZE) < 0) { return; } @@ -186,7 +186,7 @@ static void stressone(unsigned long long ramsizeMB) for (i = 0; i < ramsizeMB; i++, nMB++) { for (j = 0; j < pagesPerMB; j++) { dataptr = data; - for (k = 0; k < PAGE_SIZE; k += sizeof(long long)) { + for (k = 0; k < RAM_PAGE_SIZE; k += sizeof(long long)) { ramptr += sizeof(long long); dataptr += sizeof(long long); *(unsigned long long *)ramptr ^= *(unsigned long long *)dataptr; -- cgit v1.1