From: nikita Date: Fri, 8 Aug 2008 13:54:28 +0000 (+0000) Subject: libcfs: 0. add emulation of new style Linux mutices for older kernels; 1. add lockdep... X-Git-Tag: v1_9_50~37 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=7c06e02cd77ab8359f48ecf6b5f83fa4d14c513a libcfs: 0. add emulation of new style Linux mutices for older kernels; 1. add lockdep emulation for pre-lockdep kernels. --- diff --git a/libcfs/include/libcfs/linux/linux-lock.h b/libcfs/include/libcfs/linux/linux-lock.h index 26e5578..d78e2b5 100644 --- a/libcfs/include/libcfs/linux/linux-lock.h +++ b/libcfs/include/libcfs/linux/linux-lock.h @@ -114,4 +114,55 @@ * - wait_for_completion(c) */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) + +/************************************************************************** + * + * Lockdep "implementation". Also see liblustre.h + * + **************************************************************************/ + +struct lock_class_key { + ; +}; + +static inline void lockdep_set_class(void *lock, struct lock_class_key *key) +{ +} + +/************************************************************************** + * + * Mutex interface from newer Linux kernels. + * + * this augments compatibility interface from include/linux/mutex.h + * + **************************************************************************/ + +#ifndef mutex +# define mutex semaphore +#endif + +static inline void mutex_lock_nested(struct mutex *mutex, unsigned int subclass) +{ + return down(mutex); +} + +static inline void mutex_destroy(struct mutex *lock) +{ +} + +/* + * This is for use in assertions _only_, i.e., this function should always + * return 1. + * + * \retval 1 mutex is locked. + * + * \retval 0 mutex is not locked. This should never happen. + */ +static inline int mutex_is_locked(struct mutex *lock) +{ + return !!down_trylock(lock); +} +#endif + #endif