Re: Attribute const and inline functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2014-02-24 16:07, David Brown wrote:
extern const int const_var;
>
>GCC will read the value of const_var again after a compiler memory
>barrier (e.g. __asm__ volatile("" ::: "memory")).
That's the rules - a "memory clobber" says that/any/  memory may change,
and things read from memory could change and must therefore be re-read.
  Specifying the extern var as "const" does not tell the compiler that
the value is constant - it simply tells the compiler that/you/  promise
not to change it.  (It would be nice if C, or at least gcc, had a way to
say that the value is never changed, but it does not.)

These variables go into the .rodata section. It seems a bit over paranoid to assume that they change. In my case the .rodata section is a read-only region covering a NOR flash, so its unlikely to change.

--
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber@xxxxxxxxxxxxxxxxxx
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux