Move GLOCK initialisation to platform directories
authorSimon Wilkinson <sxw@inf.ed.ac.uk>
Tue, 17 Nov 2009 19:52:15 +0000 (19:52 +0000)
committerDerrick Brashear <shadow|account-1000005@unknown>
Thu, 14 Jan 2010 15:47:59 +0000 (07:47 -0800)
Rework the GLOCK initialisation code so that it's moved out into
platform directories, rather than all being done in osi_Init.

Change-Id: I1aae76ba12cd4e45f54881f5573ed1713159b64b
Reviewed-on: http://gerrit.openafs.org/837
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>

src/afs/AIX/osi_machdep.h
src/afs/DARWIN/osi_machdep.h
src/afs/FBSD/osi_machdep.h
src/afs/IRIX/osi_machdep.h
src/afs/LINUX/osi_machdep.h
src/afs/LINUX24/osi_machdep.h
src/afs/NBSD/osi_machdep.h
src/afs/OBSD/osi_machdep.h
src/afs/SOLARIS/osi_machdep.h
src/afs/UKERNEL/osi_machdep.h
src/afs/afs_osi.c

index ffab0ae..1cd8b90 100644 (file)
@@ -74,6 +74,17 @@ extern simple_lock_data afs_global_lock;
                        } while(0)
 #define ISAFS_GLOCK()  lock_mine((void *)&afs_global_lock)
 
+#if defined(AFS_AIX41_ENV)
+#define osi_InitGlock() \
+       do {                                                            \
+           lock_alloc((void *)&afs_global_lock, LOCK_ALLOC_PIN, 1, 1); \
+           simple_lock_init((void *)&afs_global_lock);                 \
+       } while(0)
+#else
+#define osi_InitGlock() \
+       mutex_init(&afs_global_lock, "afs_global_lock", MUTEX_DEFAULT, NULL)
+#endif
+
 #define ifnet_flags(x) (x?(x)->if_flags:0)
 #endif
 
index 3fe44ff..a0ad9c2 100644 (file)
@@ -174,6 +174,10 @@ extern lck_mtx_t  *afs_global_lock;
        afs_global_owner = 0; \
         lck_mtx_unlock(afs_global_lock); \
     } while(0)
+#define osi_InitGlock() \
+    do { \
+       afs_global_owner = 0; \
+    } while (0)
 #else
 /* Should probably use mach locks rather than bsd locks, since we use the
    mach thread control api's elsewhere (mach locks not used for consistency
@@ -192,6 +196,11 @@ extern struct lock__bsd__ afs_global_lock;
        afs_global_owner = 0; \
         lockmgr(&afs_global_lock, LK_RELEASE, 0, current_proc()); \
     } while(0)
+#define osi_InitGlock() \
+    do { \
+       lockinit(&afs_global_lock, PLOCK, "afs global lock", 0, 0); \
+       afs_global_owner = 0; \
+    } while (0)
 #endif
 #define ISAFS_GLOCK() (afs_global_owner == current_thread())
 
index 954295a..dff2e40 100644 (file)
@@ -119,6 +119,19 @@ extern struct mtx afs_global_mtx;
 #define AFS_GLOCK() mtx_lock(&afs_global_mtx)
 #define AFS_GUNLOCK() mtx_unlock(&afs_global_mtx)
 #define ISAFS_GLOCK() (mtx_owned(&afs_global_mtx))
+#if defined(AFS_FBSD80_ENV) && defined(WITNESS)
+# define osi_InitGlock() \
+       do { \
+           memset(&afs_global_mtx, 0, sizeof(struct mtx)); \
+           mtx_init(&afs_global_mtx, "AFS global lock", NULL, MTX_DEF); \
+           afs_global_owner = 0; \
+       } while(0)
+#else
+# define osi_InitGlock() \
+    do { \
+       mtx_init(&afs_global_mtx, "AFS global lock", NULL, MTX_DEF); \
+       afs_global_owner = 0; \
+    } while (0)
 #else /* FBSD50 */
 extern struct lock afs_global_lock;
 #define osi_curcred()  (curproc->p_cred->pc_ucred)
@@ -141,6 +154,11 @@ extern struct proc *afs_global_owner;
         lockmgr(&afs_global_lock, LK_RELEASE, 0, curproc); \
     } while(0)
 #define ISAFS_GLOCK() (afs_global_owner == curproc && curproc)
+#define osi_InitGlock() \
+    do { \
+       lockinit(&afs_global_lock, PLOCK, "afs global lock", 0, 0); \
+       afs_global_owner = 0; \
+    } while (0)
 #endif /* FBSD50 */
 
 #undef SPLVAR
index 444c24c..3885aff 100644 (file)
@@ -194,7 +194,13 @@ extern long afs_global_owner;
 
 #endif /* KERNEL  */
 
-
+#if defined(AFS_SGI62_ENV)
+# define osi_InitGlock() \
+       mutex_init(&afs_global_lock, MUTEX_DEFAULT, "afs_global_lock");
+#else
+# define osi_InitGlock() \
+        mutex_init(&afs_global_lock, "afs_global_lock", MUTEX_DEFAULT, NULL);
+#endif
 
 #ifdef AFS_SGI64_ENV
 #define gop_rdwr(rw,gp,base,len,offset,segflg,ioflag,ulimit,cr,aresid) \
index bfd11c1..f807ae2 100644 (file)
@@ -292,6 +292,9 @@ do { \
     afs_global_owner = 0; \
     mutex_unlock(&afs_global_lock); \
 } while (0)
+
+#define osi_InitGlock()
+
 #else
 #define AFS_GLOCK()
 #define AFS_GUNLOCK()
index 24bcd67..0f2de98 100644 (file)
@@ -269,6 +269,9 @@ do { \
     afs_global_owner = 0; \
     mutex_unlock(&afs_global_lock); \
 } while (0)
+
+#define osi_InitGlock()
+
 #else
 #define AFS_GLOCK()
 #define AFS_GUNLOCK()
index 91e98bc..db7440a 100644 (file)
@@ -77,6 +77,11 @@ extern thread_t afs_global_owner;
     do { \
        simple_unlock(&afs_global_lock); \
     } while(0)
+#define osi_InitGlock() \
+    do { \
+       lockinit(&afs_global_lock, PLOCK, "afs global lock", 0, 0); \
+       afs_global_owner = 0; \
+    } while (0)
 #endif /* 0 */
 
 #undef SPLVAR
index 906ec10..33a8af6 100644 (file)
@@ -226,6 +226,12 @@ extern struct lock afs_global_lock;
 #define USERPRI splx(splvar)
 #endif /* KERNEL */
 
+#define osi_InitGlock() \
+    do { \
+       lockinit(&afs_global_lock, PLOCK, "afs global lock", 0, 0); \
+       afs_global_owner = 0; \
+    } while (0)
+
 /* vnodes */
 extern int (**afs_vnodeop_p) ();
 #define vType(vc)               AFSTOV(vc)->v_type
index 56b2bdd..0faf363 100644 (file)
@@ -81,6 +81,8 @@ extern kmutex_t afs_global_lock;
 #define AFS_GLOCK()    mutex_enter(&afs_global_lock);
 #define AFS_GUNLOCK()  mutex_exit(&afs_global_lock);
 #define ISAFS_GLOCK()  mutex_owned(&afs_global_lock)
+#define osi_InitGlock() \
+       mutex_init(&afs_global_lock, "afs_global_lock", MUTEX_DEFAULT, NULL);
 #endif
 
 
index ad08918..b41b261 100644 (file)
@@ -76,6 +76,8 @@ extern usr_mutex_t afs_global_lock;
     } while(0)
 #define AFS_ASSERT_GLOCK() \
     do { if (!ISAFS_GLOCK()) { osi_Panic("afs global lock not held"); } } while(0)
+#define osi_GlockInit() \
+    usr_mutex_init(&afs_global_lock, "afs_global_lock", MUTEX_DEFAULT, NULL)
 
 extern int afs_bufferpages;
 
index 695a327..4e5e21f 100644 (file)
@@ -74,33 +74,8 @@ osi_Init(void)
     static int once = 0;
     if (once++ > 0)            /* just in case */
        return;
-#if    defined(AFS_HPUX_ENV)
+
     osi_InitGlock();
-#else /* AFS_HPUX_ENV */
-#if defined(AFS_GLOBAL_SUNLOCK)
-#if defined(AFS_SGI62_ENV)
-    mutex_init(&afs_global_lock, MUTEX_DEFAULT, "afs_global_lock");
-#elif defined(AFS_FBSD50_ENV)
-#if defined(AFS_FBSD80_ENV) && defined(WITNESS)
-    /* "lock_initalized" (sic) can panic, checks a flag bit
-     * is unset _before_ init */
-    memset(&afs_global_mtx, 0, sizeof(struct mtx));
-#endif
-    mtx_init(&afs_global_mtx, "AFS global lock", NULL, MTX_DEF);
-#elif defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
-#if !defined(AFS_DARWIN80_ENV)
-    lockinit(&afs_global_lock, PLOCK, "afs global lock", 0, 0);
-#endif
-    afs_global_owner = 0;
-#elif defined(AFS_AIX41_ENV)
-    lock_alloc((void *)&afs_global_lock, LOCK_ALLOC_PIN, 1, 1);
-    simple_lock_init((void *)&afs_global_lock);
-#elif !defined(AFS_LINUX22_ENV)
-    /* Linux initialization in osi directory. Should move the others. */
-    mutex_init(&afs_global_lock, "afs_global_lock", MUTEX_DEFAULT, NULL);
-#endif
-#endif /* AFS_GLOBAL_SUNLOCK */
-#endif /* AFS_HPUX_ENV */
 
     if (!afs_osicred_initialized) {
 #if defined(AFS_DARWIN80_ENV)