[LTP] [PATCH v6 1/3] Refactor regen.sh script to generate syscalls

Andrea Cervesato andrea.cervesato@suse.com
Thu Oct 31 12:02:06 CET 2024


On 10/31/24 11:28, Cyril Hrubis wrote:
> Hi!
>> I was comparing the old include/lapi/syscalls.h (21579 lines) and the new one
>> (20054). Having new file shorter is a bit surprising to me. I haven't found what
>> is missing, probably I'm missing something myself :).
> That is strange, I got exactly same content minus some whitespaces and
> slightly different macros that check for arch support:
>
> --- syscalls.h.old      2024-10-31 11:17:04.840217056 +0100
> +++ syscalls.h  2024-10-31 11:23:38.326891830 +0100
> @@ -1,3 +1,5 @@
> +
> +// SPDX-License-Identifier: GPL-2.0-or-later
>   /************************************************
>    * GENERATED FILE: DO NOT EDIT/PATCH THIS FILE  *
>    *  change your arch specific .in file instead  *
> @@ -6,8 +8,6 @@
>   /*
>    * Here we stick all the ugly *fallback* logic for linux
>    * system call numbers (those __NR_ thingies).
> - *
> - * Licensed under the GPLv2 or later, see the COPYING file.
>    */
>
>   #ifndef LAPI_SYSCALLS_H__
> @@ -19,30 +19,30 @@
>
>   #ifdef TST_TEST_H__
>   #define TST_SYSCALL_BRK__(NR, SNR) ({ \
> -       tst_brk(TCONF, \
> -               "syscall(%d) " SNR " not supported on your arch", NR); \
> +tst_brk(TCONF, \
> +       "syscall(%d) " SNR " not supported on your arch", NR); \
>   })
>   #else
>   inline static void dummy_cleanup(void) {}
>
>   #define TST_SYSCALL_BRK__(NR, SNR) ({ \
> -       tst_brkm(TCONF, dummy_cleanup, \
> -               "syscall(%d) " SNR " not supported on your arch", NR); \
> +tst_brkm(TCONF, dummy_cleanup, \
> +       "syscall(%d) " SNR " not supported on your arch", NR); \
>   })
>   #endif
>
>   #define tst_syscall(NR, ...) ({ \
> -       intptr_t tst_ret; \
> -       if (NR == __LTP__NR_INVALID_SYSCALL) { \
> -               errno = ENOSYS; \
> -               tst_ret = -1; \
> -       } else { \
> -               tst_ret = syscall(NR, ##__VA_ARGS__); \
> -       } \
> -       if (tst_ret == -1 && errno == ENOSYS) { \
> -               TST_SYSCALL_BRK__(NR, #NR); \
> -       } \
> -       tst_ret; \
> +intptr_t tst_ret; \
> +if (NR == __LTP__NR_INVALID_SYSCALL) { \
> +       errno = ENOSYS; \
> +       tst_ret = -1; \
> +} else { \
> +       tst_ret = syscall(NR, ##__VA_ARGS__); \
> +} \
> +if (tst_ret == -1 && errno == ENOSYS) { \
> +       TST_SYSCALL_BRK__(NR, #NR); \
> +} \
> +tst_ret; \
>   })
>
>   #define __LTP__NR_INVALID_SYSCALL -1
> @@ -6681,7 +6681,7 @@
>   #endif
>
>
> -#if defined(__mips__) && defined(_ABIN32)
> +#ifdef __mips_n32__
>   # ifndef __NR_read
>   #  define __NR_read 6000
>   # endif
> @@ -7828,7 +7828,7 @@
>   #endif
>
>
> -#if defined(__mips__) && defined(_ABI64)
> +#ifdef __mips_n64__
>   # ifndef __NR_read
>   #  define __NR_read 5000
>   # endif
> @@ -8903,7 +8903,7 @@
>   #endif
>
>
> -#if defined(__mips__) && defined(_ABIO32) && _MIPS_SZLONG == 32
> +#ifdef __mips_o32__
>   # ifndef __NR_syscall
>   #  define __NR_syscall 4000
>   # endif
>
I just realized that these are errors. The reason is that files are 
changed now, so I need to change the way architecture is seen at compile 
time. For example, mips64n32 is now mips_n32 and that has to be handled 
in the syscalls file generator.

Andrea



More information about the ltp mailing list