lkml.org 
[lkml]   [2000]   [Jan]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [idea] request_module(const char *fmt, ...);
    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/

    \
     
     \ /
      Last update: 2005-03-22 13:55    [W:0.033 / U:62.184 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site