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 #define AFS_PROC struct proc
91 #define AFS_UCRED struct ucred
92 #define afs_suser(x) afs_osi_suser(osi_curcred())
93 #define getpid() curproc
94 #define osi_curcred() (curproc->p_cred->pc_ucred)
95 #define osi_curproc() curproc
96 #define p_rcred p_ucred
100 #define osi_GetTime(x) microtime(x)
101 extern time_t osi_Time();
104 #define afs_strcasecmp(s1, s2) strncasecmp((s1), (s2), 65535)
105 #ifdef AFS_OBSD34_ENV
106 #define strcpy(s1, s2) afs_strcpy((s1), (s2))
107 #define strcat(s1, s2) afs_strcat((s1), (s2))
109 #define afs_strcat(s1, s2) strcat((s1), (s2))
113 #define afs_bufferpages bufpages
115 #define iodone biodone
117 #define printk printf /* for RX version of xdr_* */
118 #define setgroups sys_setgroups
121 /* This is not always in scope yet */
124 extern int afs_obsd_lookupname(char *fnamep, enum uio_seg segflg,
125 int followlink, struct vnode **compvpp);
126 extern void afs_obsd_getnewvnode(struct vcache *tvc);
127 extern void *afs_obsd_Alloc(size_t asize);
128 extern void afs_obsd_Free(void *p, size_t asize);
129 extern int afs_vget();
131 #undef gop_lookupname
132 #define gop_lookupname(fnamep, segflg, followlink, compvpp) \
133 afs_nbsd_lookupname((fnamep), (segflg), (followlink), (compvpp))
135 #undef gop_lookupname_user
136 #define gop_lookupname_user(fnamep, segflg, followlink, compvpp) \
137 afs_nbsd_lookupname((fnamep), (segflg), (followlink), (compvpp))
139 #ifdef AFS_OBSD39_ENV
140 #define afs_osi_lockmgr(l, f, i, p) lockmgr((l), (f), (i))
142 #define afs_osi_lockmgr(l, f, i, p) lockmgr((l), (f), (i), (p))
147 #ifdef AFS_OBSD44_ENV
148 /* Revert to classical, BSD locks */
150 extern struct lock afs_global_lock;
151 extern struct proc *afs_global_owner;
153 #ifdef AFS_GLOBAL_SUNLOCK
155 #if defined(LOCKDEBUG)
157 #define AFS_GLOCK() \
159 _lockmgr(&afs_global_lock, LK_EXCLUSIVE, NULL, __FILE__, __LINE__); \
161 #define AFS_GUNLOCK() \
163 _lockmgr(&afs_global_lock, LK_RELEASE, NULL, __FILE__, __LINE__); \
168 #define AFS_GLOCK() \
170 lockmgr(&afs_global_lock, LK_EXCLUSIVE, NULL); \
172 #define AFS_GUNLOCK() \
174 lockmgr(&afs_global_lock, LK_RELEASE, NULL); \
176 #endif /* LOCKDEBUG */
177 #define ISAFS_GLOCK() (lockstatus(&afs_global_lock) == LK_EXCLUSIVE)
179 extern struct lock afs_global_lock;
180 #define AFS_GLOCKP(p)
181 #define AFS_GUNLOCKP(p)
182 #define AFS_ASSERT_GLOCK()
183 #define ISAFS_GLOCK() 1
187 /* I don't see doing locks this way for older kernels, either,
188 * but, smart folks wrote this
190 #define AFS_GLOCK() AFS_GLOCKP(curproc)
191 #define AFS_GUNLOCK() AFS_GUNLOCKP(curproc)
192 #ifdef AFS_GLOBAL_SUNLOCK
193 extern struct proc *afs_global_owner;
194 extern struct lock afs_global_lock;
195 #define AFS_GLOCKP(p) \
198 afs_osi_lockmgr(&afs_global_lock, LK_EXCLUSIVE, 0, (p)); \
199 osi_Assert(afs_global_owner == NULL); \
200 afs_global_owner = (p); \
202 #define AFS_GUNLOCKP(p) \
205 osi_Assert(afs_global_owner == (p)); \
206 afs_global_owner = NULL; \
207 afs_osi_lockmgr(&afs_global_lock, LK_RELEASE, 0, (p)); \
209 #define ISAFS_GLOCK() (afs_global_owner == curproc && curproc)
211 extern struct lock afs_global_lock;
212 #define AFS_GLOCKP(p)
213 #define AFS_GUNLOCKP(p)
214 #define AFS_ASSERT_GLOCK()
215 #define ISAFS_GLOCK() 1
218 #endif /* AFS_OBSD44_ENV */
221 #define SPLVAR int splvar
223 #define NETPRI splvar=splnet()
225 #define USERPRI splx(splvar)
228 #endif /* _OSI_MACHDEP_H_ */