linux kernel c code

S

slurper

i encounter regularly in the linux source code signatures like this:

static void __init do_initcalls(void)
{
definition(whatever)
}

"__init" en "do_initcalls" are two different words. how must one interpret
this? i don't understand a function definition with two separate words.
anybody can explain me this?
 
J

Jens.Toerring

slurper said:
i encounter regularly in the linux source code signatures like this:
static void __init do_initcalls(void)
{
definition(whatever)
}
"__init" en "do_initcalls" are two different words. how must one interpret
this? i don't understand a function definition with two separate words.
anybody can explain me this?

You shouldn't expect things like kernels to be clean, standard
conforming C - lots and lots of non-portable, compiler-dependend
extensions are typically used. A place where this kind of questions
is on-topic is e.g. comp.os.linux.development.system, here in clc
they are heavily frowned upon since they are compiler- and platform
dependend. In "clean" C the only possibility I can see at the moment
to make that __init stuff at least halfway legal would be by having
a define somewhere before like

#define __init

i.e. by making it invisible or with

#define __init *

(but in this case you would also have to change the function to make
it return a void pointer;-)

<OT>
To satisfy you're curiosity have a look at the init.h header file
in the kernel sources - you will find that __init is defined as
some gcc-supplied extension, a function attribute, which gives
the compiler some additional hints on how the function is going
to be used - nothing you can do in standard C.
</OT>
Regards, Jens
 
E

Erik de Castro Lopo

slurper said:
i encounter regularly in the linux source code signatures like this:

static void __init do_initcalls(void)
{
definition(whatever)
}

"__init" en "do_initcalls" are two different words. how must one interpret
this? i don't understand a function definition with two separate words.
anybody can explain me this?

This newsgroups is really about ISO standard C and the above is not ISO
standard C.

However, __init is explained a little about 3/4 of the way doen this
page (found by searching google):

http://www.faqs.org/docs/kernel_2_4/lki-1.html

Erik
--
+-----------------------------------------------------------+
Erik de Castro Lopo (e-mail address removed) (Yes it's valid)
+-----------------------------------------------------------+
"It's not that perl programmers are idiots, it's that the
language rewards idiotic behavior in a way that no other
language or tool has ever done." -- Erik Naggum
 
C

CBFalconer

.... snip ...

<OT>
To satisfy you're curiosity have a look at the init.h header file
in the kernel sources - you will find that __init is defined as

While your English is generally excellent, this usage is wrong.
"you're" is an abbreviation for "you are", while "your" is the
possessive. If you don't want to hear it, my apologies and I will
try to remember not to do it again.
 
J

James McIninch

<posted & mailed>
i encounter regularly in the linux source code signatures like this:

static void __init do_initcalls(void)
{
definition(whatever)
}

"__init" en "do_initcalls" are two different words. how must one interpret
this? i don't understand a function definition with two separate words.
anybody can explain me this?

Not that it has naything to do with Linux, but __init must either be
something compiler specific, or a macro. The declaration above is not using
two words as a function name, the first world is a qualifier just like
'static' and 'void' are. In this particular case, it's a macro that does
something compiler-specific.
 
J

Joona I Palaste

While your English is generally excellent, this usage is wrong.
"you're" is an abbreviation for "you are", while "your" is the
possessive. If you don't want to hear it, my apologies and I will
try to remember not to do it again.

Seeing as countless native English speakers get it wrong too, Jens
Toerring can be excused for mixing up those words.
 
J

Jens.Toerring

Seeing as countless native English speakers get it wrong too, Jens
Toerring can be excused for mixing up those words.

Well, it's nice that CBFalconer tried to help me with that (in
principle I know about the difference, but it still happens
again and again that for some reasons I don't understand I get
them mixed up). Better getting such a thing expained once than
repeating the same stupid mistake over and over again;-)

Regards, Jens
 
J

Joona I Palaste

(e-mail address removed)-berlin.de scribbled the following:
Well, it's nice that CBFalconer tried to help me with that (in
principle I know about the difference, but it still happens
again and again that for some reasons I don't understand I get
them mixed up). Better getting such a thing expained once than
repeating the same stupid mistake over and over again;-)

I'm lucky my native language has a nearly 1-1 correspondence between
writing and pronunciation. One of the best such ones in Europe, in fact.
Thus my knowledge of English spelling is nearly perfect. The downside is
that I don't speak English aloud too well - I have a horrible Finnish
accent.

--
/-- Joona Palaste ([email protected]) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"And according to Occam's Toothbrush, we only need to optimise the most frequent
instructions."
- Teemu Kerola
 
E

Emmanuel Delahaye

Joona I Palaste wrote on 07/08/04 :
Seeing as countless native English speakers get it wrong too, Jens
Toerring can be excused for mixing up those words.

But it's good to know, anyway...
 
C

CBFalconer

Joona said:
Seeing as countless native English speakers get it wrong too, Jens
Toerring can be excused for mixing up those words.

Agreed. By and large non-native English speakers write better
English than natives - after all, they have been taught. Joseph
Conrad is a fine example in the literary world. Europeans have
the advantage that they need to speak more than one language,
while USanians don't.
 
C

CBFalconer

Joona said:
.... snip ...

I'm lucky my native language has a nearly 1-1 correspondence
between writing and pronunciation. One of the best such ones in
Europe, in fact. Thus my knowledge of English spelling is nearly
perfect. The downside is that I don't speak English aloud too
well - I have a horrible Finnish accent.

Hmm. I haven't noticed it. :)
 
D

Dave Thompson

Well, it's nice that CBFalconer tried to help me with that (in
principle I know about the difference, but it still happens
again and again that for some reasons I don't understand I get

Possibly the reason I have seen quite a few native speakers -- well,
here native writers -- have trouble: the possessive of a specific
thing uses apostrophe ess: Fred's house; the machine's capacity, etc.
But those of pronouns do not: your; its; his; her; our; their. I think
I once long ago learned that there is actually a reason for this --
unlike many things in English which are arbitrary or accidental or
even actually wrong but enshrined by long usage -- but I have
forgotten it and in any case the original reason no longer matters;
them mixed up). Better getting such a thing expained once than
repeating the same stupid mistake over and over again;-)
I'm certain, completely certain, you meant "explained".

But "expained", even though it isn't a word, sounds so perfectly
apropos as well as mellifluous that it really *should* be!


- David.Thompson1 at worldnet.att.net
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,145
Messages
2,570,826
Members
47,372
Latest member
LucretiaFo

Latest Threads

Top