public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] syscalls/getcpu01: support Android
@ 2018-09-12 17:32 Steve Muckle
  2018-09-27 13:35 ` Cyril Hrubis
  0 siblings, 1 reply; 2+ messages in thread
From: Steve Muckle @ 2018-09-12 17:32 UTC (permalink / raw)
  To: ltp

Android platforms have the required support for this test.

Signed-off-by: Steve Muckle <smuckle.linux@gmail.com>
---
 testcases/kernel/syscalls/getcpu/getcpu01.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/testcases/kernel/syscalls/getcpu/getcpu01.c b/testcases/kernel/syscalls/getcpu/getcpu01.c
index c927512ca..73db5a21a 100644
--- a/testcases/kernel/syscalls/getcpu/getcpu01.c
+++ b/testcases/kernel/syscalls/getcpu/getcpu01.c
@@ -61,7 +61,9 @@
 #include <sys/types.h>
 #include <dirent.h>
 
-#if defined(__i386__) || defined(__x86_64__)
+#ifdef ANDROID
+int sys_support = 1;
+#elif defined(__i386__) || defined(__x86_64__)
 #if __GLIBC_PREREQ(2,6)
 #if defined(__x86_64__)
 #include <utmpx.h>
@@ -164,7 +166,7 @@ static inline int getcpu(unsigned *cpu_id, unsigned *node_id,
 {
 #if defined(__i386__)
 	return syscall(318, cpu_id, node_id, cache_struct);
-#elif __GLIBC_PREREQ(2,6)
+#elif __GLIBC_PREREQ(2,6) || defined(ANDROID)
 	*cpu_id = sched_getcpu();
 #endif
 	return 0;
@@ -191,7 +193,7 @@ unsigned int set_cpu_affinity(void)
 	cpu_set_t *set;
 	size_t size;
 	int nrcpus = 1024;
-#if __GLIBC_PREREQ(2, 7)
+#if __GLIBC_PREREQ(2, 7) || defined(ANDROID)
 realloc:
 	set = CPU_ALLOC(nrcpus);
 #else
@@ -200,7 +202,7 @@ realloc:
 	if (set == NULL) {
 		tst_brkm(TFAIL, NULL, "CPU_ALLOC:errno:%d", errno);
 	}
-#if __GLIBC_PREREQ(2, 7)
+#if __GLIBC_PREREQ(2, 7) || defined(ANDROID)
 	size = CPU_ALLOC_SIZE(nrcpus);
 	CPU_ZERO_S(size, set);
 #else
@@ -209,7 +211,7 @@ realloc:
 #endif
 	if (sched_getaffinity(0, size, set) < 0) {
 		CPU_FREE(set);
-#if __GLIBC_PREREQ(2, 7)
+#if __GLIBC_PREREQ(2, 7) || defined(ANDROID)
 		if (errno == EINVAL && nrcpus < (1024 << 8)) {
 			nrcpus = nrcpus << 2;
 			goto realloc;
@@ -224,7 +226,7 @@ realloc:
 		tst_exit();
 	}
 	cpu_max = max_cpuid(size, set);
-#if __GLIBC_PREREQ(2, 7)
+#if __GLIBC_PREREQ(2, 7) || defined(ANDROID)
 	CPU_ZERO_S(size, set);
 	CPU_SET_S(cpu_max, size, set);
 #else
@@ -247,7 +249,7 @@ unsigned int max_cpuid(size_t size, cpu_set_t * set)
 {
 	unsigned int index, max = 0;
 	for (index = 0; index < size * BITS_PER_BYTE; index++)
-#if __GLIBC_PREREQ(2, 7)
+#if __GLIBC_PREREQ(2, 7) || defined(ANDROID)
 		if (CPU_ISSET_S(index, size, set))
 #else
 		if (CPU_ISSET(index, set))
-- 
2.19.0.rc2.392.g5ba43deb5a-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [LTP] [PATCH] syscalls/getcpu01: support Android
  2018-09-12 17:32 [LTP] [PATCH] syscalls/getcpu01: support Android Steve Muckle
@ 2018-09-27 13:35 ` Cyril Hrubis
  0 siblings, 0 replies; 2+ messages in thread
From: Cyril Hrubis @ 2018-09-27 13:35 UTC (permalink / raw)
  To: ltp

Hi!
> Android platforms have the required support for this test.

This is getting way too ugly with all the ifdefs...

And actually we do have a fallback implementation for the CPU_* macros.
I guess that it would be cleaner if we moved the sched_setaffinity.h
from syscalls/sched_setaffinity/ to include/lapi/ so that we can use it
here, that should eliminate most of the ugliness.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-09-27 13:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-12 17:32 [LTP] [PATCH] syscalls/getcpu01: support Android Steve Muckle
2018-09-27 13:35 ` Cyril Hrubis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox