Index: generic/include/synch/spinlock.h
===================================================================
--- generic/include/synch/spinlock.h	(revision 7c7aae1655a7653ed95980918529a6c78e15b376)
+++ generic/include/synch/spinlock.h	(revision 53f98219259f3ae305745185632cbe185fb7c871)
@@ -34,4 +34,5 @@
 #include <preemption.h>
 #include <arch/atomic.h>
+#include <debug.h>
 
 #ifdef CONFIG_SMP
@@ -67,7 +68,31 @@
 
 extern void spinlock_initialize(spinlock_t *sl, char *name);
-extern void spinlock_lock(spinlock_t *sl);
 extern int spinlock_trylock(spinlock_t *sl);
-extern void spinlock_unlock(spinlock_t *sl);
+extern void spinlock_lock_debug(spinlock_t *sl);
+
+#ifdef CONFIG_DEBUG_SPINLOCK
+#  define spinlock_lock(x) spinlock_lock_debug(x)
+#else
+#  define spinlock_lock(x) atomic_lock_arch(&(x)->val)
+#endif
+
+/** Unlock spinlock
+ *
+ * Unlock spinlock.
+ *
+ * @param sl Pointer to spinlock_t structure.
+ */
+static inline void spinlock_unlock(spinlock_t *sl)
+{
+	ASSERT(atomic_get(&sl->val) != 0);
+
+	/*
+	 * Prevent critical section code from bleeding out this way down.
+	 */
+	CS_LEAVE_BARRIER();
+	
+	atomic_set(&sl->val,0);
+	preemption_enable();
+}
 
 #else
Index: generic/include/syscall/syscall.h
===================================================================
--- generic/include/syscall/syscall.h	(revision 7c7aae1655a7653ed95980918529a6c78e15b376)
+++ generic/include/syscall/syscall.h	(revision 53f98219259f3ae305745185632cbe185fb7c871)
@@ -56,4 +56,6 @@
 
 extern syshandler_t syscall_table[SYSCALL_END];
+extern __native syscall_handler(__native a1, __native a2, __native a3,
+				__native a4, __native id);
 
 #endif
