OpenAFS
OpenAFS distributed network file system
/cygdrive/c/src/openafs/openafs.git/repo/src/rx/LINUX/rx_kmutex.h
00001 /*
00002  * Copyright 2000, International Business Machines Corporation and others.
00003  * All Rights Reserved.
00004  *
00005  * This software has been released under the terms of the IBM Public
00006  * License.  For details, see the LICENSE file in the top-level source
00007  * directory or online at http://www.openafs.org/dl/license10.html
00008  */
00009 
00010 /*
00011  * rx_kmutex.h - mutex and condition variable macros for kernel environment.
00012  *
00013  * Linux implementation.
00014  * This are noops until such time as the kernel no longer has a global lock.
00015  */
00016 #ifndef RX_KMUTEX_H_
00017 #define RX_KMUTEX_H_
00018 
00019 #include "rx/rx_kernel.h"       /* for osi_Panic() */
00020 
00021 /* AFS_GLOBAL_RXLOCK_KERNEL is defined so that the busy tq code paths are
00022  * used. The thread can sleep when sending packets.
00023  */
00024 #define AFS_GLOBAL_RXLOCK_KERNEL 1
00025 
00026 
00027 #define RX_ENABLE_LOCKS 1
00028 
00029 #ifndef _LINUX_CODA_FS_I
00030 #define _LINUX_CODA_FS_I
00031 struct coda_inode_info {
00032 };
00033 #endif
00034 #include <linux/version.h>
00035 #include <linux/wait.h>
00036 #include <linux/sched.h>
00037 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
00038 #include <linux/mutex.h>
00039 #else
00040 #include <asm/semaphore.h>
00041 #endif
00042 
00043 typedef struct afs_kmutex {
00044 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
00045     struct mutex mutex;
00046 #else
00047     struct semaphore sem;
00048 #endif
00049     int owner;
00050 } afs_kmutex_t;
00051 
00052 #ifndef set_current_state
00053 #define set_current_state(X) current->state=X
00054 #endif
00055 
00056 typedef struct afs_kcondvar {
00057     int seq;
00058     wait_queue_head_t waitq;
00059 } afs_kcondvar_t;
00060 
00061 static inline int
00062 MUTEX_ISMINE(afs_kmutex_t * l)
00063 {
00064     return l->owner == current->pid;
00065 }
00066 
00067 #define MUTEX_INIT(a,b,c,d)     afs_mutex_init(a)
00068 #define MUTEX_DESTROY(a)
00069 #define MUTEX_ENTER             afs_mutex_enter
00070 #define MUTEX_TRYENTER          afs_mutex_tryenter
00071 #define MUTEX_EXIT              afs_mutex_exit
00072 
00073 #define CV_INIT(cv,b,c,d)       do { (cv)->seq = 0; init_waitqueue_head(&(cv)->waitq); } while (0)
00074 #define CV_DESTROY(cv)
00075 #define CV_WAIT_SIG(cv, m)      afs_cv_wait(cv, m, 1)
00076 #define CV_WAIT(cv, m)          afs_cv_wait(cv, m, 0)
00077 #define CV_TIMEDWAIT            afs_cv_timedwait
00078 
00079 #define CV_SIGNAL(cv)          do { ++(cv)->seq; wake_up(&(cv)->waitq); } while (0)
00080 #define CV_BROADCAST(cv)       do { ++(cv)->seq; wake_up_all(&(cv)->waitq); } while (0)
00081 
00082 #endif /* RX_KMUTEX_H_ */
 All Data Structures Files Functions Variables