[LTP] [RFC PATCH v2 1/1] lapi: Add sysinfo.h to fix build with older MUSL toolchain

Yang Xu (Fujitsu) xuyang2018.jy@fujitsu.com
Fri May 12 09:53:00 CEST 2023


Hi Petr

Cyril has pointed that SYSINFO_H__ should be on the top of #ifndef 
SYSINFO_H__ three years ago[1].

#ifndef SYSINFO_H__
#define SYSINFO_H__

......

[1]https://lore.kernel.org/ltp/20201014143317.GC13224@yuki.lan/

> Hi all,
> 
>> diff --git a/testcases/kernel/syscalls/sysinfo/sysinfo01.c b/testcases/kernel/syscalls/sysinfo/sysinfo01.c
>> index 2ea44a2be..a237345ef 100644
>> --- a/testcases/kernel/syscalls/sysinfo/sysinfo01.c
>> +++ b/testcases/kernel/syscalls/sysinfo/sysinfo01.c
>> @@ -69,7 +69,7 @@
>>   #include <sys/types.h>
>>   #include <sys/stat.h>
>>   #include <sys/signal.h>
>> -#include <sys/sysinfo.h>
>> +#include "lapi/sysinfo.h"
> 
> NOTE: sysinfo0[1-3].c (and any new sysinfo test) will need to use
> <sys/sysinfo.h> due sysinfo() signature in it (that's not in
> <linux/sysinfo.h>).
> Following fix would be needed for this patch. But as there is no
> feedback, I don't even send v3.
I guess it still will meet redefine erroron musl[2] because
tst_test.h- >#include "tst_safe_macros.h" -> <linux/sysinfo.h>  -> 
sysinfo struct
<sys/sysinfo.h> -> sysinfo struct
[2]http://git.musl-libc.org/cgit/musl/tree/include/sys/sysinfo.h

How about use <linux/sysinfo.h> directly and add signature in 
lapi/sysinfo.h?

Best Regards
Yang Xu
> 
> Kind regards,
> Petr
> 
> diff --git testcases/kernel/syscalls/sysinfo/sysinfo01.c
> testcases/kernel/syscalls/sysinfo/sysinfo01.c
> index a237345ef..2ea44a2be 100644
> --- testcases/kernel/syscalls/sysinfo/sysinfo01.c
> +++ testcases/kernel/syscalls/sysinfo/sysinfo01.c
> @@ -69,7 +69,7 @@
>   #include <sys/types.h>
>   #include <sys/stat.h>
>   #include <sys/signal.h>
> -#include "lapi/sysinfo.h"
> +#include <sys/sysinfo.h>
> 
>   #include "test.h"
> 
> diff --git testcases/kernel/syscalls/sysinfo/sysinfo02.c
> testcases/kernel/syscalls/sysinfo/sysinfo02.c
> index 61fa1ab75..7ad0e8bdc 100644
> --- testcases/kernel/syscalls/sysinfo/sysinfo02.c
> +++ testcases/kernel/syscalls/sysinfo/sysinfo02.c
> @@ -65,7 +65,7 @@
>   #include <sys/types.h>
>   #include <sys/stat.h>
>   #include <sys/signal.h>
> -#include "lapi/sysinfo.h"
> +#include <sys/sysinfo.h>
>   #include <stdint.h>
> 
>   #include "test.h"
> diff --git testcases/kernel/syscalls/sysinfo/sysinfo03.c
> testcases/kernel/syscalls/sysinfo/sysinfo03.c
> index 0b6ffb49b..13b0de806 100644
> --- testcases/kernel/syscalls/sysinfo/sysinfo03.c
> +++ testcases/kernel/syscalls/sysinfo/sysinfo03.c
> @@ -14,9 +14,9 @@
>    */
> 
>   #include "lapi/posix_clocks.h"
> -#include "lapi/sched.h"
> -#include "lapi/sysinfo.h"
> +#include <sys/sysinfo.h>
>   #include "tst_test.h"
> +#include "lapi/sched.h"
> 
>   static int offsets[] = {
>    10,
> 


More information about the ltp mailing list