Re: Why is the kfree() argument const?

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Linus Torvalds <torvalds@...>
Cc: David Schwartz <davids@...>, Johannes Weiner <hannes@...>, Linux Kernel Mailing List <linux-kernel@...>, <clameter@...>, <penberg@...>
Date: Friday, January 18, 2008 - 4:20 am

And to demostrate that Linus is not the only person
with this view, I copy some paragraphs from C99 rationale
(you can find standard, rationale and other documents
in http://clc-wiki.net/wiki/C_standardisation:ISO )

Page 75 of C99 rationale:

Type qualifiers were introduced in part to provide greater control over optimization. Several
important optimization techniques are based on the principle of "cacheing": under certain
circumstances the compiler can remember the last value accessed (read or written) from a
location, and use this retained value the next time that location is read. (The memory, or
"cache", is typically a hardware register.) If this memory is a machine register, for instance, the
code can be smaller and faster using the register rather than accessing external memory.
The basic qualifiers can be characterized by the restrictions they impose on access and
cacheing:

const          No writes through this lvalue. In the absence of this qualifier, writes may occur
               through this lvalue.

volatile       No cacheing through this lvalue: each operation in the abstract semantics must
               be performed (that is, no cacheing assumptions may be made, since the location
               is not guaranteed to contain any previous value). In the absence of this qualifier,
               the contents of the designated location may be assumed to be unchanged except
               for possible aliasing.

restrict       Objects referenced through a restrict-qualified pointer have a special
               association with that pointer. All references to that object must directly or
               indirectly use the value of this pointer. In the absence of this qualifier, other
               pointers can alias this object. Cacheing the value in an object designated through
               a restrict-qualified pointer is safe at the beginning of the block in which the
               pointer is declared, because no pre-existing aliases may also be used to reference
               that object. The cached value must be restored to the object by the end of the
               block, where pre-existing aliases again become available. New aliases may be
               formed within the block, but these must all depend on the value of the
               restrict-qualified pointer, so that they can be identified and adjusted to refer
               to the cached value. For a restrict-qualified pointer at file scope, the block
               is the body of main.

ciao
	cate
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
RE: Why is the kfree() argument const?, Linus Torvalds, (Thu Jan 17, 5:25 pm)
Re: Why is the kfree() argument const?, Jakob Oestergaard, (Fri Jan 18, 5:48 am)
Re: Why is the kfree() argument const?, Björn, (Fri Jan 18, 9:31 am)
Re: Why is the kfree() argument const?, Jakob Oestergaard, (Fri Jan 18, 10:53 am)
Re: Why is the kfree() argument const?, Giacomo A. Catenazzi, (Fri Jan 18, 7:47 am)
Re: Why is the kfree() argument const?, Vadim Lobanov, (Fri Jan 18, 3:06 pm)
Re: Why is the kfree() argument const?, Jakob Oestergaard, (Fri Jan 18, 10:39 am)
RE: Why is the kfree() argument const?, David Schwartz, (Thu Jan 17, 6:28 pm)
RE: Why is the kfree() argument const?, Linus Torvalds, (Thu Jan 17, 7:10 pm)
RE: Why is the kfree() argument const?, David Schwartz, (Thu Jan 17, 8:56 pm)
RE: Why is the kfree() argument const?, Linus Torvalds, (Thu Jan 17, 9:15 pm)
Re: Why is the kfree() argument const?, Giacomo Catenazzi, (Fri Jan 18, 3:51 am)
Re: Why is the kfree() argument const?, Vadim Lobanov, (Fri Jan 18, 4:30 am)
Re: Why is the kfree() argument const?, Giacomo Catenazzi, (Fri Jan 18, 4:20 am)
Re: Why is the kfree() argument const?, Andy Lutomirski, (Fri Jan 18, 9:54 am)
Re: Why is the kfree() argument const?, Vadim Lobanov, (Fri Jan 18, 3:14 pm)
Re: Why is the kfree() argument const?, Zan Lynx, (Fri Jan 18, 3:31 pm)
Re: Why is the kfree() argument const?, Vadim Lobanov, (Fri Jan 18, 3:55 pm)
Re: Why is the kfree() argument const?, Andy Lutomirski, (Fri Jan 18, 9:53 am)
Re: Why is the kfree() argument const?, Olivier Galibert, (Fri Jan 18, 1:24 pm)
Re: Why is the kfree() argument const?, J.A. , (Fri Jan 18, 6:29 pm)
Re: Why is the kfree() argument const?, Krzysztof Halasa, (Fri Jan 18, 7:44 pm)
RE: Why is the kfree() argument const?, David Schwartz, (Fri Jan 18, 1:02 am)
Re: Why is the kfree() argument const?, DM, (Fri Jan 18, 2:06 pm)
Re: Why is the kfree() argument const?, Olivier Galibert, (Fri Jan 18, 1:37 pm)
RE: Why is the kfree() argument const?, Linus Torvalds, (Fri Jan 18, 12:10 pm)
RE: Why is the kfree() argument const?, David Schwartz, (Fri Jan 18, 4:55 pm)
Re: Why is the kfree() argument const?, Chris Friesen, (Fri Jan 18, 11:38 am)