gettimeofday seconds rollover problem?

Pavel Pisa ppisa4lists at pikron.com
Tue Feb 28 08:19:06 UTC 2006


On Tuesday 28 February 2006 08:23, Thomas Doerfler (nt) wrote:
> >   loc_var=AS_VOLATILE(*glob_var_ptr)
> >   loc_var=AS_VOLATILE(glob_var)
> >
> >   AS_VOLATILE(*glob_var_ptr)=loc_var
>
> Shouldn't it be something like this:
>
> #define AS_VOLATILE(x) (*(volatile typeof(&(x)))(&(x)))

:-) Late night syndrome stroked me again, thanks.

> Apart from the missing "volatile", I think this construct has nice
> features. It will mark, which accesses are really required to be "safe".
> The disadvantage is, that all the locations using
> interrupt_disable/enable are required to be revised.
>
> Therefore I would tend again to use the "memory barrier" method as it is
> more robust (with the disadvantage of loosing some performance).

I am personally voting for and prefer barriers all the time.
But because there are some concerns about that solution,
I am trying to to think and disturb others peace in other
directions as well.

To remind, my vote is to add missing "cc" into 
m68k_enable_interrupts and use Till Straumann's idea

      #define _ISR_Disable( _level ) \
              do { _CPU_ISR_Disable( _level ); \
              asm volatile("":::"memory"); } while(0)

      #define _ISR_Enable( _level ) \
              do { asm volatile("":::"memory"); \
              _CPU_ISR_Enable(); } while(0)

      #define _ISR_Flash( _level ) \
              do { asm volatile("":::"memory"); \
              _CPU_ISR_Flash( _level ); \
              asm volatile("":::"memory"); } while(0)

May be, the  construct
  asm volatile("":::"memory")
should be hidden by some macro to leave code portable to non-GCC
compilers. It should be something like _CPU/_SCORE_LOCAL_MEMORY_BARRIER().
It should be evident, that it is not equivalent to physical memory barriers
required for ensuring coherence in MP/DMA/coprocessor cases on the most
of the targets.

Best wishes

              Pavel Pisa




More information about the users mailing list