[LTP] [PATCH 2/3] generate_syscall.sh: add a helper named tst_syscall_base

gang.yan@linux.dev gang.yan@linux.dev
Wed Jul 15 05:04:55 CEST 2026


July 14, 2026 at 7:08 PM, "Andrea Cervesato" <andrea.cervesato@suse.com mailto:andrea.cervesato@suse.com?to=%22Andrea%20Cervesato%22%20%3Candrea.cervesato%40suse.com%3E > wrote:


> 
> Hi Gang,
> 
> > 
> > From: Gang Yan <yangang@kylinos.cn>
> >  
> >  This patch adds a helper named tst_syscall_base, it can check the
> >  syscall on older distros without tst_brk.
> >  
> >  Signed-off-by: Gang Yan <yangang@kylinos.cn>
> >  ---
> >  include/lapi/syscalls/generate_syscalls.sh | 27 +++++++++++++---------
> >  1 file changed, 16 insertions(+), 11 deletions(-)
> >  
> >  diff --git a/include/lapi/syscalls/generate_syscalls.sh b/include/lapi/syscalls/generate_syscalls.sh
> >  index 19f280dfb..95c2c9aeb 100755
> >  --- a/include/lapi/syscalls/generate_syscalls.sh
> >  +++ b/include/lapi/syscalls/generate_syscalls.sh
> >  @@ -49,18 +49,23 @@ tst_brkm(TCONF, dummy_cleanup, \
> >  })
> >  #endif
> >  
> >  +#define tst_syscall_base(NR, ...) ({ \
> >  + intptr_t tst_ret; \
> >  + if (NR == __LTP__NR_INVALID_SYSCALL) { \
> >  + errno = ENOSYS; \
> >  + tst_ret = -1; \
> >  + } else { \
> >  + tst_ret = syscall(NR, ##__VA_ARGS__); \
> >  + } \
> >  + tst_ret; \
> >  +})
> > 
Hi Andrea,

Thanks for your review.

> Do we really need this? If we don't define memfd_secret, we really want
> to get a TCONF. And the function is used in a weird way.

You are right. I've confirmed that syscall(-1) returning a positive
value is a glibc or kernel bug on loongarch64, syscall(-1) should return
-1, but return 38 (ENONSYS) in my enviroment. It is not something LTP should
work around.


> 
> If you need to add the support for memfd_secret, please just update the
> syscalls files via:
> 
> ./include/lapi/syscalls/generate_arch.sh <path to linux sources>
> 
> We don't update .in files manually since it's error prone.
>

Thanks again

Cherrs
Gang 
> Regards,
> --
> Andrea Cervesato
> SUSE QE Automation Engineer Linux
> andrea.cervesato@suse.com mailto:andrea.cervesato@suse.com
>


More information about the ltp mailing list