Date: Tue, 17 Jun 1997 00:19:42 +0900 From: Shigio Yamaguchi <shigio@wafu.netgate.net> To: freebsd-hackers@FreeBSD.ORG Cc: shigio@wafu.netgate.net Subject: an inconvenience about macro [/usr/src/sys/sys/kernel.h] Message-ID: <199706160722.HAA10719@wafu.netgate.net>
next in thread | raw e-mail | index | archive | help
Hello hackers.
I found an inconvenience in kernel source. (It is not a bug.)
What do you think?
---------------------------------------------------------------------------
Inconvenience about Macro
---------------------------------------------------------------------------
In /usr/src/sys/kern/init_main.c, SYSINIT macro is used. It is like this.
[/usr/src/sys/kern/init_main.c]
SYSINIT(placeholder, SI_SUB_DUMMY,SI_ORDER_ANY, NULL, NULL)
SYSINIT doesn't end with ';', because the definition already has it.
[/usr/src/sys/sys/kern.h]
#define SYSINIT(uniquifier, subsystem, order, func, ident) \
static struct sysinit uniquifier ## _sys_init = { \
subsystem, \
order, \
func, \
ident, \
SI_TYPE_DEFAULT \
}; \
DATA_SET(sysinit_set,uniquifier ## _sys_init);
^
|
END WITH ';'
But ctags(1) cannot treat this pattern.
For example, in these code
[/usr/src/sys/kern/init_main.c]
SYSINIT(placeholder, SI_SUB_DUMMY,SI_ORDER_ANY, NULL, NULL) ... (a)
.....
void
main(framep) ... (b)
void *framep;
{
.....
} ... (c)
Ctags(1) assumes SYSINIT start at (a) and end at (c). As the result that
main() functin is skipped.
I think the definition of SYSINIT should not end with ';' and the referenced
point should end with ';' like this.
SYSINIT(placeholder, SI_SUB_DUMMY,SI_ORDER_ANY, NULL, NULL);
By the way, in the same source file(/usr/src/sys/sys/kern.h), MAKE_SET's code
is good.
[/usr/src/sys/sys/kern.h]
#define MAKE_SET(set, sym, type) \
static void const * const __set_##set##_sym_##sym = &sym; \
asm(".stabs \"_" #set "\", " #type ", 0, 0, _" #sym)
In this macro, the first statement ends with ';' and the second (=last)
statement doesn't end with ';'. It should be so.
--
Shigio Yamaguchi (Freelance programmer)
Mail: shigio@wafu.netgate.net, WWW: http://wafu.netgate.net/tama/
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199706160722.HAA10719>
