Complete.Org: Mailing Lists: Archives: linux-help: June 2000:
[linux-help] Re: Blood and Guts
Home

[linux-help] Re: Blood and Guts

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: linux-help@xxxxxxxxx
Subject: [linux-help] Re: Blood and Guts
From: Jeff <schaller@xxxxxxxxxxxxx>
Date: Wed, 7 Jun 2000 14:31:05 -0500 (CDT)
Reply-to: linux-help@xxxxxxxxx

On Wed, 7 Jun 2000, Lrs v.d.Ast wrote:

> extern ssize_t __write __P ((int __fd, __const __ptr_t __buf, size_t __n));
> extern ssize_t write __P ((int __fd, __const __ptr_t __buf, size_t __n));
> 
> I understand extern to allow globally declared stuff to not
> step on each other, hence ssize_t is declared as a global in
> some other file, right?

Nope.
'extern' means the function is defined somewhere else. It tells
the compiler "I'm gonna use this function, but I'm not gonna
define it -- you'll know about it time, trust me".

ssize_t is the return type of the function, and should be defined
by this point in the compilation process, probably by a #define or
#include earlier.

> I'm confused by how ssize_t is followed by a __write (or
> write) but then a space then __P then double parentheses!
> What's going on here? 

__write and write are the function names.
__P is a macro, I believe defined in /usr/include/glob.h (maybe
other places) that affect the behavior of the compiler -- whether
you're compiling C++ or C code. The double parens are necessary to
protect the macro definition, and then end up with one set of
parens for the legal function definition.

> I guess __P is the real write function, embedded in the
> __write function? 

No, see above.

> Also, what is the convention for this double underscore stuff?

Functions that start with double underscore are typically
library-level functions that you wouldn't normally call directly.

> And finally, where is the code where my
> write() function actually gets done?

Well, my return question would be, "why do you care?"  Call
printf and be happy it goes where it's supposed to ..? Where
it really ends up going is a question you can answer very clearly
for yourself by following the code, just as you have been.


> Hopefully somebody knows and maybe somebody can put me on the
> trail of a book, etc. that will explain some of this blood and
> guts stuff.


There's at least a few books out on "linux kernel internals" and
other C programming ones that should help.


-jeff
-- 
We will have no generalizations. --G.K. Chesterston


-- This is the linux-help@xxxxxxxxx list.  To unsubscribe,
visit http://tmp2.complete.org/cgi-bin/listargate-aclug.cgi


[Prev in Thread] Current Thread [Next in Thread]