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>
28 extern struct simplelock afs_rxglobal_lock;
33 #define osi_Time() time_second
38 #define AFS_UCRED ucred
39 #define AFS_PROC struct proc
41 #define afs_bufferpages bufpages
43 #define iodone biodone
46 #define osi_vnhold(avc,r) vref(AFSTOV(avc))
48 #define vSetVfsp(vc, vfsp) AFSTOV(vc)->v_mount = (vfsp)
50 #define vSetType(vc, type) AFSTOV(vc)->v_type = (type)
52 #define vType(vc) AFSTOV(vc)->v_type
55 #define gop_lookupname osi_lookupname
59 #define afs_strcat(s1, s2) strcat((s1), (s2))
63 #undef afs_osi_Alloc_NoSleep
64 #define afs_osi_Alloc_NoSleep(size) osi_fbsd_alloc((size), 0)
66 #define VN_RELE(vp) vrele(vp)
67 #define VN_HOLD(vp) VREF(vp)
71 #define IsAfsVnode(v) ((v)->v_op == &afs_vnodeops)
72 extern struct vop_vector afs_vnodeops;
76 #if defined(AFS_FBSD50_ENV)
79 #define v_flag v_vflag
80 #define osi_curcred() (curthread->td_ucred)
81 #define afs_suser(x) (!suser(curthread))
82 #define osi_getpid() (curthread->td_proc->p_pid)
83 #define simple_lock(x) mtx_lock(x)
84 #define simple_unlock(x) mtx_unlock(x)
85 #define gop_rdwr(rw,gp,base,len,offset,segflg,unit,cred,aresid) \
86 vn_rdwr((rw),(gp),(base),(len),(offset),(segflg),(unit),(cred),(cred),(aresid), curthread)
87 extern struct mtx afs_global_mtx;
88 #define AFS_GLOCK() mtx_lock(&afs_global_mtx)
89 #define AFS_GUNLOCK() mtx_unlock(&afs_global_mtx)
90 #define ISAFS_GLOCK() (mtx_owned(&afs_global_mtx))
93 extern struct lock afs_global_lock;
95 #define osi_curcred() (curproc->p_cred->pc_ucred)
96 #define afs_suser(x) (!suser(curproc))
97 #define osi_getpid() (curproc->p_pid)
98 #define gop_rdwr(rw,gp,base,len,offset,segflg,unit,cred,aresid) \
99 vn_rdwr((rw),(gp),(base),(len),(offset),(segflg),(unit),(cred),(aresid), curproc)
100 extern struct proc *afs_global_owner;
101 #define AFS_GLOCK() \
103 osi_Assert(curproc); \
104 lockmgr(&afs_global_lock, LK_EXCLUSIVE, 0, curproc); \
105 osi_Assert(afs_global_owner == 0); \
106 afs_global_owner = curproc; \
108 #define AFS_GUNLOCK() \
110 osi_Assert(curproc); \
111 osi_Assert(afs_global_owner == curproc); \
112 afs_global_owner = 0; \
113 lockmgr(&afs_global_lock, LK_RELEASE, 0, curproc); \
115 #define ISAFS_GLOCK() (afs_global_owner == curproc && curproc)
119 #define SPLVAR int splvar
121 #define NETPRI splvar=splnet()
123 #define USERPRI splx(splvar)
126 #endif /* _OSI_MACHDEP_H_ */