This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: code optimizations


>>>>> "Trenton" == Trenton D Adams <tadams@theone.dnsalias.com> writes:

    Trenton> Does it matter whether voltatile or unsigned goes first?
    Trenton> Because I'm still getting the jumping around with
    Trenton> (unsigned volatile)

Yes, it matters:

    volatile unsigned*	ptr_to_volatile_uint;

This declares a pointer to a volatile memory location. The pointer
itself will not change at the whim of the hardware, but the memory
location may. Usually this is what is required.

    unsigned volatile* volatile_ptr_to_uint;
    unsigned *volatile volatile_ptr_to_uint;

These declare a volatile pointer to a non-volatile memory location.
The memory location will not change at the whim of the hardware, but
the pointer may change at any time. This is less common, an example
might be a DMA controller where one of the registers points at memory.

    volatile unsigned volatile* volatile_ptr_to_volatile_uint;

The pointer may change at any time, and so can the memory location
pointed out. Very unusual.

This is why I specified (volatile unsigned *) in my message, not
the (unsigned volatile*) which you have used.

>>>>> "Trenton" == Trenton D Adams <tadams@theone.dnsalias.com> writes:

    Trenton> Screw optimizations. My CDL thing did work, and I changed
    Trenton> to -O0. This didn't have any affect on whether my driver
    Trenton> works or not as was suggested by some people a few weeks
    Trenton> ago! :(

It may work with the current compiler. It may or may not work with the
next version of the compiler, even at -O0. I am not aware of any
compiler work going on that would stop it working at -O0. However if
you are not using volatile correctly when accessing hardware registers
then the source code is broken, and you cannot depend on the compiler
generating code that behaves the way you would like it to.

Bart


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]