Kernel is always defined
[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  * NetBSD 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 typedef struct ucred afs_ucred_t;
36 typedef struct proc afs_proc_t;
37
38 #define afs_bufferpages bufpages
39
40 #undef gop_lookupname
41 #define gop_lookupname(fnamep,segflg,followlink,compvpp) lookupname((fnamep),(segflg),(followlink),NULL,(compvpp))
42 #undef gop_lookupname_user
43 #define gop_lookupname_user(fnamep,segflg,followlink,compvpp) lookupname((fnamep),(segflg),(followlink),NULL,(compvpp))
44
45 #define osi_vnhold(avc,r)  do { \
46        if ((avc)->vrefCount) { VN_HOLD((struct vnode *)(avc)); } \
47        else osi_Panic("refcnt==0");  } while(0)
48
49 #define gop_rdwr(rw,gp,base,len,offset,segflg,unit,cred,aresid) \
50   vn_rdwr((rw),(gp),(base),(len),(offset),(segflg),(unit),(cred),(aresid), curproc)
51
52 #undef afs_suser
53
54 extern struct simplelock afs_global_lock;
55 #if 0
56 extern thread_t afs_global_owner;
57 #define AFS_GLOCK() \
58     do { \
59         usimple_lock(&afs_global_lock); \
60         osi_Assert(afs_global_owner == (thread_t)0); \
61         afs_global_owner = current_thread(); \
62     } while (0)
63 #define AFS_GUNLOCK() \
64     do { \
65         osi_Assert(afs_global_owner == current_thread()); \
66         afs_global_owner = (thread_t)0; \
67         usimple_unlock(&afs_global_lock); \
68     } while(0)
69 #define ISAFS_GLOCK() (afs_global_owner == current_thread())
70 #else
71 #define AFS_GLOCK() \
72     do { \
73         simple_lock(&afs_global_lock); \
74     } while (0)
75 #define AFS_GUNLOCK() \
76     do { \
77         simple_unlock(&afs_global_lock); \
78     } while(0)
79 #define osi_InitGlock() \
80     do { \
81         lockinit(&afs_global_lock, PLOCK, "afs global lock", 0, 0); \
82         afs_global_owner = 0; \
83     } while (0)
84 #endif /* 0 */
85
86 #undef SPLVAR
87 #define SPLVAR
88 #undef NETPRI
89 #define NETPRI
90 #undef USERPRI
91 #define USERPRI
92
93 /* Vnode related macros */
94
95 extern int (**afs_vnodeop_p) ();
96 #define vType(vc)               AFSTOV(vc)->v_type
97 #define vSetVfsp(vc, vfsp)      AFSTOV(vc)->v_mount = (vfsp)
98 #define vSetType(vc, type)      AFSTOV(vc)->v_type = (type)
99 #define IsAfsVnode(v)           ((v)->v_op == afs_vnodeop_p)
100 #define SetAfsVnode(v)          /* nothing; done in getnewvnode() */
101
102 #endif /* _OSI_MACHDEP_H_ */