why gets "invalidate_cache" a const void ptr?

Gedare Bloom gedare at gwmail.gwu.edu
Fri Apr 9 17:43:42 UTC 2010


On Fri, Apr 9, 2010 at 1:05 PM, Thomas Dörfler
<Thomas.Doerfler at embedded-brains.de> wrote:
> Hi,
>
> I just tripped over a strange thing: the "*invalidate_*_cache" functions
> in cpukit/rtems/rtems/include/rtems/cache.h are declared to get a "const
> void *" pointer passed in. IMHO the "const" is wrong, because the
> function may modify the storage where the pointer points to
>
Is there a case where this happens?

> Background:
> 1.) when a cache line is invalidated, the real memory behind it may
> become visible and have a different content than available in the cache
> previously.
>
Yes, that is probably why the line was invalidated.

> 2.) Having that function to get a "const void *" allos GCC to use more
> optimizations, which may result in wrong code.
>
Are there examples of gcc optimizations that act on pointer to const?
Having const enforces code paths in the cache_invalidate family to not
attempt to write-back data to the address, I think this is expected
behavior when someone invalidates a cache line.
-Gedare

> what do you all think?
>
> I would vote to remove the "const" keyword in the declaration and the
> implementations of the functions.
> wkr,
> Thomas.
>
> --
>
> --------------------------------------------
> Embedded Brains GmbH
> Thomas Doerfler        Obere Lagerstrasse 30
> D-82178 Puchheim       Germany
> email: Thomas.Doerfler at embedded-brains.de
> Phone: +49-89-18908079-2
> Fax:   +49-89-18908079-9
> _______________________________________________
> rtems-users mailing list
> rtems-users at rtems.org
> http://www.rtems.org/mailman/listinfo/rtems-users
>



More information about the users mailing list