2 * Copyright 2000, International Business Machines Corporation and others.
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
12 * FBSD OSI header file. Extends afs_osi.h.
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
19 #ifndef _OSI_MACHDEP_H_
20 #define _OSI_MACHDEP_H_
24 #if defined(AFS_FBSD50_ENV)
25 #include <sys/mutex.h>
31 #define osi_Time() time_second
34 #define AFS_UCRED ucred
35 #define AFS_PROC struct proc
37 #define afs_bufferpages bufpages
39 #define iodone biodone
42 #define osi_vnhold(avc,r) vref(AFSTOV(avc))
44 #define vSetVfsp(vc, vfsp) AFSTOV(vc)->v_mount = (vfsp)
46 #define vSetType(vc, type) AFSTOV(vc)->v_type = (type)
48 #define vType(vc) AFSTOV(vc)->v_type
51 #define gop_lookupname osi_lookupname
55 #define afs_strcat(s1, s2) strcat((s1), (s2))
59 #undef afs_osi_Alloc_NoSleep
60 #define afs_osi_Alloc_NoSleep(size) osi_fbsd_alloc((size), 0)
68 #define VN_RELE(vp) vrele(vp)
70 #define VN_HOLD(vp) VREF(vp)
74 #define IsAfsVnode(v) ((v)->v_op == &afs_vnodeops)
75 extern struct vop_vector afs_vnodeops;
79 #if defined(AFS_FBSD50_ENV)
82 #define v_flag v_vflag
83 #define osi_curcred() (curthread->td_ucred)
84 #define afs_suser(x) (!suser(curthread))
85 #define osi_getpid() (curthread->td_proc->p_pid)
86 #define simple_lock(x) mtx_lock(x)
87 #define simple_unlock(x) mtx_unlock(x)
88 #define gop_rdwr(rw,gp,base,len,offset,segflg,unit,cred,aresid) \
89 vn_rdwr((rw),(gp),(base),(len),(offset),(segflg),(unit),(cred),(cred),(aresid), curthread)
90 extern struct mtx afs_global_mtx;
91 #define AFS_GLOCK() mtx_lock(&afs_global_mtx)
92 #define AFS_GUNLOCK() mtx_unlock(&afs_global_mtx)
93 #define ISAFS_GLOCK() (mtx_owned(&afs_global_mtx))
95 extern struct lock afs_global_lock;
96 #define osi_curcred() (curproc->p_cred->pc_ucred)
97 #define afs_suser(x) (!suser(curproc))
98 #define osi_getpid() (curproc->p_pid)
99 #define gop_rdwr(rw,gp,base,len,offset,segflg,unit,cred,aresid) \
100 vn_rdwr((rw),(gp),(base),(len),(offset),(segflg),(unit),(cred),(aresid), curproc)
101 extern struct proc *afs_global_owner;
102 #define AFS_GLOCK() \
104 osi_Assert(curproc); \
105 lockmgr(&afs_global_lock, LK_EXCLUSIVE, 0, curproc); \
106 osi_Assert(afs_global_owner == 0); \
107 afs_global_owner = curproc; \
109 #define AFS_GUNLOCK() \
111 osi_Assert(curproc); \
112 osi_Assert(afs_global_owner == curproc); \
113 afs_global_owner = 0; \
114 lockmgr(&afs_global_lock, LK_RELEASE, 0, curproc); \
116 #define ISAFS_GLOCK() (afs_global_owner == curproc && curproc)
120 #define SPLVAR int splvar
122 #define NETPRI splvar=splnet()
124 #define USERPRI splx(splvar)
127 #define ifnet_flags(x) (x?(x)->if_flags:0)
129 #endif /* _OSI_MACHDEP_H_ */