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 * OpenBSD 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
21 #ifndef _OSI_MACHDEP_H_
22 #define _OSI_MACHDEP_H_
26 #define M_AFSFID (M_TEMP-1)
27 #define M_AFSBUFHDR (M_TEMP-2)
28 #define M_AFSBUFFER (M_TEMP-3)
29 #define M_AFSGENERIC (M_TEMP-4)
33 #define osi_vfs_bsize mnt_stat.f_bsize
34 #define osi_vfs_fsid mnt_stat.f_fsid
35 #define vfs_bsize mnt_stat.f_bsize
36 #define vfs_fsid mnt_stat.f_fsid
37 #define vfs_vnodecovered mnt_vnodecovered
38 #define v_vfsp v_mount
41 #define VN_HOLD(vp) afs_vget((vp), 0)
42 #define VN_RELE(vp) vrele(vp)
43 #define osi_vnhold(avc, r) afs_vget(AFSTOV(avc), 0)
44 #define va_nodeid va_fileid
45 #define vnode_t struct vnode
48 #define afsio_iov uio_iov
49 #define afsio_iovcnt uio_iovcnt
50 #define afsio_offset uio_offset
51 #define afsio_resid uio_resid
52 #define afsio_seg uio_segflg
53 #define AFS_UIOSYS UIO_SYSSPACE
54 #define AFS_UIOUSER UIO_USERSPACE
57 inline void afs_osi_Free(void *buf, size_t asize);
58 inline void afs_osi_FreeStr(char *x);
59 extern void *osi_obsd_Alloc(size_t asize, int cansleep);
60 extern void osi_obsd_Free(void *p, size_t asize);
62 #define afs_osi_Alloc_NoSleep(asize) osi_obsd_Alloc((asize), 0)
63 #define afs_osi_Alloc(asize) osi_obsd_Alloc((asize), 1)
64 #define afs_osi_FreeStr(s) afs_osi_Free((s), strlen((s)) + 1)
65 #define afs_osi_Free(buf, asize) osi_obsd_Free((buf), (asize))
69 #define AFS_KALLOC(s) osi_obsd_Alloc((s), 1 /* cansleep */)
74 #define AFS_KFREE(p, s) (osi_obsd_Free((p), (s)))
78 /* removed, live with it */
79 #define BSD_KMALLOC(p, ptype, msize, mtype, mflags) \
80 (p) = malloc((msize), (mtype), (mflags))
82 #define BSD_KFREE(p, mflags) \
85 #define BSD_KMALLOC MALLOC
86 #define BSD_KFREE KFREE
87 #endif /* AFS_OBSD42_ENV */
90 typedef struct proc afs_proc_t;
91 typedef struct ucred afs_ucred_t;
93 #define afs_suser(x) afs_osi_suser(osi_curcred())
94 #define getpid() curproc
95 #define osi_curcred() (curproc->p_cred->pc_ucred)
96 #define osi_curproc() curproc
97 #define p_rcred p_ucred
101 #define osi_GetTime(x) microtime(x)
102 extern time_t osi_Time();
105 #define afs_strcasecmp(s1, s2) strncasecmp((s1), (s2), 65535)
106 #ifdef AFS_OBSD34_ENV
107 #define strcpy(s1, s2) afs_strcpy((s1), (s2))
108 #define strcat(s1, s2) afs_strcat((s1), (s2))
110 #define afs_strcat(s1, s2) strcat((s1), (s2))
114 #define afs_bufferpages bufpages
116 #define iodone biodone
118 #define printk printf /* for RX version of xdr_* */
119 #define setgroups sys_setgroups
122 /* This is not always in scope yet */
125 extern int afs_obsd_lookupname(char *fnamep, enum uio_seg segflg,
126 int followlink, struct vnode **compvpp);
127 extern void afs_obsd_getnewvnode(struct vcache *tvc);
128 extern void *afs_obsd_Alloc(size_t asize);
129 extern void afs_obsd_Free(void *p, size_t asize);
130 extern int afs_vget();
132 #undef gop_lookupname
133 #define gop_lookupname(fnamep, segflg, followlink, compvpp) \
134 afs_nbsd_lookupname((fnamep), (segflg), (followlink), (compvpp))
136 #undef gop_lookupname_user
137 #define gop_lookupname_user(fnamep, segflg, followlink, compvpp) \
138 afs_nbsd_lookupname((fnamep), (segflg), (followlink), (compvpp))
140 #ifdef AFS_OBSD39_ENV
141 #define afs_osi_lockmgr(l, f, i, p) lockmgr((l), (f), (i))
143 #define afs_osi_lockmgr(l, f, i, p) lockmgr((l), (f), (i), (p))
148 #ifdef AFS_OBSD44_ENV
149 /* Revert to classical, BSD locks */
151 extern struct lock afs_global_lock;
152 extern struct proc *afs_global_owner;
154 #ifdef AFS_GLOBAL_SUNLOCK
156 #if defined(LOCKDEBUG)
158 #define AFS_GLOCK() \
160 _lockmgr(&afs_global_lock, LK_EXCLUSIVE, NULL, __FILE__, __LINE__); \
162 #define AFS_GUNLOCK() \
164 _lockmgr(&afs_global_lock, LK_RELEASE, NULL, __FILE__, __LINE__); \
169 #define AFS_GLOCK() \
171 lockmgr(&afs_global_lock, LK_EXCLUSIVE, NULL); \
173 #define AFS_GUNLOCK() \
175 lockmgr(&afs_global_lock, LK_RELEASE, NULL); \
177 #endif /* LOCKDEBUG */
178 #define ISAFS_GLOCK() (lockstatus(&afs_global_lock) == LK_EXCLUSIVE)
180 extern struct lock afs_global_lock;
181 #define AFS_GLOCKP(p)
182 #define AFS_GUNLOCKP(p)
183 #define AFS_ASSERT_GLOCK()
184 #define ISAFS_GLOCK() 1
188 /* I don't see doing locks this way for older kernels, either,
189 * but, smart folks wrote this
191 #define AFS_GLOCK() AFS_GLOCKP(curproc)
192 #define AFS_GUNLOCK() AFS_GUNLOCKP(curproc)
193 #ifdef AFS_GLOBAL_SUNLOCK
194 extern struct proc *afs_global_owner;
195 extern struct lock afs_global_lock;
196 #define AFS_GLOCKP(p) \
199 afs_osi_lockmgr(&afs_global_lock, LK_EXCLUSIVE, 0, (p)); \
200 osi_Assert(afs_global_owner == NULL); \
201 afs_global_owner = (p); \
203 #define AFS_GUNLOCKP(p) \
206 osi_Assert(afs_global_owner == (p)); \
207 afs_global_owner = NULL; \
208 afs_osi_lockmgr(&afs_global_lock, LK_RELEASE, 0, (p)); \
210 #define ISAFS_GLOCK() (afs_global_owner == curproc && curproc)
212 extern struct lock afs_global_lock;
213 #define AFS_GLOCKP(p)
214 #define AFS_GUNLOCKP(p)
215 #define AFS_ASSERT_GLOCK()
216 #define ISAFS_GLOCK() 1
219 #endif /* AFS_OBSD44_ENV */
222 #define SPLVAR int splvar
224 #define NETPRI splvar=splnet()
226 #define USERPRI splx(splvar)
229 #define osi_InitGlock() \
231 lockinit(&afs_global_lock, PLOCK, "afs global lock", 0, 0); \
232 afs_global_owner = 0; \
236 extern int (**afs_vnodeop_p) ();
237 #define vType(vc) AFSTOV(vc)->v_type
238 #define vSetVfsp(vc, vfsp) AFSTOV(vc)->v_mount = (vfsp)
239 #define vSetType(vc, type) AFSTOV(vc)->v_type = (type)
240 #define IsAfsVnode(v) ((v)->v_op == afs_vnodeop_p)
241 #define SetAfsVnode(v) /* nothing; done in getnewvnode() */
243 #endif /* _OSI_MACHDEP_H_ */