[LTP] [PATCH v2 2/2] syscalls/getcpu:Add libc sched_getcpu() detection &&fix compiler errors
Petr Vorel
pvorel@suse.cz
Mon May 13 10:27:08 CEST 2019
Hi,
> sched_getcpu() isn't defined on some old distros, so we can add dection
> and fix compiler error.
> Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
Acked-by: Petr Vorel <pvorel@suse.cz>
@Metan: I'd be for pushing this before new release.
...
> static inline int get_cpu(unsigned *cpu_id,
> unsigned *node_id LTP_ATTRIBUTE_UNUSED,
> void *cache_struct LTP_ATTRIBUTE_UNUSED)
> {
> -#if defined(__i386__)
> - return syscall(__NR_getcpu, cpu_id, node_id, cache_struct);
> +#ifndef HAVE_SCHED_GETCPU
> + return tst_syscall(__NR_getcpu, cpu_id, node_id, cache_struct);
> #else
> *cpu_id = sched_getcpu();
> #endif
BTW: when rewriting into new C API (whenever it happens) it'd be nice to test
both syscall and libc sched_getcpu() (if available) via recently added test_variants [1].
Kind regards,
Petr
[1] https://github.com/linux-test-project/ltp/wiki/Test-Writing-Guidelines#2229-testing-similar-syscalls-in-one-test
More information about the ltp
mailing list