[LTP] [PATCH] endian_switch01: Add HAVE_GETAUXVAL guarder

Petr Vorel pvorel@suse.cz
Fri May 5 18:28:22 CEST 2023


From: Petr Vorel <petr.vorel@gmail.com>

This fixes compilation on uClibc / uClibc-ng (and also older glibc),
which does not provide this header.

Fixes: 03b76a20c ("endian_switch01.c: drop unused main4()")
Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
---
Hi Jan,

can you please have a look, I'd prefer to merge this before release
(build fix on Buildroot).

Kind regards,
Petr

 testcases/kernel/syscalls/switch/endian_switch01.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/testcases/kernel/syscalls/switch/endian_switch01.c b/testcases/kernel/syscalls/switch/endian_switch01.c
index d965aed56..fac9e2382 100644
--- a/testcases/kernel/syscalls/switch/endian_switch01.c
+++ b/testcases/kernel/syscalls/switch/endian_switch01.c
@@ -2,7 +2,7 @@
 /*
  * Copyright (c) International Business Machines Corp., 2008
  * Copyright (c) Paul Mackerras, IBM Corp., 2008
- * Copyright (c) 2018 Linux Test Project
+ * Copyright (c) 2018-2023 Linux Test Project
  */
 
 /*
@@ -15,16 +15,20 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <elf.h>
-#include <sys/auxv.h>
 #include <sys/types.h>
 #include <sys/wait.h>
+
 #include "tst_test.h"
 
 #if defined(__powerpc64__) || defined(__powerpc__)
+
 # ifndef PPC_FEATURE_TRUE_LE
-# define PPC_FEATURE_TRUE_LE              0x00000002
+#  define PPC_FEATURE_TRUE_LE              0x00000002
 # endif
 
+# ifdef HAVE_GETAUXVAL
+#  include <sys/auxv.h>
+
 /*
  * Make minimal call to 0x1ebe. If we get ENOSYS then syscall is not
  * available, likely because of:
@@ -98,6 +102,10 @@ static struct tst_test test = {
 	.forks_child = 1,
 };
 
+# else
+TST_TEST_TCONF("Toolchain does not have <sys/auxv.h>");
+# endif /* HAVE_GETAUXVAL */
+
 #else /* defined (__powerpc64__) || (__powerpc__) */
 TST_TEST_TCONF("This system does not support running of switch() syscall");
 #endif
-- 
2.40.1



More information about the ltp mailing list