Index: generic/include/console/chardev.h
===================================================================
--- generic/include/console/chardev.h	(revision 3fc03fd55a97ee8c78eecc373fec290d6bd547d9)
+++ generic/include/console/chardev.h	(revision dc747e33f6f5d74c7d1b7b50fda3b2fabff8fa82)
@@ -53,5 +53,5 @@
 	
 	waitq_t wq;
-	spinlock_t lock;		/**< Protects everything below. */
+	SPINLOCK_DECLARE(lock);		/**< Protects everything below. */
 	__u8 buffer[CHARDEV_BUFLEN];
 	count_t counter;
Index: generic/include/console/kconsole.h
===================================================================
--- generic/include/console/kconsole.h	(revision 3fc03fd55a97ee8c78eecc373fec290d6bd547d9)
+++ generic/include/console/kconsole.h	(revision dc747e33f6f5d74c7d1b7b50fda3b2fabff8fa82)
@@ -56,5 +56,5 @@
 struct cmd_info {
 	link_t link;			/**< Command list link. */
-	spinlock_t lock;		/**< This lock protects everything below. */
+	SPINLOCK_DECLARE(lock);		/**< This lock protects everything below. */
 	const char *name;		/**< Command name. */
 	const char *description;	/**< Textual description. */
Index: generic/include/cpu.h
===================================================================
--- generic/include/cpu.h	(revision 3fc03fd55a97ee8c78eecc373fec290d6bd547d9)
+++ generic/include/cpu.h	(revision dc747e33f6f5d74c7d1b7b50fda3b2fabff8fa82)
@@ -43,5 +43,5 @@
 
 struct cpu {
-	spinlock_t lock;
+	SPINLOCK_DECLARE(lock);
 	context_t saved_context;
 
@@ -50,5 +50,5 @@
 	volatile count_t needs_relink;
 
-	spinlock_t timeoutlock;
+	SPINLOCK_DECLARE(timeoutlock);
 	link_t timeout_active_head;
 
Index: generic/include/mm/frame.h
===================================================================
--- generic/include/mm/frame.h	(revision 3fc03fd55a97ee8c78eecc373fec290d6bd547d9)
+++ generic/include/mm/frame.h	(revision dc747e33f6f5d74c7d1b7b50fda3b2fabff8fa82)
@@ -55,5 +55,5 @@
 	link_t link;		/**< link to previous and next zone */
 
-	spinlock_t lock;	/**< this lock protects everything below */
+	SPINLOCK_DECLARE(lock);	/**< this lock protects everything below */
 	__address base;		/**< physical address of the first frame in the frames array */
 	frame_t *frames;	/**< array of frame_t structures in this zone */
Index: generic/include/mm/vm.h
===================================================================
--- generic/include/mm/vm.h	(revision 3fc03fd55a97ee8c78eecc373fec290d6bd547d9)
+++ generic/include/mm/vm.h	(revision dc747e33f6f5d74c7d1b7b50fda3b2fabff8fa82)
@@ -58,5 +58,5 @@
  */
 struct vm_area {
-	spinlock_t lock;
+	SPINLOCK_DECLARE(lock);
 	link_t link;
 	vm_type_t type;
@@ -73,5 +73,5 @@
  */
 struct vm {
-	spinlock_t lock;
+	SPINLOCK_DECLARE(lock);
 	link_t vm_area_head;
 	pte_t *ptl0;
Index: generic/include/proc/scheduler.h
===================================================================
--- generic/include/proc/scheduler.h	(revision 3fc03fd55a97ee8c78eecc373fec290d6bd547d9)
+++ generic/include/proc/scheduler.h	(revision dc747e33f6f5d74c7d1b7b50fda3b2fabff8fa82)
@@ -41,5 +41,5 @@
 /** Scheduler run queue structure. */
 struct runq {
-	spinlock_t lock;
+	SPINLOCK_DECLARE(lock);
 	link_t rq_head;		/**< List of ready threads. */
 	count_t n;		/**< Number of threads in rq_ready. */
Index: generic/include/proc/task.h
===================================================================
--- generic/include/proc/task.h	(revision 3fc03fd55a97ee8c78eecc373fec290d6bd547d9)
+++ generic/include/proc/task.h	(revision dc747e33f6f5d74c7d1b7b50fda3b2fabff8fa82)
@@ -35,5 +35,5 @@
 
 struct task {
-	spinlock_t lock;
+	SPINLOCK_DECLARE(lock);
 	link_t th_head;		/**< List of threads contained in this task. */
 	link_t tasks_link;	/**< Link to other tasks within the system. */
Index: generic/include/proc/thread.h
===================================================================
--- generic/include/proc/thread.h	(revision 3fc03fd55a97ee8c78eecc373fec290d6bd547d9)
+++ generic/include/proc/thread.h	(revision dc747e33f6f5d74c7d1b7b50fda3b2fabff8fa82)
@@ -71,5 +71,5 @@
 	 * 
 	 */
-	spinlock_t lock;
+	SPINLOCK_DECLARE(lock);
 
 	void (* thread_code)(void *);		/**< Function implementing the thread. */
Index: generic/include/synch/rwlock.h
===================================================================
--- generic/include/synch/rwlock.h	(revision 3fc03fd55a97ee8c78eecc373fec290d6bd547d9)
+++ generic/include/synch/rwlock.h	(revision dc747e33f6f5d74c7d1b7b50fda3b2fabff8fa82)
@@ -34,4 +34,5 @@
 #include <synch/mutex.h>
 #include <synch/synch.h>
+#include <synch/spinlock.h>
 
 enum rwlock_type {
@@ -42,5 +43,5 @@
 
 struct rwlock {
-	spinlock_t lock;
+	SPINLOCK_DECLARE(lock);
 	mutex_t exclusive;	/**< Mutex for writers, readers can bypass it if readers_in is positive. */
 	count_t readers_in;	/**< Number of readers in critical section. */
Index: generic/include/synch/spinlock.h
===================================================================
--- generic/include/synch/spinlock.h	(revision 3fc03fd55a97ee8c78eecc373fec290d6bd547d9)
+++ generic/include/synch/spinlock.h	(revision dc747e33f6f5d74c7d1b7b50fda3b2fabff8fa82)
@@ -42,4 +42,27 @@
 };
 
+/*
+ * SPINLOCK_DECLARE is to be used for dynamically allocated spinlocks,
+ * where the lock gets initialized in run time.
+ */
+#define SPINLOCK_DECLARE(slname) 	spinlock_t slname
+
+/*
+ * SPINLOCK_INITIALIZE is to be used for statically allocated spinlocks.
+ * It declares and initializes the lock.
+ */
+#ifdef CONFIG_DEBUG_SPINLOCK
+#define SPINLOCK_INITIALIZE(slname) 	\
+	spinlock_t slname = { 		\
+		.name = #slname,	\
+		.val = 0		\
+	}
+#else
+#define SPINLOCK_INITIALIZE(slname) 	\
+	spinlock_t slname = { 		\
+		.val = 0		\
+	}
+#endif
+
 extern void spinlock_initialize(spinlock_t *sl, char *name);
 extern void spinlock_lock(spinlock_t *sl);
@@ -49,6 +72,7 @@
 #else
 
-struct spinlock {
-};
+/* On UP systems, spinlocks are effectively left out. */
+#define SPINLOCK_DECLARE(name)
+#define SPINLOCK_INITIALIZE(name)
 
 #define spinlock_initialize(x,name)
Index: generic/include/synch/waitq.h
===================================================================
--- generic/include/synch/waitq.h	(revision 3fc03fd55a97ee8c78eecc373fec290d6bd547d9)
+++ generic/include/synch/waitq.h	(revision dc747e33f6f5d74c7d1b7b50fda3b2fabff8fa82)
@@ -46,5 +46,5 @@
 	 * Must be acquired before T.lock for each T of type thread_t.
 	 */
-	spinlock_t lock;
+	SPINLOCK_DECLARE(lock);
 
 	int missed_wakeups;	/**< Number of waitq_wakeup() calls that didn't find a thread to wake up. */
Index: generic/include/time/timeout.h
===================================================================
--- generic/include/time/timeout.h	(revision 3fc03fd55a97ee8c78eecc373fec290d6bd547d9)
+++ generic/include/time/timeout.h	(revision dc747e33f6f5d74c7d1b7b50fda3b2fabff8fa82)
@@ -40,5 +40,5 @@
 
 struct timeout {
-	spinlock_t lock;
+	SPINLOCK_DECLARE(lock);
 
 	link_t link;			/**< Link to the list of active timeouts on THE->cpu */
