linux-warning-reduction-20090318
[openafs.git] / src / rx / LINUX / rx_kmutex.h
index bc1bed8..6ea4faf 100644 (file)
@@ -24,7 +24,6 @@
 #define        AFS_GLOBAL_RXLOCK_KERNEL 1
 
 
-#if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT)
 #define RX_ENABLE_LOCKS 1
 
 #ifndef _LINUX_CODA_FS_I
 struct coda_inode_info {
 };
 #endif
-#include "linux/wait.h"
-#include "linux/sched.h"
+#include <linux/version.h>
+#include <linux/wait.h>
+#include <linux/sched.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+#include <linux/mutex.h>
+#else
+#include <asm/semaphore.h>
+#endif
 
 typedef struct afs_kmutex {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+    struct mutex mutex;
+#else
     struct semaphore sem;
+#endif
     int owner;
 } afs_kmutex_t;
 
@@ -44,11 +53,14 @@ typedef struct afs_kmutex {
 #define set_current_state(X) current->state=X
 #endif
 
+typedef struct afs_kcondvar {
+    int seq;
 #if defined(AFS_LINUX24_ENV)
-typedef wait_queue_head_t afs_kcondvar_t;
+    wait_queue_head_t waitq;
 #else
-typedef struct wait_queue *afs_kcondvar_t;
+    struct wait_queue *waitq;
 #endif
+} afs_kcondvar_t;
 
 static inline int
 MUTEX_ISMINE(afs_kmutex_t * l)
@@ -63,42 +75,20 @@ MUTEX_ISMINE(afs_kmutex_t * l)
 #define MUTEX_EXIT             afs_mutex_exit
 
 #if defined(AFS_LINUX24_ENV)
-#define CV_INIT(cv,b,c,d)      init_waitqueue_head((wait_queue_head_t *)(cv))
+#define CV_INIT(cv,b,c,d)       do { (cv)->seq = 0; init_waitqueue_head(&(cv)->waitq); } while (0)
 #else
-#define CV_INIT(cv,b,c,d)      init_waitqueue((struct wait_queue**)(cv))
+#define CV_INIT(cv,b,c,d)      do { (cv)->seq = 0; init_waitqueue(&(cv)->waitq); } while (0)
 #endif
 #define CV_DESTROY(cv)
 #define CV_WAIT_SIG(cv, m)     afs_cv_wait(cv, m, 1)
 #define CV_WAIT(cv, m)         afs_cv_wait(cv, m, 0)
 #define CV_TIMEDWAIT           afs_cv_timedwait
 
+#define CV_SIGNAL(cv)          do { ++(cv)->seq; wake_up(&(cv)->waitq); } while (0)
 #if defined(AFS_LINUX24_ENV)
-#define CV_SIGNAL(cv)          wake_up((wait_queue_head_t *)cv)
-#define CV_BROADCAST(cv)       wake_up((wait_queue_head_t *)cv)
-#else
-#define CV_SIGNAL(cv)          wake_up((struct wait_queue**)cv)
-#define CV_BROADCAST(cv)       wake_up((struct wait_queue**)cv)
-#endif
-
+#define CV_BROADCAST(cv)       do { ++(cv)->seq; wake_up_all(&(cv)->waitq); } while (0)
 #else
-
-#define MUTEX_ISMINE(a)
-#define osirx_AssertMine(addr, msg)
-
-#define MUTEX_DESTROY(a)
-#define MUTEX_ENTER(a)
-#define MUTEX_TRYENTER(a) 1
-#define MUTEX_EXIT(a)
-#define MUTEX_INIT(a,b,c,d)
-#define CV_INIT(a,b,c,d)
-#define CV_DESTROY(a)
+#define CV_BROADCAST(cv)       do { ++(cv)->seq; wake_up(&(cv)->waitq); } while (0)
 #endif
 
-/* Since we're using the RX listener daemon, we don't need to hold off
- * interrupts.
- */
-#define SPLVAR
-#define NETPRI
-#define USERPRI
-
 #endif /* RX_KMUTEX_H_ */