Subject: #ifdef in syscalls.master considered harmful
To: None <tech-kern@NetBSD.org>
From: Matt Thomas <matt@3am-software.com>
List: tech-kern
Date: 08/31/2006 09:11:35
The fallout of my making PTRACE conditional has made me realize that
#ifdefs in syscalls.master are never the right thing. They just overly
complicate the code. The only downside to no #ifdefs in syscall.master
is that *sysent.c always has a call to optional syscall. This can
be resolved by including a include files which will #define the syscall
to sys_nosys. Or the actual syscall could always return ENOSYS.
For the LKM case, declare the underlying syscall as a weak reference and
then test it for being non-zero at the start of the syscall. We
probably
should have a WEAK_SYSCALL(func) macro.
WEAK_SYSCALL(sys_ptrace);
int
foo_sys_ptrace(struct lwp *l, void *v, register_t *retval)
{
#if defined(PTRACE) || defined(_LKM)
#ifdef _LKM
if (sys_ptrace == NULL)
return ENOSYS;
#endif
...
...
#else
return ENOSYS;
#endif /* PTRACE || _LKM */
}