* Uwe Hermann uwe@hermann-uwe.de [070701 00:57]:
On Sun, Jul 01, 2007 at 12:46:04AM +0200, Stefan Reinauer wrote:
-/* Most GCC versions have a nasty bug with empty initializers */ -#if (__GNUC__ > 2) -typedef struct { } spinlock_t; -#define SPIN_LOCK_UNLOCKED (spinlock_t) { } -#else -typedef struct { int gcc_is_buggy; } spinlock_t; -#define SPIN_LOCK_UNLOCKED (spinlock_t) { 0 } -#endif
ACK. Sending a similar patch was already on my TODO list. We don't care about gcc <= 3, I guess.
Check the code, it will work on pre v3 like a charme. I don't know what those Linux guys must have been smoking, but I better don't try it.
#define spin_unlock(lock) do {} while(0) +#define spin_define(lock) /* empty */
Why not this? #define spin_define(lock) do {} while(0)
Haha. I had this first. But a do .. while construct outside a function scope is nothing gcc (or any other compiler) would handle :-)
+#define spin_define(spin) static struct spinlock spin = SPIN_LOCK_UNLOCKED
Uh, that looks like an inline function might be better here.
Not sure I get what you mean.. This one defines a (file) global variable.