Messages in this thread | | | Date | Fri, 29 Aug 2003 17:24:18 +0200 | From | Antonio Vargas <> | Subject | Re: [2.4] gcc3 warns about type-punned pointers ? |
| |
On Fri, Aug 29, 2003 at 12:35:11AM +0200, J.A. Magallon wrote: > Hi all... > > gcc3 gives this warning when using the __set_64bit_var function: > > /usr/src/linux/include/asm/system.h:190: warning: dereferencing type-punned pointer will break strict-aliasing rules > > Is it a potential problem ? > > This seems to cure it: > > --- linux-2.4.22-jam1m/include/asm-i386/system.h.orig 2003-08-29 00:26:41.000000000 +0200 > +++ linux-2.4.22-jam1m/include/asm-i386/system.h 2003-08-29 00:26:55.000000000 +0200 > @@ -181,8 +181,8 @@ > { > __set_64bit(ptr,(unsigned int)(value), (unsigned int)((value)>>32ULL)); > } > -#define ll_low(x) *(((unsigned int*)&(x))+0) > -#define ll_high(x) *(((unsigned int*)&(x))+1) > +#define ll_low(x) *(((unsigned int*)(void*)&(x))+0) > +#define ll_high(x) *(((unsigned int*)(void*)&(x))+1) > > static inline void __set_64bit_var (unsigned long long *ptr, > unsigned long long value) > > A collateral question: why is the reason for this function ? > long long assignments are not atomic in gcc ?
On x86, long long int == 64 bits but the chip is 32 bits wide, so it uses 2 separate memory accesses. There are 64bit-wide instructions which do bus-locking so that the are atomic, but gcc will not use them directly.
( info nasm and look up "cmpxchg8b" and related friends)
Greets, Antonio.
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |