On Mon, Sep 16, 2013 at 6:08 AM, Rusty Russell <ru...@rustcorp.com.au> wrote: > Predates git, does anyone remember the rationale? > > ie: > int test_bit(int nr, const volatile unsigned long *addr)
That's why we have full-history-linux ;-) Unfortunately it doesn't show the rationale, as this change also predates bitkeeper. Since 2.1.30, volatile is used unconditionally: commit 84d59b7dda1092a22663f4e2da77a6ce581b539e Author: linus1 <torva...@linuxfoundation.org> Date: Mon Mar 10 12:00:00 1997 -0600 Import 2.1.30 #ifdef __SMP__ #define LOCK_PREFIX "lock ; " -#define SMPVOL volatile #else #define LOCK_PREFIX "" -#define SMPVOL #endif /* * This routine doesn't need to be atomic. */ -extern __inline__ int test_bit(int nr, const SMPVOL void * addr) +extern __inline__ int __constant_test_bit(int nr, const volatile void * addr) { - return ((1UL << (nr & 31)) & (((const unsigned int *) addr)[nr >> 5])) ! + return ((1UL << (nr & 31)) & (((const volatile unsigned int *) addr)[nr } +extern __inline__ int __test_bit(int nr, volatile void * addr) +{ + int oldbit; + + __asm__ __volatile__( + "btl %2,%1\n\tsbbl %0,%0" + :"=r" (oldbit) + :"m" (ADDR),"ir" (nr)); + return oldbit; +} + +#define test_bit(nr,addr) \ +(__builtin_constant_p(nr) ? \ + __constant_test_bit((nr),(addr)) : \ + __test_bit((nr),(addr))) + /* Between 1.3.75 and 2.1.30, volatile was used on SMP only: commit 08c5b9d698e6ca2233aec0f7d7f0fdd6eb3ad235 Author: linus1 <torva...@linuxfoundation.org> Date: Thu Mar 7 12:00:00 1996 -0600 Import 1.3.75 #ifdef __SMP__ #define LOCK_PREFIX "lock ; " +#define SMPVOL volatile #else #define LOCK_PREFIX "" +#define SMPVOL #endif /* * This routine doesn't need to be atomic. */ -extern __inline__ int test_bit(int nr, const void * addr) +extern __inline__ int test_bit(int nr, const SMPVOL void * addr) { return 1UL & (((const unsigned int *) addr)[nr >> 5] >> (nr & 31)); } Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/