[PATCH] Fix for asm-alpha/spinlock.h: GCC empty initializer problem

Matthias Welwarsky (matze@stud.fbi.fh-darmstadt.de)
Wed, 11 Nov 1998 22:12:51 +0100


This is a multi-part message in MIME format.
--------------5C9E3153D6B2A7BC60ED13A7
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hello Linus and list,

this patch is basically cut'n'pasted from asm-i386/spinlock.h and makes
parport_share.c compile again. I think the rationale behind the
respective lines in the i386 header file applies to the alpha
architecture, too.

Gruss,
Matthias
--------------5C9E3153D6B2A7BC60ED13A7
Content-Type: text/plain; charset=us-ascii; name="asm_alpha_spinlock_h-2.1.127-1.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="asm_alpha_spinlock_h-2.1.127-1.patch"

--- linux/include/asm-alpha/spinlock.h.orig Wed Nov 11 21:41:07 1998
+++ linux/include/asm-alpha/spinlock.h Wed Nov 11 21:45:38 1998
@@ -5,9 +5,18 @@

#ifndef __SMP__

-/* gcc 2.7.2 can crash initializing an empty structure. */
-typedef struct { int dummy; } spinlock_t;
-#define SPIN_LOCK_UNLOCKED { 0 }
+/*
+ * Your basic spinlocks, allowing only a single CPU anywhere
+ *
+ * Gcc-2.7.x has a nasty bug with empty initializers.
+ */
+#if (__GNUC__ > 2) || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)
+ 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

#define spin_lock_init(lock) ((void) 0)
#define spin_lock(lock) ((void) 0)
@@ -29,9 +38,16 @@
* can "mix" irq-safe locks - any writer needs to get a
* irq-safe write-lock, but readers can get non-irqsafe
* read-locks.
+ *
+ * Gcc-2.7.x has a nasty bug with empty initializers.
*/
-typedef struct { int dummy; } rwlock_t;
-#define RW_LOCK_UNLOCKED { 0 }
+#if (__GNUC__ > 2) || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)
+ typedef struct { } rwlock_t;
+ #define RW_LOCK_UNLOCKED (rwlock_t) { }
+#else
+ typedef struct { int gcc_is_buggy; } rwlock_t;
+ #define RW_LOCK_UNLOCKED (rwlock_t) { 0 }
+#endif

#define read_lock(lock) ((void) 0)
#define read_unlock(lock) ((void) 0)

--------------5C9E3153D6B2A7BC60ED13A7--

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/