Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #26893

Re: How to name a function to indicate that they require calling from a critical section?

From Stephen Sprunk <stephen@sprunk.org>
Newsgroups comp.lang.c
Subject Re: How to name a function to indicate that they require calling from a critical section?
Date 2012-09-30 13:45 -0500
Organization A noiseless patient Spider
Message-ID <k4a3vv$9d7$1@dont-email.me> (permalink)
References (1 earlier) <GhVUr.1067102$3s1.72445@fx12.am4> <lnr4rfvl3q.fsf@nuthaus.mib.org> <kfnk3w5kfne.fsf@x-alumni2.alumni.caltech.edu> <k2dnbm$rab$1@dont-email.me> <aavmtqFok6U5@mid.individual.net>

Show all headers | View raw


On 07-Sep-12 20:56, Ian Collins wrote:
> On 09/ 8/12 09:01 AM, Stephen Sprunk wrote:
>> On 07-Sep-12 10:37, Tim Rentsch wrote:
>>> Keith Thompson<kst-u@mib.org>  writes:
>>> And, even if [the kernel] were [part of the implementation], it
>>> is not part of implementations running on other operating systems
>>> (eg MS windows or MacOS), yet presumably it's expected to be
>>> compileable some such environments, so it's still breaking the
>>> rules regarding reserved identifiers.
>> 
>> The Linux kernel is only expected to be compilable by GCC, and 
>> successfully compiling the Linux kernel is a gate in the GCC 
>> release process, so the two are intimately tied together.
>> 
>> I would expect the same of Windows and MSVC, etc.  Kernels are 
>> special.
> 
> Not necessarily. One of the early tasks when the Solaris kernel was 
> open-sourced was to get it to compile cleanly with gcc as well as the
> native compiler.  This took a while, but in the process removed a lot
> of cruft from the source.  Just like any other code base, being able
> to compile with more than one compiler is a good way to improve and
> maintain code quality.

I agree that making code portable tends to increase quality, but that's
not really the point.

> From my occasional exposure to it, my impression is the Linux kernel
> is a lost cause when it comes to compiler portability!

Probably.  I'll note that the ICC folks chose to copy GCC's "features"
rather than change the Linux kernel source itself to be more portable.
I don't know what drove that decision, nor am I qualified to judge
whether the kernel developers are justified in the use of said
"features" in the first place, since they're obviously more skilled than
I am.

> Due to their size and reliance on high levels of optimisation, 
> kernels are more susceptible than most applications to compiler
> bugs.

I don't think it's bugs per se but that kernels, by their nature, tend
to rely on behaviors that the Standard does not (and cannot) guarantee,
which means they become tied to the particular compiler(s) used to
compile them.

IMHO, the ability to write both portable and non-portable code in the
same language is one of C's strengths--and a reason for its enduring
success.  However, it takes discipline to segregate the two types of
code, which apparently many people (including those who write books)
seem to be lacking.

S

-- 
Stephen Sprunk         "God does not play dice."  --Albert Einstein
CCIE #3723         "God is an inveterate gambler, and He throws the
K5SSS        dice at every possible opportunity." --Stephen Hawking

Back to comp.lang.c | Previous | Next — Previous in thread | Find similar | Unroll thread


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