Hi guys,
I think I have a solution to the variable-length macro
:
if you define an empty macro for request_module, this
line :
request_module("blah","blah2","foobar");
will be converted to :
("blah","blah2","foobar");
which is treated by the compiler as useless code and
will no even generate one byte of code.
Here is a looser example which works :
#ifndef ENABLE
#define test_func
#else
#define test_func myfunc
int myfunc(char *fmt, ...) {
return *fmt;
}
#endif
main() {
test_func("azerazer","aerazerazer");
}
when compiled with gcc -S -O2 -DENABLE, you'll get
this output :
.text
.align 4
.globl myfunc
.type myfunc,@function
myfunc:
pushl %ebp
movl %esp,%ebp
movl 8(%ebp),%eax
movsbl (%eax),%eax
leave
ret
.Lfe1:
.size myfunc,.Lfe1-myfunc
.section .rodata
.LC0:
.string "aerazerazer"
.LC1:
.string "azerazer"
.text
.align 4
.globl main
.type main,@function
main:
pushl %ebp
movl %esp,%ebp
pushl $.LC0
pushl $.LC1
call myfunc
leave
ret
But when compiled with gcc -O2 -S test.c, you get this
shorter code :
.text
.align 4
.globl main
.type main,@function
main:
pushl %ebp
movl %esp,%ebp
leave
ret
I think this is perfectly usable, any comments ?
Willy
___________________________________________________________
Do You Yahoo!?
Achetez, vendez! À votre prix! Sur http://encheres.yahoo.fr
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/
This archive was generated by hypermail 2b29 : Sat Jan 15 2000 - 21:00:24 EST