Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Eric Sosman <esosman@ieee-dot-org.invalid> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: How to name a function to indicate that they require calling from a critical section? |
| Date | 2012-08-09 18:22 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <k01d7g$n4m$1@dont-email.me> (permalink) |
| References | <12497759-f557-4c9a-a4f4-7bcf177b251d@googlegroups.com> <GhVUr.1067102$3s1.72445@fx12.am4> <lnr4rfvl3q.fsf@nuthaus.mib.org> <DAWUr.852233$1o5.350073@fx03.am4> |
On 8/9/2012 6:11 PM, Andrew Cooper wrote:
> On 09/08/2012 21:58, Keith Thompson wrote:
>> [...]
>> Identifiers starting with two underscores, or with an underscore and an
>> uppercase letter, are reserved to the implementation; if you define such
>> an identifer yourself, the behavior is undefined.
>>
>> (The kernel is arguably part of the implementation, and even if it
>> isn't, it's probably ok for the developers to rely on certain behaviors
>> that aren't defined by the language standard.)
>>
>
> I doubt anyone could make a functional kernel while strictly adhering to
> non UD behaviour. There is "what the standard states" and "what
> basically universally works".
If you hadn't said "universally" I'd have agreed with you,
more or less. But it is *not* universally true that you're
free to start your identifiers with __ and have things "work."
Even if you can get away with the particular set of __xxx you
use today with the particular compiler and options you use today,
you may find yourself in trouble tomorrow when you upgrade to the
next compiler version or invent a new identifier or even #include
a new header.
Example: Try this in gcc:
#include <stdio.h>
static const char *whom(void) {
return "World";
}
int main(void) {
printf("Hello, %s!\n", whom());
}
Everything working? Okay, now change the identifier `whom' to
`__attribute__'.
> Having said that, because of narrow architecture targets of kernels, you
> can perhaps rely substantially more on "what will work" while strictly
> being UD.
Agreed that you can -- indeed, must -- rely on a lot of things
the C language itself does not guarantee. But adopting a dubious
naming convention (when there are plenty of others available) is
begging for trouble just for the thrill of begging.
--
Eric Sosman
esosman@ieee-dot-org.invalid
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How to name a function to indicate that they require calling from a critical section? celephicus@gmail.com - 2012-08-08 18:55 -0700
Re: How to name a function to indicate that they require calling from a critical section? Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-08-09 08:31 -0400
Re: How to name a function to indicate that they require calling from a critical section? "China Blue [Tor], Meersburg" <chine.bleu@yahoo.com> - 2012-08-09 12:24 -0700
Re: How to name a function to indicate that they require calling from a critical section? Keith Thompson <kst-u@mib.org> - 2012-08-09 13:59 -0700
Re: How to name a function to indicate that they require calling from a critical section? Andrew Cooper <amc96@cam.ac.uk> - 2012-08-09 21:43 +0100
Re: How to name a function to indicate that they require calling from a critical section? Keith Thompson <kst-u@mib.org> - 2012-08-09 13:58 -0700
Re: How to name a function to indicate that they require calling from a critical section? Andrew Cooper <amc96@cam.ac.uk> - 2012-08-09 23:11 +0100
Re: How to name a function to indicate that they require calling from a critical section? Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-08-09 18:22 -0400
Re: How to name a function to indicate that they require calling from a critical section? Tim Rentsch <txr@alumni.caltech.edu> - 2012-09-07 08:37 -0700
Re: How to name a function to indicate that they require calling from a critical section? Stephen Sprunk <stephen@sprunk.org> - 2012-09-07 16:01 -0500
Re: How to name a function to indicate that they require calling from a critical section? Tim Rentsch <txr@alumni.caltech.edu> - 2012-09-07 18:37 -0700
Re: How to name a function to indicate that they require calling from a critical section? Stephen Sprunk <stephen@sprunk.org> - 2012-09-30 00:17 -0500
Re: How to name a function to indicate that they require calling from a critical section? Tim Rentsch <txr@alumni.caltech.edu> - 2012-12-17 14:24 -0800
Re: How to name a function to indicate that they require calling from a critical section? Ian Collins <ian-news@hotmail.com> - 2012-09-08 13:56 +1200
Re: How to name a function to indicate that they require calling from a critical section? Stephen Sprunk <stephen@sprunk.org> - 2012-09-30 13:45 -0500
csiph-web