openbsd-20021203
[openafs.git] / src / afs / OBSD / osi_machdep.h
index 5450bab..cd453ca 100644 (file)
@@ -82,6 +82,9 @@ extern struct timeval time;
 
 /* other */
 #define afs_bufferpages bufpages
+#ifndef iodone
+#define iodone biodone
+#endif
 #define PAGESIZE       8192
 #define printk         printf  /* for RX version of xdr_* */
 #define setgroups      sys_setgroups
@@ -104,24 +107,42 @@ extern int afs_vget();
 
 #ifdef KERNEL
 extern int (**afs_vnodeop_p)();
-extern struct simplelock afs_global_lock;
 
-#ifndef AFS_GLOBAL_SUNLOCK
-#define AFS_ASSERT_GLOCK()
-#endif
+#ifdef AFS_GLOBAL_SUNLOCK
+extern struct proc * afs_global_owner;
+extern struct lock afs_global_lock;
+#define AFS_GLOCK() \
+    do { \
+        osi_Assert(curproc); \
+       lockmgr(&afs_global_lock, LK_EXCLUSIVE, 0, curproc); \
+        osi_Assert(afs_global_owner == NULL); \
+       afs_global_owner = curproc; \
+    } while (0)
+#define AFS_GUNLOCK() \
+    do { \
+        osi_Assert(curproc); \
+       osi_Assert(afs_global_owner == curproc); \
+        afs_global_owner = NULL; \
+        lockmgr(&afs_global_lock, LK_RELEASE, 0, curproc); \
+    } while(0)
+#define ISAFS_GLOCK() (afs_global_owner == curproc && curproc)
+#else
+extern struct simplelock afs_global_lock;
 #define AFS_GLOCK()
 #define AFS_GUNLOCK()
+#define AFS_ASSERT_GLOCK()
+#define ISAFS_GLOCK() 1
+#endif
 #define AFS_RXGLOCK()
 #define AFS_RXGUNLOCK()
 #define ISAFS_RXGLOCK() 1
-#define ISAFS_GLOCK() 1
 
 #undef SPLVAR
-#define SPLVAR
+#define SPLVAR int splvar
 #undef NETPRI
-#define NETPRI
+#define NETPRI splvar=splnet()
 #undef USERPRI
-#define USERPRI
+#define USERPRI splx(splvar)
 #endif /* KERNEL */
 
 #endif /* _OSI_MACHDEP_H_ */