[LTP] [PATCH V2 5/6] syscalls: Don't pass struct timespec to tst_syscall()

Cyril Hrubis chrubis@suse.cz
Wed Jun 17 14:22:06 CEST 2020


Hi!
> > >  int tst_clock_getres(clockid_t clk_id, struct timespec *res)
> > >  {
> > > -       return tst_syscall(__NR_clock_getres, clk_id, res);
> > > +       int (*func)(clockid_t clk_id, void *ts);
> > > +       struct tst_ts tts = { 0, };
> > > +       int ret;
> > > +
> > > +#if defined(__NR_clock_getres_time64)
> > > +       tts.type = TST_KERN_TIMESPEC;
> > > +       func = sys_clock_getres64;
> > > +#elif defined(__NR_clock_getres)
> > > +       tts.type = TST_KERN_OLD_TIMESPEC;
> > > +       func = sys_clock_getres;
> > > +#else
> > > +       tts.type = TST_LIBC_TIMESPEC;
> > > +       func = libc_clock_getres;
> > > +#endif
> > > +
> > > +       ret = func(clk_id, tst_ts_get(&tts));
> > 
> > This is not enough to run on old kernels that have __NR_clock_getres
> > but don't have __NR_clock_getres_time64,
> 
> What about reversing the order of the two ? Check __NR_clock_getres
> first ?
>
> > you need a runtime fallback
> > instead of a compile-time fallback.
> 
> Why so ?

The existence of the __NR_... does not mean that particular syscall is
supported or even exists. As said previously LTP defines unimplemented
syscalls to -1 to avoid #ifdef hell.

Also even if the 64bit syscall is defined in headers on particular 32bit
platform calling it on old kernel will still fail because the
functionality is simply not there.

Hence we have to select the right function on the first call to the
tst_clock_* functions.

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list