Anubhav Hanjura wrote:

> I was just wondering, how is the case of variable arguments eg. in
> printf/scanf etc. implemented in linux? 

The function call is compiled in the same way as any other functions,
i.e. the function's arguments are pushed onto the stack, from right to
left (so that the first argument is at the lowest address).

The arguments are referenced using the va_* macros, which are defined
in the file

        /usr/lib/gcc-lib/<platform>/<version>/include/stdarg.h

e.g.

        /usr/lib/gcc-lib/i586-pc-linux-gnu/2.8.1/include/stdarg.h

for a standard installation of gcc 2.8.1 for glibc-2 on an i586.

> Also please suggest any good book on Unix/Linux internals.

There are a couple of online references for the Linux kernel available
from the LDP homepage (http://sunsite.unc.edu/LDP/linux.html),
specifically `The Linux Kernel' (tlk) and `The Kernel Hacker's Guide'
(khg).

For details of generic Unix implementation, there's the book

        The Design of the Unix(R) Operating System
        Maurice J Bach
        Prentice-Hall

-- 
Glynn Clements <[EMAIL PROTECTED]>

Reply via email to