]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
selftests: riscv: Allow mmap test to compile on 32-bit
authorCharlie Jenkins <charlie@rivosinc.com>
Thu, 8 Aug 2024 18:41:40 +0000 (11:41 -0700)
committerPalmer Dabbelt <palmer@rivosinc.com>
Tue, 17 Sep 2024 15:05:09 +0000 (08:05 -0700)
Macros needed for 32-bit compilations were hidden behind 64-bit riscv
ifdefs. Fix the 32-bit compilations by moving macros to allow the
memory_layout test to run on 32-bit.

Signed-off-by: Charlie Jenkins <charlie@rivosinc.com>
Fixes: 73d05262a2ca ("selftests: riscv: Generalize mm selftests")
Link: https://lore.kernel.org/r/20240808-mmap_tests__fixes-v1-1-b1344b642a84@rivosinc.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
tools/testing/selftests/riscv/mm/mmap_test.h

index 3b29ca3bb3d40d1aa11433d7433ba62ad85e7cbe..1c3313c201d5ed283624757984cc1d17c87586c7 100644 (file)
@@ -48,11 +48,11 @@ uint32_t random_addresses[] = {
 };
 #endif
 
-// Only works on 64 bit
-#if __riscv_xlen == 64
 #define PROT (PROT_READ | PROT_WRITE)
 #define FLAGS (MAP_PRIVATE | MAP_ANONYMOUS)
 
+// Only works on 64 bit
+#if __riscv_xlen == 64
 /* mmap must return a value that doesn't use more bits than the hint address. */
 static inline unsigned long get_max_value(unsigned long input)
 {
@@ -80,6 +80,8 @@ static inline unsigned long get_max_value(unsigned long input)
        })
 #endif /* __riscv_xlen == 64 */
 
+#define TEST_MMAPS do { } while (0)
+
 static inline int memory_layout(void)
 {
        void *value1 = mmap(NULL, sizeof(int), PROT, FLAGS, 0, 0);