OpenAFS
OpenAFS distributed network file system
|
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 * Solaris implementation. 00014 */ 00015 00016 #ifndef _RX_KMUTEX_H_ 00017 #define _RX_KMUTEX_H_ 00018 00019 #if defined(AFS_SUN5_ENV) && defined(KERNEL) 00020 00021 #define RX_ENABLE_LOCKS 1 00022 #define AFS_GLOBAL_RXLOCK_KERNEL 1 00023 00024 #include <sys/tiuser.h> 00025 #include <sys/t_lock.h> 00026 #include <sys/mutex.h> 00027 00028 typedef kmutex_t afs_kmutex_t; 00029 typedef kcondvar_t afs_kcondvar_t; 00030 00031 #undef osirx_AssertMine 00032 extern void osirx_AssertMine(afs_kmutex_t * lockaddr, char *msg); 00033 00034 #define MUTEX_DESTROY(a) mutex_destroy(a) 00035 #define MUTEX_INIT(a,b,c,d) mutex_init(a, b, c, d) 00036 #define MUTEX_ISMINE(a) mutex_owned((afs_kmutex_t *)(a)) 00037 #define CV_INIT(a,b,c,d) cv_init(a, b, c, d) 00038 #define CV_DESTROY(a) cv_destroy(a) 00039 #define CV_SIGNAL(a) cv_signal(a) 00040 #define CV_BROADCAST(a) cv_broadcast(a) 00041 00042 #ifdef RX_LOCKS_DB 00043 00044 #define MUTEX_ENTER(a) \ 00045 do { \ 00046 mutex_enter(a); \ 00047 rxdb_grablock((a), osi_ThreadUnique(), rxdb_fileID, __LINE__); \ 00048 } while(0) 00049 00050 #define MUTEX_TRYENTER(a) \ 00051 (mutex_tryenter(a) ? (rxdb_grablock((a), osi_ThreadUnique(), \ 00052 rxdb_fileID, __LINE__), 1) : 0) 00053 00054 #define MUTEX_EXIT(a) \ 00055 do { \ 00056 rxdb_droplock((a), osi_ThreadUnique(), rxdb_fileID, __LINE__); \ 00057 mutex_exit(a); \ 00058 } while(0) 00059 00060 #define CV_WAIT_SIG(cv, m) afs_cv_wait(cv, m, 1, rxdb_fileID, __LINE__) 00061 #define CV_WAIT(cv, m) afs_cv_wait(cv, m, 0, rxdb_fileID, __LINE__) 00062 00063 #define CV_TIMEDWAIT(cv, m, t) \ 00064 afs_cv_timedwait(cv, lck, t, 0, rxdb_fileID, __LINE__) 00065 00066 #else /* RX_LOCKS_DB */ 00067 00068 #define MUTEX_ENTER(a) mutex_enter(a) 00069 #define MUTEX_TRYENTER(a) mutex_tryenter(a) 00070 #define MUTEX_EXIT(a) mutex_exit(a) 00071 00072 #define CV_WAIT_SIG(cv, m) afs_cv_wait(cv, m, 1) 00073 #define CV_WAIT(cv, m) afs_cv_wait(cv, m, 0) 00074 00075 #define CV_TIMEDWAIT(cv, m, t) afs_cv_timedwait(cv, m, t, 0) 00076 00077 #endif /* RX_LOCKS_DB */ 00078 00079 #endif /* SUN5 && KERNEL */ 00080 00081 #endif /* _RX_KMUTEX_H_ */