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
48 #define vfs_bsize mnt_stat.f_bsize
49 #define vfs_fsid mnt_stat.f_fsid
51 #define vfs_vnodecovered mnt_vnodecovered
52 #define v_vfsp v_mount
55 #define VN_HOLD(vp) (vget(vp, 0))
56 #define VN_RELE(vp) (vrele(vp))
57 #define osi_vnhold(avc, r) (VN_HOLD(AFSTOV(avc)))
59 #define va_nodeid va_fileid
63 syscallarg(long) syscall
;
64 syscallarg(long) parm1
;
65 syscallarg(long) parm2
;
66 syscallarg(long) parm3
;
67 syscallarg(long) parm4
;
68 syscallarg(long) parm5
;
69 syscallarg(long) parm6
;
73 #define afsio_iov uio_iov
74 #define afsio_iovcnt uio_iovcnt
75 #define afsio_offset uio_offset
76 #define afsio_resid uio_resid
77 #define afsio_seg uio_segflg
78 #define AFS_UIOSYS UIO_SYSSPACE
79 #define AFS_UIOUSER UIO_USERSPACE
82 typedef struct lwp afs_proc_t
;
83 #define osi_curproc() curlwp
84 #define getpid() (osi_curproc())->l_proc->p_pid
85 #define osi_procname(procname, size) strncpy(procname, curproc->p_comm, size)
87 typedef struct kauth_cred afs_ucred_t
;
88 #define osi_curcred() (kauth_cred_get())
89 #define afs_suser(x) afs_osi_suser(osi_curcred())
90 #define osi_crgetruid(acred) (kauth_cred_getuid(acred))
91 #define osi_crgetrgid(acred) (kauth_cred_getgid(acred))
92 #define osi_crngroups(acred) (kauth_cred_ngroups(acred))
93 #define osi_proccred(aproc) ((aproc)->l_proc->p_cred)
94 #define osi_crgroupbyid kauth_cred_group
95 #define crdup kauth_cred_dup
96 #define crhold kauth_cred_hold
97 #define crfree kauth_cred_free
99 #define afs_cr_gid osi_crgetrgid
100 #define afs_cr_uid osi_crgetruid
104 #define osi_GetTime(x) getmicrotime(x)
105 #define osi_Time() time_second
108 #define afs_strcasecmp(s1, s2) strncasecmp((s1), (s2), 65535)
109 #define afs_strcat(s1, s2) strcat((s1), (s2))
112 #define afs_bufferpages bufpages
114 #define iodone biodone
116 #define printk printf /* for RX version of xdr_* */
117 #define setgroups sys_setgroups
120 /* This is not always in scope yet */
123 extern int afs_nbsd_lookupname(const char *fnamep
, enum uio_seg segflg
,
124 int followlink
, struct vnode
**compvpp
);
125 extern void afs_nbsd_getnewvnode(struct vcache
*tvc
);
127 #undef gop_lookupname
128 #undef gop_lookupname_user
129 #define osi_lookupname_user(fnamep, segflg, followlink, compvpp) \
130 afs_nbsd_lookupname((fnamep), (segflg), (followlink), (compvpp))
131 #define gop_lookupname_user osi_lookupname_user
132 #define gop_lookupname osi_lookupname_user
135 #ifdef AFS_GLOBAL_SUNLOCK
137 #if defined(AFS_NBSD50_ENV)
138 extern kmutex_t afs_global_mtx
;
139 #define AFS_GLOCK() \
141 mutex_enter(&afs_global_mtx); \
143 #define AFS_GUNLOCK() \
145 mutex_exit(&afs_global_mtx); \
147 #define ISAFS_GLOCK() (mutex_owned(&afs_global_mtx))
148 #define osi_InitGlock() \
150 mutex_init(&afs_global_mtx, MUTEX_DEFAULT, IPL_NONE); \
153 extern struct lock afs_global_lock
;
154 #if defined(LOCKDEBUG)
155 #define AFS_GLOCK() \
157 _lockmgr(&afs_global_lock, LK_EXCLUSIVE, NULL, __FILE__, __LINE__); \
159 #define AFS_GUNLOCK() \
161 _lockmgr(&afs_global_lock, LK_RELEASE, NULL, __FILE__, __LINE__); \
164 #define AFS_GLOCK() \
166 lockmgr(&afs_global_lock, LK_EXCLUSIVE, NULL); \
168 #define AFS_GUNLOCK() \
170 lockmgr(&afs_global_lock, LK_RELEASE, NULL); \
172 #endif /* LOCKDEBUG */
175 #define ISAFS_GLOCK() (lockstatus(&afs_global_lock) == LK_EXCLUSIVE)
176 extern struct lock afs_global_lock
;
177 #define AFS_GLOCKP(p)
178 #define AFS_GUNLOCKP(p)
179 #define AFS_ASSERT_GLOCK()
180 #define ISAFS_GLOCK() 1
181 #endif /* !AFS_GLOBAL_SUNLOCK */
184 #define SPLVAR int splvar
186 #define NETPRI splvar=splnet()
188 #define USERPRI splx(splvar)
191 #if !defined(ASSEMBLER) && !defined(__LANGUAGE_ASSEMBLY__) && !defined(IGNORE_STDS_H)
192 enum vcexcl
{ NONEXCL
, EXCL
};
195 #define MIN(A,B) ((A) < (B) ? (A) : (B))
198 #define MAX(A,B) ((A) > (B) ? (A) : (B))
201 #endif /* ASSEMBLER */
204 extern int (**afs_vnodeop_p
) __P((void *));
205 #define vType(vc) AFSTOV(vc)->v_type
206 #define vSetVfsp(vc, vfsp) AFSTOV(vc)->v_mount = (vfsp)
207 #define vSetType(vc, type) AFSTOV(vc)->v_type = (type)
208 #define IsAfsVnode(v) ((v)->v_op == afs_vnodeop_p)
209 #define SetAfsVnode(v) /* nothing; done in getnewvnode() */
211 extern int afs_debug
;
213 #define AFS_USE_NBSD_NAMECACHE 0
215 #endif /* _OSI_MACHDEP_H_ */