> +/*
> + * LTP_COMPAT16_IS_DEFINED(SNAME) - if true, then __NR_SNAME
> + *   is a 16-bit version of SNAME() syscall
> + *
> + * LTP_COMPAT16_IF_DEFINED(SNAME, ...) - action to execute
> + *   if 16-bit version of SNAME syscall is supported
> + *
> + * LTP_COMPAT16_IF_UNDEFINED(SNAME) - action to execute
> + *   if 16-bit version of SNAME syscall is not supported
> + */
> +#define LTP_COMPAT16_IS_DEFINED(SNAME) \
> +     (__NR_##SNAME##32 != __LTP__NR_INVALID_SYSCALL)
> +
> +#define LTP_COMPAT16_IF_DEFINED(SNAME, ...) \
> +     return ltp_syscall(__NR_##SNAME, ##__VA_ARGS__);
> +
> +#define LTP_COMPAT16_IF_UNDEFINED(SNAME) \
> +     tst_brkm(TCONF, cleanup, \
> +             "16-bit version of %s() is not supported on your platform", \
> +             #SNAME);

What I do not like is the calling cleanup from this part of the code, it
was not passed there and the code will break badly if you name the
cleanup function differently (or create more of them, cleanup, cleanup1,
...).

What I would do here is to set errno to ENOSYS and return a failure. And
let the test that called the function handle it.

Or we can add a cleanup parameter to the all caps functions bellow.

> +int
> +SETGROUPS(size_t gidsetsize, GID_T *list16)
> +{
> +# if LTP_COMPAT16_IS_DEFINED(setgroups)
> +     LTP_COMPAT16_IF_DEFINED(setgroups, gidsetsize, list16)
> +# else
> +     LTP_COMPAT16_IF_UNDEFINED(setgroups)
> +# endif
> +}
> +
> +int
> +GETGROUPS(int gidsetsize, GID_T *list16)
> +{
> +# if LTP_COMPAT16_IS_DEFINED(getgroups)
> +     LTP_COMPAT16_IF_DEFINED(getgroups, gidsetsize, list16)
> +# else
> +     LTP_COMPAT16_IF_UNDEFINED(getgroups)
> +# endif
> +}
> +
> +#else
> +int
> +SETGROUPS(size_t size, const GID_T *list)
> +{
> +     return setgroups(size, list);
> +}
> +
> +int
> +GETGROUPS(int size, GID_T *list)
> +{
> +     return getgroups(size, list);
> +}
> +
> +#endif       /* TST_USE_COMPAT16_SYSCALL */
> +
> +#endif /* __SETGROUPS_COMPAT_16_H__ */

We can even simplify this macros. At least the innter part of SETGROUPS
and GETGROUPS could be created by a single macro:

COMPAT16_SYSCALL(setgroups, gitsetsize, list16)

#define COMPAT16_SYSCALL(sys_name, ...) \
# ifdef TST_USE_COMPAT16_SYSCALL
#  if ....
        return ltp_syscall(sys_name, ##__VA_ARGS__);
#  else
        errno = ENOSYS;
        return -1;
#  fi
# else
        return sys_name(__VA_ARGS__);
# endif

In case that the syscall and libcall params does not match we can use
only the part enclosed in the ifdef TST_USE_COMPAT16_SYSCALL.

-- 
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to