a0f71016cba32fbaaa83b590600bc2777bbda408
[openafs.git] / src / afs / NBSD / osi_machdep.h
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 /*
11  *
12  * DUX OSI header file. Extends afs_osi.h.
13  *
14  * afs_osi.h includes this file, which is the only way this file should
15  * be included in a source file. This file can redefine macros declared in
16  * afs_osi.h.
17  */
18
19 #ifndef _OSI_MACHDEP_H_
20 #define _OSI_MACHDEP_H_
21
22 #include <sys/lock.h>
23 /* #include <kern/sched_prim.h> */
24 /* #include <sys/unix_defs.h> */
25
26 #define getpid()                curproc
27
28 /* 
29  * Time related macros
30  */
31 extern struct timeval time;
32 #define osi_Time() (time.tv_sec)
33 #define afs_hz      hz
34
35 #define PAGESIZE 8192
36
37 #define AFS_UCRED       ucred
38 #define AFS_PROC        struct proc
39
40 #define afs_bufferpages bufpages
41
42 #define osi_vnhold(avc,r)  do { \
43        if ((avc)->vrefCount) { VN_HOLD((struct vnode *)(avc)); } \
44        else osi_Panic("refcnt==0");  } while(0)
45
46 #define gop_rdwr(rw,gp,base,len,offset,segflg,unit,cred,aresid) \
47   vn_rdwr((rw),(gp),(base),(len),(offset),(segflg),(unit),(cred),(aresid), curproc)
48
49 #undef afs_suser
50
51 #ifdef KERNEL
52 extern struct simplelock afs_global_lock;
53 #if 0
54 extern thread_t afs_global_owner;
55 #define AFS_GLOCK() \
56     do { \
57         usimple_lock(&afs_global_lock); \
58         osi_Assert(afs_global_owner == (thread_t)0); \
59         afs_global_owner = current_thread(); \
60     } while (0)
61 #define AFS_GUNLOCK() \
62     do { \
63         osi_Assert(afs_global_owner == current_thread()); \
64         afs_global_owner = (thread_t)0; \
65         usimple_unlock(&afs_global_lock); \
66     } while(0)
67 #define ISAFS_GLOCK() (afs_global_owner == current_thread())
68 #else
69 #define AFS_GLOCK() \
70     do { \
71         simple_lock(&afs_global_lock); \
72     } while (0)
73 #define AFS_GUNLOCK() \
74     do { \
75         simple_unlock(&afs_global_lock); \
76     } while(0)
77 #endif /* 0 */
78
79 #undef SPLVAR
80 #define SPLVAR
81 #undef NETPRI
82 #define NETPRI
83 #undef USERPRI
84 #define USERPRI
85 #endif /* KERNEL */
86
87 #endif /* _OSI_MACHDEP_H_ */