fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / include / asm-i386 / semaphore.h
index 986da20..4e34a46 100644 (file)
@@ -45,24 +45,15 @@ struct semaphore {
        atomic_t count;
        int sleepers;
        wait_queue_head_t wait;
-#ifdef WAITQUEUE_DEBUG
-       long __magic;
-#endif
 };
 
-#ifdef WAITQUEUE_DEBUG
-# define __SEM_DEBUG_INIT(name) \
-               , (int)&(name).__magic
-#else
-# define __SEM_DEBUG_INIT(name)
-#endif
-
-#define __SEMAPHORE_INITIALIZER(name,count) \
-{ ATOMIC_INIT(count), 0, __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
-       __SEM_DEBUG_INIT(name) }
 
-#define __MUTEX_INITIALIZER(name) \
-       __SEMAPHORE_INITIALIZER(name,1)
+#define __SEMAPHORE_INITIALIZER(name, n)                               \
+{                                                                      \
+       .count          = ATOMIC_INIT(n),                               \
+       .sleepers       = 0,                                            \
+       .wait           = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait)    \
+}
 
 #define __DECLARE_SEMAPHORE_GENERIC(name,count) \
        struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
@@ -81,9 +72,6 @@ static inline void sema_init (struct semaphore *sem, int val)
        atomic_set(&sem->count, val);
        sem->sleepers = 0;
        init_waitqueue_head(&sem->wait);
-#ifdef WAITQUEUE_DEBUG
-       sem->__magic = (int)&sem->__magic;
-#endif
 }
 
 static inline void init_MUTEX (struct semaphore *sem)
@@ -96,15 +84,10 @@ static inline void init_MUTEX_LOCKED (struct semaphore *sem)
        sema_init(sem, 0);
 }
 
-asmlinkage void __down_failed(void /* special register calling convention */);
-asmlinkage int  __down_failed_interruptible(void  /* params in registers */);
-asmlinkage int  __down_failed_trylock(void  /* params in registers */);
-asmlinkage void __up_wakeup(void /* special register calling convention */);
-
-asmlinkage void __down(struct semaphore * sem);
-asmlinkage int  __down_interruptible(struct semaphore * sem);
-asmlinkage int  __down_trylock(struct semaphore * sem);
-asmlinkage void __up(struct semaphore * sem);
+fastcall void __down_failed(void /* special register calling convention */);
+fastcall int  __down_failed_interruptible(void  /* params in registers */);
+fastcall int  __down_failed_trylock(void  /* params in registers */);
+fastcall void __up_wakeup(void /* special register calling convention */);
 
 /*
  * This is ugly, but we want the default case to fall through.
@@ -113,22 +96,17 @@ asmlinkage void __up(struct semaphore * sem);
  */
 static inline void down(struct semaphore * sem)
 {
-#ifdef WAITQUEUE_DEBUG
-       CHECK_MAGIC(sem->__magic);
-#endif
        might_sleep();
        __asm__ __volatile__(
                "# atomic down operation\n\t"
-               LOCK "decl %0\n\t"     /* --sem->count */
-               "js 2f\n"
-               "1:\n"
-               LOCK_SECTION_START("")
-               "2:\tcall __down_failed\n\t"
-               "jmp 1b\n"
-               LOCK_SECTION_END
-               :"=m" (sem->count)
-               :"c" (sem)
-               :"memory");
+               LOCK_PREFIX "decl %0\n\t"     /* --sem->count */
+               "jns 2f\n"
+               "\tlea %0,%%eax\n\t"
+               "call __down_failed\n"
+               "2:"
+               :"+m" (sem->count)
+               :
+               :"memory","ax");
 }
 
 /*
@@ -139,22 +117,17 @@ static inline int down_interruptible(struct semaphore * sem)
 {
        int result;
 
-#ifdef WAITQUEUE_DEBUG
-       CHECK_MAGIC(sem->__magic);
-#endif
        might_sleep();
        __asm__ __volatile__(
                "# atomic interruptible down operation\n\t"
-               LOCK "decl %1\n\t"     /* --sem->count */
-               "js 2f\n\t"
-               "xorl %0,%0\n"
-               "1:\n"
-               LOCK_SECTION_START("")
-               "2:\tcall __down_failed_interruptible\n\t"
-               "jmp 1b\n"
-               LOCK_SECTION_END
-               :"=a" (result), "=m" (sem->count)
-               :"c" (sem)
+               "xorl %0,%0\n\t"
+               LOCK_PREFIX "decl %1\n\t"     /* --sem->count */
+               "jns 2f\n\t"
+               "lea %1,%%eax\n\t"
+               "call __down_failed_interruptible\n"
+               "2:"
+               :"=&a" (result), "+m" (sem->count)
+               :
                :"memory");
        return result;
 }
@@ -167,22 +140,16 @@ static inline int down_trylock(struct semaphore * sem)
 {
        int result;
 
-#ifdef WAITQUEUE_DEBUG
-       CHECK_MAGIC(sem->__magic);
-#endif
-
        __asm__ __volatile__(
                "# atomic interruptible down operation\n\t"
-               LOCK "decl %1\n\t"     /* --sem->count */
-               "js 2f\n\t"
-               "xorl %0,%0\n"
-               "1:\n"
-               LOCK_SECTION_START("")
-               "2:\tcall __down_failed_trylock\n\t"
-               "jmp 1b\n"
-               LOCK_SECTION_END
-               :"=a" (result), "=m" (sem->count)
-               :"c" (sem)
+               "xorl %0,%0\n\t"
+               LOCK_PREFIX "decl %1\n\t"     /* --sem->count */
+               "jns 2f\n\t"
+               "lea %1,%%eax\n\t"
+               "call __down_failed_trylock\n\t"
+               "2:\n"
+               :"=&a" (result), "+m" (sem->count)
+               :
                :"memory");
        return result;
 }
@@ -190,27 +157,19 @@ static inline int down_trylock(struct semaphore * sem)
 /*
  * Note! This is subtle. We jump to wake people up only if
  * the semaphore was negative (== somebody was waiting on it).
- * The default case (no contention) will result in NO
- * jumps for both down() and up().
  */
 static inline void up(struct semaphore * sem)
 {
-#ifdef WAITQUEUE_DEBUG
-       CHECK_MAGIC(sem->__magic);
-#endif
        __asm__ __volatile__(
                "# atomic up operation\n\t"
-               LOCK "incl %0\n\t"     /* ++sem->count */
-               "jle 2f\n"
-               "1:\n"
-               LOCK_SECTION_START("")
-               "2:\tcall __up_wakeup\n\t"
-               "jmp 1b\n"
-               LOCK_SECTION_END
-               ".subsection 0\n"
-               :"=m" (sem->count)
-               :"c" (sem)
-               :"memory");
+               LOCK_PREFIX "incl %0\n\t"     /* ++sem->count */
+               "jg 1f\n\t"
+               "lea %0,%%eax\n\t"
+               "call __up_wakeup\n"
+               "1:"
+               :"+m" (sem->count)
+               :
+               :"memory","ax");
 }
 
 #endif