lapi: Add wordsize.h and use it
PATCH 1/1 lapi: Add wordsize.h and use it
This fixes MUSL build, which defines __WORDSIZE in <sys/reg.h>.
---
Hi,
not sure if it's a good approach, Cyril suggested to implement it in include/lapi/abisize.h, so maybe my changes should be in abisize.h.
Kind regards,
Petr
PS: I found and fix this error independently and use different approach,
but first it was reported by Dengke Du in PR #177 [2] and
used in openembedded-core [3].
[1] https://github.com/linux-test-project/ltp/pull/177#discussion_r125466352
[2] https://github.com/linux-test-project/ltp/pull/177/commits/fd65412438526a28813fae403b6d3fb6ec605bde
[3] http://cgit.openembedded.org/openembedded-core/tree/meta/recipes-extended/ltp/ltp/0009-fix-redefinition-of-struct-msgbuf-error-building-wit.patch?h=sumo
--- configure.ac | 1 + include/lapi/abisize.h | 2 ++ include/lapi/sync_file_range.h | 1 + include/lapi/wordsize.h | 17 +++++++++++++++++ testcases/kernel/io/disktest/main.h | 1 + .../kernel/mem/hugetlb/hugemmap/hugemmap02.c | 1 + .../kernel/mem/hugetlb/hugemmap/hugemmap04.c | 1 + .../kernel/mem/hugetlb/hugeshmat/hugeshmat02.c | 1 + testcases/kernel/mem/mem/mem01.c | 1 + testcases/kernel/mem/mtest01/mtest01.c | 1 + testcases/kernel/mem/oom/oom01.c | 1 + testcases/kernel/mem/oom/oom02.c | 1 + testcases/kernel/mem/oom/oom03.c | 1 + testcases/kernel/mem/oom/oom04.c | 1 + testcases/kernel/mem/oom/oom05.c | 1 + testcases/kernel/mem/swapping/swapping01.c | 1 + testcases/kernel/mem/tunable/min_free_kbytes.c | 1 + .../kernel/mem/tunable/overcommit_memory.c | 1 + testcases/kernel/mem/vma/vma03.c | 1 + .../kernel/syscalls/fadvise/posix_fadvise03.c | 1 + .../kernel/syscalls/fallocate/fallocate02.c | 1 + testcases/kernel/syscalls/fcntl/fcntl_common.h | 1 + testcases/kernel/syscalls/fork/fork14.c | 1 + testcases/kernel/syscalls/ipc/msgrcv/msgrcv08.c | 1 + testcases/kernel/syscalls/mmap/mmap15.c | 1 + testcases/kernel/syscalls/profil/profil01.c | 1 + testcases/kernel/syscalls/sbrk/sbrk03.c | 1 + testcases/kernel/syscalls/sendfile/sendfile09.c | 1 + 28 files changed, 45 insertions(+) create mode 100644 include/lapi/wordsize.h
configure.ac +1 -0
@@ -33,6 +33,7 @@ AC_PROG_YACC AC_PREFIX_DEFAULT(/opt/ltp) AC_CHECK_HEADERS([ \ + bits/wordsize.h \ ifaddrs.h \ keyutils.h \ linux/can.h \
include/lapi/abisize.h +2 -0
@@ -20,6 +20,8 @@#ifndef ABISIZE_H__ #define ABISIZE_H__ +#include "lapi/wordsize.h" +/* * Determines if we have to split up 64 bit arguments or not *
include/lapi/sync_file_range.h +1 -0
@@ -9,6 +9,7 @@#include <sys/types.h> #include "config.h" #include "lapi/syscalls.h" +#include "lapi/wordsize.h" #if !defined(HAVE_SYNC_FILE_RANGE )
include/lapi/wordsize.h new file +17 -0
@@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2019 Petr Vorel <[email protected]> +*/ + +#ifndef WORDSIZE_H__ +#define WORDSIZE_H__ + +#ifdef HAVE_BITS_WORDSIZE_H +# include <bits/wordsize.h> +#endif + +#ifndef __WORDSIZE +# include <sys/reg.h> +#endif + +#endif /* WORDSIZE_H__ */
testcases/kernel/io/disktest/main.h +1 -0
@@ -49,6 +49,7 @@#include <time.h> #include <errno.h> #include "defs.h" +#include "lapi/wordsize.h" #define VER_STR "v1.4.2"#define BLKGETSIZE _IO(0x12,96)/* IOCTL for getting the device size */
testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c +1 -0
@@ -39,6 +39,7 @@#include <sys/mount.h> #include <limits.h> #include <sys/param.h> +#include "lapi/wordsize.h" #include "hugetlb.h" #define LOW_ADDR 0x80000000
testcases/kernel/mem/hugetlb/hugemmap/hugemmap04.c +1 -0
@@ -38,6 +38,7 @@#include <stdio.h> #include <limits.h> #include <sys/param.h> +#include "lapi/wordsize.h" #include "hugetlb.h" static struct tst_option options[] = {
testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat02.c +1 -0
@@ -36,6 +36,7 @@#include <pwd.h> #include <limits.h> +#include "lapi/wordsize.h" #include "hugetlb.h" #if __WORDSIZE ==64
testcases/kernel/mem/mem/mem01.c +1 -0
@@ -39,6 +39,7 @@#include <time.h> #include <limits.h> +#include "lapi/wordsize.h" #include "test.h" /* in KB */
testcases/kernel/mem/mtest01/mtest01.c +1 -0
@@ -28,6 +28,7 @@#include <stdlib.h> #include <unistd.h> +#include "lapi/wordsize.h" #include "tst_test.h" #define FIVE_HUNDRED_MB (500ULL*1024*1024)
testcases/kernel/mem/oom/oom01.c +1 -0
@@ -27,6 +27,7 @@#include <stdio.h> #include <stdlib.h> #include <unistd.h> +#include "lapi/wordsize.h" #include "mem.h" static void verify_oom (void )
testcases/kernel/mem/oom/oom02.c +1 -0
@@ -30,6 +30,7 @@#include <numa.h> #endif +#include "lapi/wordsize.h" #include "numa_helper.h" #include "mem.h"
testcases/kernel/mem/oom/oom03.c +1 -0
@@ -30,6 +30,7 @@#include <numa.h> #endif +#include "lapi/wordsize.h" #include "numa_helper.h" #include "mem.h"
testcases/kernel/mem/oom/oom04.c +1 -0
@@ -30,6 +30,7 @@#include <numa.h> #endif +#include "lapi/wordsize.h" #include "numa_helper.h" #include "mem.h"
testcases/kernel/mem/oom/oom05.c +1 -0
@@ -30,6 +30,7 @@#include <numa.h> #endif +#include "lapi/wordsize.h" #include "numa_helper.h" #include "mem.h"
testcases/kernel/mem/swapping/swapping01.c +1 -0
@@ -44,6 +44,7 @@#include <stdlib.h> #include <string.h> #include <unistd.h> +#include "lapi/wordsize.h" #include "mem.h" /* allow swapping 1 * phy_mem in maximum */
testcases/kernel/mem/tunable/min_free_kbytes.c +1 -0
@@ -34,6 +34,7 @@#include <signal.h> #include <stdio.h> #include <stdlib.h> +#include "lapi/wordsize.h" #include "mem.h" #define MAP_SIZE (1UL<<20)
testcases/kernel/mem/tunable/overcommit_memory.c +1 -0
@@ -69,6 +69,7 @@#include <stdio.h> #include <stdlib.h> #include <limits.h> +#include "lapi/wordsize.h" #include "mem.h" #define DEFAULT_OVER_RATIO 50L
testcases/kernel/mem/vma/vma03.c +1 -0
@@ -51,6 +51,7 @@#include "test.h" #include "safe_macros.h" #include "tst_kernel.h" +#include "lapi/wordsize.h" char *TCID ="vma03" ;int TST_TOTAL =1 ;
testcases/kernel/syscalls/fadvise/posix_fadvise03.c +1 -0
@@ -30,6 +30,7 @@#include "tst_test.h" #include "lapi/syscalls.h" +#include "lapi/wordsize.h" char fname[] ="/bin/cat" ;/* test executable to open */ int fd =-1 ;/* initialized in open */
testcases/kernel/syscalls/fallocate/fallocate02.c +1 -0
@@ -41,6 +41,7 @@#include "test.h" #include "safe_macros.h" #include "lapi/fallocate.h" +#include "lapi/wordsize.h" #define BLOCKS_WRITTEN 12#ifdef TEST_DEFAULT
testcases/kernel/syscalls/fcntl/fcntl_common.h +1 -0
@@ -1,4 +1,5 @@#include "lapi/syscalls.h" +#include "lapi/wordsize.h" /* * glibc commit:
testcases/kernel/syscalls/fork/fork14.c +1 -0
@@ -35,6 +35,7 @@#include <unistd.h> #include "test.h" #include "safe_macros.h" +#include "lapi/wordsize.h" char *TCID ="fork14" ;int TST_TOTAL =1 ;
testcases/kernel/syscalls/ipc/msgrcv/msgrcv08.c +1 -0
@@ -42,6 +42,7 @@#include <sys/ipc.h> #include <sys/msg.h> #include "test.h" +#include "lapi/wordsize.h" const char *TCID ="msgrcv08" ;const int TST_TOTAL =1 ;
testcases/kernel/syscalls/mmap/mmap15.c +1 -0
@@ -36,6 +36,7 @@#include <unistd.h> #include "test.h" #include "safe_macros.h" +#include "lapi/wordsize.h" char *TCID ="mmap15" ;int TST_TOTAL =1 ;
testcases/kernel/syscalls/profil/profil01.c +1 -0
@@ -27,6 +27,7 @@#include <sys/types.h> #include "test.h" #include "safe_macros.h" +#include "lapi/wordsize.h" #include "config.h" char *TCID ="profil01" ;
testcases/kernel/syscalls/sbrk/sbrk03.c +1 -0
@@ -46,6 +46,7 @@#include <stdio.h> #include <unistd.h> +#include "lapi/wordsize.h" #include "tst_test.h" static void sbrk_test (void )
testcases/kernel/syscalls/sendfile/sendfile09.c +1 -0
@@ -51,6 +51,7 @@#include <inttypes.h> #include "test.h" #include "safe_macros.h" +#include "lapi/wordsize.h" #ifndef OFF_T #define OFF_T off_t
Signature · 1 line
2.21.0
PATCH 1/1 lapi: Add wordsize.h and use it
Hi!
Quoted 2 lines
not sure if it's a good approach, Cyril suggested to implement it in
include/lapi/abisize.h, so maybe my changes should be inabisize.h.
Maybe we should use __LP64__ instead.
But I guess that the safest option would be defining new constants somewhere in lapi/abisize.h that could be then used in tests.
Something as:
#ifdef __LP64__
# define TST_ABI64 #else # define TST_ABI32 #endif
Quoted 388 lines
PS: I found and fix this error independently and use different approach,
but first it was reported by Dengke Du in PR #177 [2] and
used in openembedded-core [3].
[1] https://github.com/linux-test-project/ltp/pull/177#discussion_r125466352
[2] https://github.com/linux-test-project/ltp/pull/177/commits/fd65412438526a28813fae403b6d3fb6ec605bde
[3] http://cgit.openembedded.org/openembedded-core/tree/meta/recipes-extended/ltp/ltp/0009-fix-redefinition-of-struct-msgbuf-error-building-wit.patch?h=sumo--- configure.ac | 1 + include/lapi/abisize.h | 2 ++ include/lapi/sync_file_range.h | 1 + include/lapi/wordsize.h | 17 +++++++++++++++++ testcases/kernel/io/disktest/main.h | 1 + .../kernel/mem/hugetlb/hugemmap/hugemmap02.c | 1 + .../kernel/mem/hugetlb/hugemmap/hugemmap04.c | 1 + .../kernel/mem/hugetlb/hugeshmat/hugeshmat02.c | 1 + testcases/kernel/mem/mem/mem01.c | 1 + testcases/kernel/mem/mtest01/mtest01.c | 1 + testcases/kernel/mem/oom/oom01.c | 1 + testcases/kernel/mem/oom/oom02.c | 1 + testcases/kernel/mem/oom/oom03.c | 1 + testcases/kernel/mem/oom/oom04.c | 1 + testcases/kernel/mem/oom/oom05.c | 1 + testcases/kernel/mem/swapping/swapping01.c | 1 + testcases/kernel/mem/tunable/min_free_kbytes.c | 1 + .../kernel/mem/tunable/overcommit_memory.c | 1 + testcases/kernel/mem/vma/vma03.c | 1 + .../kernel/syscalls/fadvise/posix_fadvise03.c | 1 + .../kernel/syscalls/fallocate/fallocate02.c | 1 + testcases/kernel/syscalls/fcntl/fcntl_common.h | 1 + testcases/kernel/syscalls/fork/fork14.c | 1 + testcases/kernel/syscalls/ipc/msgrcv/msgrcv08.c | 1 + testcases/kernel/syscalls/mmap/mmap15.c | 1 + testcases/kernel/syscalls/profil/profil01.c | 1 + testcases/kernel/syscalls/sbrk/sbrk03.c | 1 + testcases/kernel/syscalls/sendfile/sendfile09.c | 1 + 28 files changed, 45 insertions(+) create mode 100644 include/lapi/wordsize.hconfigure.ac +1
-0@@ -33,6 +33,7 @@ AC_PROG_YACC AC_PREFIX_DEFAULT(/opt/ltp) AC_CHECK_HEADERS([ \ + bits/wordsize.h \ ifaddrs.h \ keyutils.h \ linux/can.h \include/lapi/abisize.h +2
-0@@ -20,6 +20,8 @@#ifndef ABISIZE_H__ #define ABISIZE_H__ +#include "lapi/wordsize.h" +/* * Determines if we have to split up 64 bit arguments or not * include/lapi/sync_file_range.h +1
-0@@ -9,6 +9,7 @@#include <sys/types.h> #include "config.h" #include "lapi/syscalls.h" +#include "lapi/wordsize.h" #if !defined(HAVE_SYNC_FILE_RANGE )include/lapi/wordsize.h new file +17
-0@@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2019 Petr Vorel <[email protected]> +*/ + +#ifndef WORDSIZE_H__ +#define WORDSIZE_H__ + +#ifdef HAVE_BITS_WORDSIZE_H +# include <bits/wordsize.h> +#endif + +#ifndef __WORDSIZE +# include <sys/reg.h> +#endif + +#endif /* WORDSIZE_H__ */ testcases/kernel/io/disktest/main.h +1
-0@@ -49,6 +49,7 @@#include <time.h> #include <errno.h> #include "defs.h" +#include "lapi/wordsize.h" #define VER_STR "v1.4.2"#define BLKGETSIZE _IO(0x12,96)/* IOCTL for getting the device size */ testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c +1
-0@@ -39,6 +39,7 @@#include <sys/mount.h> #include <limits.h> #include <sys/param.h> +#include "lapi/wordsize.h" #include "hugetlb.h" #define LOW_ADDR 0x80000000testcases/kernel/mem/hugetlb/hugemmap/hugemmap04.c +1
-0@@ -38,6 +38,7 @@#include <stdio.h> #include <limits.h> #include <sys/param.h> +#include "lapi/wordsize.h" #include "hugetlb.h" static struct tst_option options[] = {testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat02.c +1
-0@@ -36,6 +36,7 @@#include <pwd.h> #include <limits.h> +#include "lapi/wordsize.h" #include "hugetlb.h" #if __WORDSIZE ==64 testcases/kernel/mem/mem/mem01.c +1
-0@@ -39,6 +39,7 @@#include <time.h> #include <limits.h> +#include "lapi/wordsize.h" #include "test.h" /* in KB */ testcases/kernel/mem/mtest01/mtest01.c +1
-0@@ -28,6 +28,7 @@#include <stdlib.h> #include <unistd.h> +#include "lapi/wordsize.h" #include "tst_test.h" #define FIVE_HUNDRED_MB (500ULL*1024*1024)testcases/kernel/mem/oom/oom01.c +1
-0@@ -27,6 +27,7 @@#include <stdio.h> #include <stdlib.h> #include <unistd.h> +#include "lapi/wordsize.h" #include "mem.h" static void verify_oom (void )testcases/kernel/mem/oom/oom02.c +1
-0@@ -30,6 +30,7 @@#include <numa.h> #endif +#include "lapi/wordsize.h" #include "numa_helper.h" #include "mem.h" testcases/kernel/mem/oom/oom03.c +1
-0@@ -30,6 +30,7 @@#include <numa.h> #endif +#include "lapi/wordsize.h" #include "numa_helper.h" #include "mem.h" testcases/kernel/mem/oom/oom04.c +1
-0@@ -30,6 +30,7 @@#include <numa.h> #endif +#include "lapi/wordsize.h" #include "numa_helper.h" #include "mem.h" testcases/kernel/mem/oom/oom05.c +1
-0@@ -30,6 +30,7 @@#include <numa.h> #endif +#include "lapi/wordsize.h" #include "numa_helper.h" #include "mem.h" testcases/kernel/mem/swapping/swapping01.c +1
-0@@ -44,6 +44,7 @@#include <stdlib.h> #include <string.h> #include <unistd.h> +#include "lapi/wordsize.h" #include "mem.h" /* allow swapping 1 * phy_mem in maximum */ testcases/kernel/mem/tunable/min_free_kbytes.c +1
-0@@ -34,6 +34,7 @@#include <signal.h> #include <stdio.h> #include <stdlib.h> +#include "lapi/wordsize.h" #include "mem.h" #define MAP_SIZE (1UL<<20)testcases/kernel/mem/tunable/overcommit_memory.c +1
-0@@ -69,6 +69,7 @@#include <stdio.h> #include <stdlib.h> #include <limits.h> +#include "lapi/wordsize.h" #include "mem.h" #define DEFAULT_OVER_RATIO 50Ltestcases/kernel/mem/vma/vma03.c +1
-0@@ -51,6 +51,7 @@#include "test.h" #include "safe_macros.h" #include "tst_kernel.h" +#include "lapi/wordsize.h" char *TCID ="vma03" ;int TST_TOTAL =1 ;testcases/kernel/syscalls/fadvise/posix_fadvise03.c +1
-0@@ -30,6 +30,7 @@#include "tst_test.h" #include "lapi/syscalls.h" +#include "lapi/wordsize.h" char fname[] ="/bin/cat" ;/* test executable to open */ int fd =-1 ;/* initialized in open */ testcases/kernel/syscalls/fallocate/fallocate02.c +1
-0@@ -41,6 +41,7 @@#include "test.h" #include "safe_macros.h" #include "lapi/fallocate.h" +#include "lapi/wordsize.h" #define BLOCKS_WRITTEN 12#ifdef TEST_DEFAULT testcases/kernel/syscalls/fcntl/fcntl_common.h +1
-0@@ -1,4 +1,5 @@#include "lapi/syscalls.h" +#include "lapi/wordsize.h" /* * glibc commit: testcases/kernel/syscalls/fork/fork14.c +1
-0@@ -35,6 +35,7 @@#include <unistd.h> #include "test.h" #include "safe_macros.h" +#include "lapi/wordsize.h" char *TCID ="fork14" ;int TST_TOTAL =1 ;testcases/kernel/syscalls/ipc/msgrcv/msgrcv08.c +1
-0@@ -42,6 +42,7 @@#include <sys/ipc.h> #include <sys/msg.h> #include "test.h" +#include "lapi/wordsize.h" const char *TCID ="msgrcv08" ;const int TST_TOTAL =1 ;testcases/kernel/syscalls/mmap/mmap15.c +1
-0@@ -36,6 +36,7 @@#include <unistd.h> #include "test.h" #include "safe_macros.h" +#include "lapi/wordsize.h" char *TCID ="mmap15" ;int TST_TOTAL =1 ;testcases/kernel/syscalls/profil/profil01.c +1
-0@@ -27,6 +27,7 @@#include <sys/types.h> #include "test.h" #include "safe_macros.h" +#include "lapi/wordsize.h" #include "config.h" char *TCID ="profil01" ;testcases/kernel/syscalls/sbrk/sbrk03.c +1
-0@@ -46,6 +46,7 @@#include <stdio.h> #include <unistd.h> +#include "lapi/wordsize.h" #include "tst_test.h" static void sbrk_test (void )testcases/kernel/syscalls/sendfile/sendfile09.c +1
-0@@ -51,6 +51,7 @@#include <inttypes.h> #include "test.h" #include "safe_macros.h" +#include "lapi/wordsize.h" #ifndef OFF_T #define OFF_T off_tSignature · 1 line
2.21.0
Signature · 2 lines
Cyril Hrubis [email protected]