OpenAFS
OpenAFS distributed network file system
/cygdrive/c/src/openafs/openafs.git/repo/src/rx/LINUX24/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 #if defined(AFS_LINUX24_ENV)
00059     wait_queue_head_t waitq;
00060 #else
00061     struct wait_queue *waitq;
00062 #endif
00063 } afs_kcondvar_t;
00064 
00065 static inline int
00066 MUTEX_ISMINE(afs_kmutex_t * l)
00067 {
00068     return l->owner == current->pid;
00069 }
00070 
00071 #define MUTEX_INIT(a,b,c,d)     afs_mutex_init(a)
00072 #define MUTEX_DESTROY(a)
00073 #define MUTEX_ENTER             afs_mutex_enter
00074 #define MUTEX_TRYENTER          afs_mutex_tryenter
00075 #define MUTEX_EXIT              afs_mutex_exit
00076 
00077 #if defined(AFS_LINUX24_ENV)
00078 #define CV_INIT(cv,b,c,d)       do { (cv)->seq = 0; init_waitqueue_head(&(cv)->waitq); } while (0)
00079 #else
00080 #define CV_INIT(cv,b,c,d)       do { (cv)->seq = 0; init_waitqueue(&(cv)->waitq); } while (0)
00081 #endif
00082 #define CV_DESTROY(cv)
00083 #define CV_WAIT_SIG(cv, m)      afs_cv_wait(cv, m, 1)
00084 #define CV_WAIT(cv, m)          afs_cv_wait(cv, m, 0)
00085 #define CV_TIMEDWAIT            afs_cv_timedwait
00086 
00087 #define CV_SIGNAL(cv)          do { ++(cv)->seq; wake_up(&(cv)->waitq); } while (0)
00088 #if defined(AFS_LINUX24_ENV)
00089 #define CV_BROADCAST(cv)       do { ++(cv)->seq; wake_up_all(&(cv)->waitq); } while (0)
00090 #else
00091 #define CV_BROADCAST(cv)       do { ++(cv)->seq; wake_up(&(cv)->waitq); } while (0)
00092 #endif
00093 
00094 #endif /* RX_KMUTEX_H_ */
 All Data Structures Files Functions Variables