* what does __foo means.
@ 2004-12-07 12:45 krishna
2004-12-07 12:54 ` Jan Engelhardt
0 siblings, 1 reply; 7+ messages in thread
From: krishna @ 2004-12-07 12:45 UTC (permalink / raw)
To: Linux Kernel
Hi all,
Can anyone tell me does double underscore before a function mean?
In which scenario a programmer must use it.
Regards,
Krishna Chaitanya
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: what does __foo means.
2004-12-07 12:45 what does __foo means krishna
@ 2004-12-07 12:54 ` Jan Engelhardt
2004-12-07 13:08 ` Josh Boyer
2004-12-07 13:11 ` bert hubert
0 siblings, 2 replies; 7+ messages in thread
From: Jan Engelhardt @ 2004-12-07 12:54 UTC (permalink / raw)
To: krishna; +Cc: Linux Kernel
>Hi all,
>
> Can anyone tell me does double underscore before a function mean?
> In which scenario a programmer must use it.
>From the POV of a compiler, _ is like [a-z]. The programmer may use it freely.
Jan Engelhardt
--
ENOSPC
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: what does __foo means.
2004-12-07 12:54 ` Jan Engelhardt
@ 2004-12-07 13:08 ` Josh Boyer
2004-12-07 13:11 ` bert hubert
1 sibling, 0 replies; 7+ messages in thread
From: Josh Boyer @ 2004-12-07 13:08 UTC (permalink / raw)
To: Jan Engelhardt; +Cc: krishna, Linux Kernel
On Tue, 2004-12-07 at 06:54, Jan Engelhardt wrote:
> >Hi all,
> >
> > Can anyone tell me does double underscore before a function mean?
> > In which scenario a programmer must use it.
>
> From the POV of a compiler, _ is like [a-z]. The programmer may use it freely.
Yes, yes, but I don't think that was the question :).
In the kernel a function that begins with __ usually denotes an internal
function for that file or subsystem. Not always, but usually.
josh
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: what does __foo means.
2004-12-07 12:54 ` Jan Engelhardt
2004-12-07 13:08 ` Josh Boyer
@ 2004-12-07 13:11 ` bert hubert
2004-12-07 15:29 ` Jörn Engel
1 sibling, 1 reply; 7+ messages in thread
From: bert hubert @ 2004-12-07 13:11 UTC (permalink / raw)
To: Jan Engelhardt; +Cc: krishna, Linux Kernel
On Tue, Dec 07, 2004 at 01:54:25PM +0100, Jan Engelhardt wrote:
> >Hi all,
> >
> > Can anyone tell me does double underscore before a function mean?
> > In which scenario a programmer must use it.
>
> From the POV of a compiler, _ is like [a-z]. The programmer may use it freely.
Nonsense. The _ is used to provide for a new namespace, __ for a second one.
It is common to have a public function 'foo()' which does lots of error
checking and has a stable api. foo() in turn calls _foo() to do the actual
work, perhaps doing additional checking and verification.
The _namespace is bound by certain rules, some of which apply to the kernel
as well. The compiler is free to output symbols in the _Namespace, as well
as in the __namespace.
"To get specific, identifiers with two leading underscores are reserved for
the compiler as well as identifiers beginning with a single underscore and
using an upper case alphabetic character for the second. "
The linux kernel breaks this by using __ for even more private things.
I don't have K&R handy to check this. We might have some more liberty
because we do not link in libc.
--
http://www.PowerDNS.com Open source, database driven DNS Software
http://lartc.org Linux Advanced Routing & Traffic Control HOWTO
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: what does __foo means.
2004-12-07 13:11 ` bert hubert
@ 2004-12-07 15:29 ` Jörn Engel
0 siblings, 0 replies; 7+ messages in thread
From: Jörn Engel @ 2004-12-07 15:29 UTC (permalink / raw)
To: bert hubert, Jan Engelhardt, krishna, Linux Kernel
On Tue, 7 December 2004 14:11:22 +0100, bert hubert wrote:
>
> Nonsense. The _ is used to provide for a new namespace, __ for a second one.
> It is common to have a public function 'foo()' which does lots of error
> checking and has a stable api. foo() in turn calls _foo() to do the actual
> work, perhaps doing additional checking and verification.
>
> The _namespace is bound by certain rules, some of which apply to the kernel
> as well. The compiler is free to output symbols in the _Namespace, as well
> as in the __namespace.
>
> "To get specific, identifiers with two leading underscores are reserved for
> the compiler as well as identifiers beginning with a single underscore and
> using an upper case alphabetic character for the second. "
>
> The linux kernel breaks this by using __ for even more private things.
C99:
"All identifiers that begin with an underscore and either an uppercase
letter or another underscore are always reserved for any use."
That applies to normal userspace programs. It allows compiler, libc
and possibly the kernel to introduce new identifiers without breaking
existing programs. If programs break, it is their fault, they
shouldn't have used such identifiers.
The kernel is quite different. Basically, all identifiers belong to
the kernel, none to libc/gcc (with very few exceptions). So
developers are free to use that at their pleasure and most stick to
your description in the first paragraph.
Jörn
--
You cannot suppose that Moliere ever troubled himself to be original in the
matter of ideas. You cannot suppose that the stories he tells in his plays
have never been told before. They were culled, as you very well know.
-- Andre-Louis Moreau in Scarabouche
^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <fa.gd7ov5r.1n64a8t@ifi.uio.no>]
* Re: what does __foo means.
[not found] <fa.gd7ov5r.1n64a8t@ifi.uio.no>
@ 2004-12-07 15:52 ` Bodo Eggert
2004-12-07 22:52 ` Kyle Moffett
0 siblings, 1 reply; 7+ messages in thread
From: Bodo Eggert @ 2004-12-07 15:52 UTC (permalink / raw)
To: krishna, linux-kernel
krishna wrote:
> Hi all,
>
> Can anyone tell me does double underscore before a function mean?
> In which scenario a programmer must use it.
---http://www.mozilla.org/hacking/portable-cpp.html---
According to the C++ Standard, 17.4.3.1.2 Global Names [lib.global.names],
paragraph 1:
Certain sets of names and function signatures are always reserved to the
implementation:
Each name that contains a double underscore (__) or begins with an
underscore followed by an uppercase letter (2.11) is reserved to the
implemenation for any use.
Each name that begins with an underscore is reserved to the implementation
for use as a name in the global namespace.
---
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: what does __foo means.
2004-12-07 15:52 ` Bodo Eggert
@ 2004-12-07 22:52 ` Kyle Moffett
0 siblings, 0 replies; 7+ messages in thread
From: Kyle Moffett @ 2004-12-07 22:52 UTC (permalink / raw)
To: 7eggert; +Cc: krishna, linux-kernel
On Dec 07, 2004, at 10:52, Bodo Eggert wrote:
> ---http://www.mozilla.org/hacking/portable-cpp.html---
> According to the C++ Standard, 17.4.3.1.2 Global Names
> [lib.global.names],
> paragraph 1:
>
> Certain sets of names and function signatures are always reserved to
> the
> implementation:
> Each name that contains a double underscore (__) or begins with an
> underscore followed by an uppercase letter (2.11) is reserved to the
> implemenation for any use.
> Each name that begins with an underscore is reserved to the
> implementation
> for use as a name in the global namespace.
> ---
The Linux kernel, however, _is_ "the implementation", at least in
kernel space.
Aside from a very few libgcc functions, almost all symbols are
available to
kernel developers, though not all are necessarily a good idea. :-D
Cheers,
Kyle Moffett
-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GCM/CS/IT/U d- s++: a18 C++++>$ UB/L/X/*++++(+)>$ P+++(++++)>$
L++++(+++) E W++(+) N+++(++) o? K? w--- O? M++ V? PS+() PE+(-) Y+
PGP+++ t+(+++) 5 X R? tv-(--) b++++(++) DI+ D+ G e->++++$ h!*()>++$ r
!y?(-)
------END GEEK CODE BLOCK------
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2004-12-07 22:52 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-12-07 12:45 what does __foo means krishna
2004-12-07 12:54 ` Jan Engelhardt
2004-12-07 13:08 ` Josh Boyer
2004-12-07 13:11 ` bert hubert
2004-12-07 15:29 ` Jörn Engel
[not found] <fa.gd7ov5r.1n64a8t@ifi.uio.no>
2004-12-07 15:52 ` Bodo Eggert
2004-12-07 22:52 ` Kyle Moffett
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.