[PATCH][2.5.73] restore UP spinlock workaround for gcc-2.95.3

Mikael Pettersson (mikpe@csd.uu.se)
Mon, 23 Jun 2003 15:48:07 +0200 (MEST)


[Sent to Linus and Andi, forgot to cc: lkml]

This patch reverts Andi's change to include/linux/spinlock.h
which made gcc-2.95 use empty structs and empty initializers for
spinlocks on UP. gcc-2.95.3 requires the workaround. Please apply.

A short boot-rebuild-kernel-reboot cycle with 2.5.73 compiled
with gcc-2.95.3 resulted in five "Unitialized timer!" stack
traces on my P4, the first three during boot+init. Recompiling
with gcc-3.2.2, or with 2.95.3 and Andi's patch reverted,
eliminated these problems.

At least on x86 gcc-2.95.3 compiles faster and generates smaller
object code than 3.x.y for at lot of us, so I'd prefer to restore
the workaround rather than deprecating 2.95.3.

/Mikael

--- linux-2.5.73/include/linux/spinlock.h.~1~ 2003-06-23 13:07:39.000000000 +0200
+++ linux-2.5.73/include/linux/spinlock.h 2003-06-23 13:46:09.000000000 +0200
@@ -146,8 +146,13 @@
/*
* gcc versions before ~2.95 have a nasty bug with empty initializers.
*/
-typedef struct { } spinlock_t;
-#define SPIN_LOCK_UNLOCKED (spinlock_t) { }
+#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

/*
* If CONFIG_SMP is unset, declare the _raw_* definitions as nops
-
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/