Re: [LTP] [PATCH V3 2/3] fixes for 16-bit syscalls testcases

chrubis
2013-09-03T10:11:08Z

Hi!
> Sorry, but is it possible to use #ifdef or #if inside a #define macro?

Right it does not, sorry. I tend to forget how dumb it the C preprocessor is.

> This doesn't work:
>
> #define MYDEF(NN) \
> # ifdef TST_USE_COMPAT16_SYSCALL
> return NN(0);
> # else
> return NN(1);
> # endif
>
> MYDEF(bla)

We need to pull the first if out of the macro and we can do the second
one as a regular if (it will be optimized away anyway).

#ifdef TST_USE_COMPAT16_SYSCALL
# define LTP_CREATE_SYSCALL(sys_name, ...) \
if (__NR_##sys_name##32 != __LTP__NR_INVALID_SYSCALL) { \
return ltp_syscall(sys_name, ##__VA_ARGS__); \
} else { \
errno = ENOSYS; \
return -1; \
}
#else
# define LTP_CREATE_SYSCALL(sys_name, ...) \
return sys_name(__VA_ARGS__)
#endif

The usage will be:

int SETGROUPS(size_t size, const GID_T *list)
{
LTP_CREATE_SYSCALL(getgroups, size, list);
}

Does this sound reasonable?

--
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
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!