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 typedef struct ucred afs_ucred_t;
35 typedef struct proc afs_proc_t;
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
53 #undef gop_lookupname_user
54 #define gop_lookupname osi_lookupname_user
58 #define afs_strcat(s1, s2) strcat((s1), (s2))
62 #undef afs_osi_Alloc_NoSleep
63 #define afs_osi_Alloc_NoSleep(size) osi_fbsd_alloc((size), 0)
71 #define VN_RELE(vp) vrele(vp)
73 #define VN_HOLD(vp) VREF(vp)
77 #define IsAfsVnode(v) ((v)->v_op == &afs_vnodeops)
78 extern struct vop_vector afs_vnodeops;
82 #if defined(AFS_FBSD50_ENV)
85 #define v_flag v_vflag
86 #define osi_curcred() (curthread->td_ucred)
87 #define afs_suser(x) (!suser(curthread))
88 #define osi_getpid() (curthread->td_proc->p_pid)
89 #define simple_lock(x) mtx_lock(x)
90 #define simple_unlock(x) mtx_unlock(x)
91 #define gop_rdwr(rw,gp,base,len,offset,segflg,unit,cred,aresid) \
92 vn_rdwr((rw),(gp),(base),(len),(offset),(segflg),(unit),(cred),(cred),(aresid), curthread)
93 extern struct mtx afs_global_mtx;
94 #define AFS_GLOCK() mtx_lock(&afs_global_mtx)
95 #define AFS_GUNLOCK() mtx_unlock(&afs_global_mtx)
96 #define ISAFS_GLOCK() (mtx_owned(&afs_global_mtx))
98 extern struct lock afs_global_lock;
99 #define osi_curcred() (curproc->p_cred->pc_ucred)
100 #define afs_suser(x) (!suser(curproc))
101 #define osi_getpid() (curproc->p_pid)
102 #define gop_rdwr(rw,gp,base,len,offset,segflg,unit,cred,aresid) \
103 vn_rdwr((rw),(gp),(base),(len),(offset),(segflg),(unit),(cred),(aresid), curproc)
104 extern struct proc *afs_global_owner;
105 #define AFS_GLOCK() \
107 osi_Assert(curproc); \
108 lockmgr(&afs_global_lock, LK_EXCLUSIVE, 0, curproc); \
109 osi_Assert(afs_global_owner == 0); \
110 afs_global_owner = curproc; \
112 #define AFS_GUNLOCK() \
114 osi_Assert(curproc); \
115 osi_Assert(afs_global_owner == curproc); \
116 afs_global_owner = 0; \
117 lockmgr(&afs_global_lock, LK_RELEASE, 0, curproc); \
119 #define ISAFS_GLOCK() (afs_global_owner == curproc && curproc)
123 #define SPLVAR int splvar
125 #define NETPRI splvar=splnet()
127 #define USERPRI splx(splvar)
130 #define ifnet_flags(x) (x?(x)->if_flags:0)
132 #endif /* _OSI_MACHDEP_H_ */