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 * NetBSD 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_
22 #define RXK_LISTENER_ENV 1
26 #if defined(AFS_NBSD50_ENV)
28 #include <sys/specificdata.h>
29 #include <sys/mutex.h>
30 #include <sys/rwlock.h>
32 #include <sys/syscall.h>
33 #include <sys/syscallargs.h>
35 #if defined(AFS_NBSD50_ENV)
36 # if !defined(DEF_CADDR_T)
37 typedef char * caddr_t;
44 #define osi_vfs_bsize mnt_stat.f_bsize
45 #define osi_vfs_iosize mnt_stat.f_iosize
46 #define osi_vfs_fsid mnt_stat.f_fsid
47 #define vfs_vnodecovered mnt_vnodecovered
48 #define v_vfsp v_mount
51 #define VN_HOLD(vp) (vget(vp, 0))
52 #define VN_RELE(vp) (vrele(vp))
53 #define osi_vnhold(avc, r) (VN_HOLD(AFSTOV(avc)))
55 #define va_nodeid va_fileid
59 syscallarg(long) syscall;
60 syscallarg(long) parm1;
61 syscallarg(long) parm2;
62 syscallarg(long) parm3;
63 syscallarg(long) parm4;
64 syscallarg(long) parm5;
65 syscallarg(long) parm6;
69 #define afsio_iov uio_iov
70 #define afsio_iovcnt uio_iovcnt
71 #define afsio_offset uio_offset
72 #define afsio_resid uio_resid
73 #define afsio_seg uio_segflg
74 #define AFS_UIOSYS UIO_SYSSPACE
75 #define AFS_UIOUSER UIO_USERSPACE
78 typedef struct lwp afs_proc_t;
79 #define osi_curproc() curlwp
80 #define getpid() (osi_curproc())->l_proc->p_pid
81 #define osi_procname(procname, size) strncpy(procname, curproc->p_comm, size)
83 typedef struct kauth_cred afs_ucred_t;
84 #define osi_curcred() (kauth_cred_get())
85 #define afs_suser(x) afs_osi_suser(osi_curcred())
86 #define osi_crgetruid(acred) (kauth_cred_getuid(acred))
87 #define osi_crgetrgid(acred) (kauth_cred_getgid(acred))
88 #define osi_crngroups(acred) (kauth_cred_ngroups(acred))
89 #define osi_proccred(aproc) ((aproc)->l_proc->p_cred)
90 #define osi_crgroupbyid kauth_cred_group
91 #define crdup kauth_cred_dup
92 #define crhold kauth_cred_hold
93 #define crfree kauth_cred_free
95 #define afs_cr_gid osi_crgetrgid
96 #define afs_cr_uid osi_crgetruid
100 #define osi_GetTime(x) getmicrotime(x)
101 #define osi_Time() time_second
104 #define afs_strcasecmp(s1, s2) strncasecmp((s1), (s2), 65535)
105 #define afs_strcat(s1, s2) strcat((s1), (s2))
108 #define afs_bufferpages bufpages
110 #define iodone biodone
112 #define printk printf /* for RX version of xdr_* */
113 #define setgroups sys_setgroups
116 /* This is not always in scope yet */
119 extern int afs_nbsd_lookupname(const char *fnamep, enum uio_seg segflg,
120 int followlink, struct vnode **compvpp);
121 extern void afs_nbsd_getnewvnode(struct vcache *tvc);
123 #undef gop_lookupname
124 #undef gop_lookupname_user
125 #define osi_lookupname_user(fnamep, segflg, followlink, compvpp) \
126 afs_nbsd_lookupname((fnamep), (segflg), (followlink), (compvpp))
127 #define gop_lookupname_user osi_lookupname_user
128 #define gop_lookupname osi_lookupname_user
131 #ifdef AFS_GLOBAL_SUNLOCK
133 #if defined(AFS_NBSD50_ENV)
134 extern kmutex_t afs_global_mtx;
135 #define AFS_GLOCK() \
137 mutex_enter(&afs_global_mtx); \
139 #define AFS_GUNLOCK() \
141 mutex_exit(&afs_global_mtx); \
143 #define ISAFS_GLOCK() (mutex_owned(&afs_global_mtx))
144 #define osi_InitGlock() \
146 mutex_init(&afs_global_mtx, MUTEX_DEFAULT, IPL_NONE); \
149 extern struct lock afs_global_lock;
150 #if defined(LOCKDEBUG)
151 #define AFS_GLOCK() \
153 _lockmgr(&afs_global_lock, LK_EXCLUSIVE, NULL, __FILE__, __LINE__); \
155 #define AFS_GUNLOCK() \
157 _lockmgr(&afs_global_lock, LK_RELEASE, NULL, __FILE__, __LINE__); \
160 #define AFS_GLOCK() \
162 lockmgr(&afs_global_lock, LK_EXCLUSIVE, NULL); \
164 #define AFS_GUNLOCK() \
166 lockmgr(&afs_global_lock, LK_RELEASE, NULL); \
168 #endif /* LOCKDEBUG */
171 #define ISAFS_GLOCK() (lockstatus(&afs_global_lock) == LK_EXCLUSIVE)
172 extern struct lock afs_global_lock;
173 #define AFS_GLOCKP(p)
174 #define AFS_GUNLOCKP(p)
175 #define AFS_ASSERT_GLOCK()
176 #define ISAFS_GLOCK() 1
177 #endif /* !AFS_GLOBAL_SUNLOCK */
180 #define SPLVAR int splvar
182 #define NETPRI splvar=splnet()
184 #define USERPRI splx(splvar)
187 #if !defined(ASSEMBLER) && !defined(__LANGUAGE_ASSEMBLY__) && !defined(IGNORE_STDS_H)
188 enum vcexcl { NONEXCL, EXCL };
191 #define MIN(A,B) ((A) < (B) ? (A) : (B))
194 #define MAX(A,B) ((A) > (B) ? (A) : (B))
197 #endif /* ASSEMBLER */
200 extern int (**afs_vnodeop_p) __P((void *));
201 #define vType(vc) AFSTOV(vc)->v_type
202 #define vSetVfsp(vc, vfsp) AFSTOV(vc)->v_mount = (vfsp)
203 #define vSetType(vc, type) AFSTOV(vc)->v_type = (type)
204 #define IsAfsVnode(v) ((v)->v_op == afs_vnodeop_p)
205 #define SetAfsVnode(v) /* nothing; done in getnewvnode() */
207 extern int afs_debug;
209 #define AFS_USE_NBSD_NAMECACHE 0
211 #endif /* _OSI_MACHDEP_H_ */