Whamcloud - gitweb
LU-2044 libcfs: fix to build libcfs without pthreads
authorJames Simmons <uja.ornl@gmail.com>
Fri, 28 Sep 2012 12:14:20 +0000 (08:14 -0400)
committerOleg Drokin <green@whamcloud.com>
Mon, 1 Oct 2012 04:45:18 +0000 (00:45 -0400)
Currently libcfs fails to build on systems without pthreads
in the libcfs_lock code with its pseudo lock implementation.
Instead of creating a phony address pointer we create a real
static lock and test the pointer to it. The compiler is much
more happy with this approach.

Signed-off-by: James Simmons <uja.ornl@gmail.com>
Change-Id: Ia66d0972951afbfe9bc69a6375d57e6a13ae4e43
Reviewed-on: http://review.whamcloud.com/4121
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Liang Zhen <liang@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
libcfs/include/libcfs/libcfs_private.h
libcfs/libcfs/libcfs_lock.c

index 0bf8c03..aaaac7c 100644 (file)
@@ -489,11 +489,13 @@ struct cfs_percpt_lock {
 };
 
 # else /* !HAVE_LIBPTHREAD */
-#define CFS_PERCPT_LOCK_MAGIC          0xbabecafe;
 
 struct cfs_percpt_lock {
        int                     pcl_lock;
 };
+
+static const struct cfs_percpt_lock CFS_PERCPT_LOCK_MAGIC;
+
 # endif /* HAVE_LIBPTHREAD */
 # define cfs_percpt_lock_num(pcl)        1
 #endif /* __KERNEL__ */
index b9e2f25..a587e95 100644 (file)
@@ -189,25 +189,25 @@ cfs_percpt_unlock(struct cfs_percpt_lock *pcl, int lock)
 struct cfs_percpt_lock *
 cfs_percpt_lock_alloc(struct cfs_cpt_table *cptab)
 {
-       return (struct cfs_percpt_lock *)CFS_PERCPT_LOCK_MAGIC;
+       return ((struct cfs_percpt_lock *) &CFS_PERCPT_LOCK_MAGIC);
 }
 
 void
 cfs_percpt_lock_free(struct cfs_percpt_lock *pcl)
 {
-       LASSERT(pcl == (struct cfs_percpt_lock *)CFS_PERCPT_LOCK_MAGIC);
+       LASSERT(pcl == (struct cfs_percpt_lock *) &CFS_PERCPT_LOCK_MAGIC);
 }
 
 void
 cfs_percpt_lock(struct cfs_percpt_lock *pcl, int index)
 {
-       LASSERT(pcl == (struct cfs_percpt_lock *)CFS_PERCPT_LOCK_MAGIC);
+       LASSERT(pcl == (struct cfs_percpt_lock *) &CFS_PERCPT_LOCK_MAGIC);
 }
 
 void
 cfs_percpt_unlock(struct cfs_percpt_lock *pcl, int index)
 {
-       LASSERT(pcl == (struct cfs_percpt_lock *)CFS_PERCPT_LOCK_MAGIC);
+       LASSERT(pcl == (struct cfs_percpt_lock *) &CFS_PERCPT_LOCK_MAGIC);
 }
 
 # endif /* HAVE_LIBPTHREAD */