Commit 1f972505 authored by Steven Rostedt (VMware)'s avatar Steven Rostedt (VMware) Committed by Greg Kroah-Hartman

locking/qspinlock: Fix build for anonymous union in older GCC compilers

[ Upstream commit 6cc65be4 ]

One of my tests compiles the kernel with gcc 4.5.3, and I hit the
following build error:

  include/linux/semaphore.h: In function 'sema_init':
  include/linux/semaphore.h:35:17: error: unknown field 'val' specified in initializer
  include/linux/semaphore.h:35:17: warning: missing braces around initializer
  include/linux/semaphore.h:35:17: warning: (near initialization for '(anonymous).raw_lock.<anonymous>.val')

I bisected it down to:

 625e88be ("locking/qspinlock: Merge 'struct __qspinlock' into 'struct qspinlock'")

... which makes qspinlock have an anonymous union, which makes initializing it special
for older compilers. By adding strategic brackets, it makes the build
happy again.
Signed-off-by: default avatarSteven Rostedt (VMware) <>
Acked-by: default avatarWaiman Long <>
Cc: Andrew Morton <>
Cc: Boqun Feng <>
Cc: Linus Torvalds <>
Cc: Peter Zijlstra (Intel) <>
Cc: Peter Zijlstra <>
Cc: Thomas Gleixner <>
Cc: Will Deacon <>
Fixes: 625e88be ("locking/qspinlock: Merge 'struct __qspinlock' into 'struct qspinlock'")
Link: default avatarIngo Molnar <>
Signed-off-by: default avatarSasha Levin <>
parent 12f75e8a
......@@ -63,7 +63,7 @@ typedef struct qspinlock {
* Initializier
#define __ARCH_SPIN_LOCK_UNLOCKED { { .val = ATOMIC_INIT(0) } }
* Bitfields in the atomic value:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment