Merge 1.8.0~pre4 packaging into master
[pkg-k5-afs_openafs.git] / src / afs / NBSD / osi_machdep.h
blobd80ef358270fc54e07a01ab2d2facb411aad1979
1 /*
2 * Copyright 2000, International Business Machines Corporation and others.
3 * All Rights Reserved.
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
8 */
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
16 * afs_osi.h.
19 #ifndef _OSI_MACHDEP_H_
20 #define _OSI_MACHDEP_H_
22 #define RXK_LISTENER_ENV 1
23 #define AFS_DIRENT 1
25 #include <sys/lock.h>
26 #if defined(AFS_NBSD50_ENV)
27 #include <sys/kmem.h>
28 #include <sys/specificdata.h>
29 #include <sys/mutex.h>
30 #include <sys/rwlock.h>
31 #endif
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;
38 #define DEF_CADDR_T
39 # endif
40 #endif
42 /* vfs */
43 #define osi_vfs mount
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 #if 0
48 #define vfs_bsize mnt_stat.f_bsize
49 #define vfs_fsid mnt_stat.f_fsid
50 #endif
51 #define vfs_vnodecovered mnt_vnodecovered
52 #define v_vfsp v_mount
54 /* vnode */
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
61 /* syscall */
62 struct afs_sysargs {
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;
72 /* uio */
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
81 /* proc */
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
102 /* time */
103 #define afs_hz hz
104 #define osi_GetTime(x) getmicrotime(x)
105 #define osi_Time() time_second
107 /* str */
108 #define afs_strcasecmp(s1, s2) strncasecmp((s1), (s2), 65535)
109 #define afs_strcat(s1, s2) strcat((s1), (s2))
111 /* other */
112 #define afs_bufferpages bufpages
113 #ifndef iodone
114 #define iodone biodone
115 #endif
116 #define printk printf /* for RX version of xdr_* */
117 #define setgroups sys_setgroups
118 #define UVM
120 /* This is not always in scope yet */
121 struct vcache;
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
134 #ifdef KERNEL
135 #ifdef AFS_GLOBAL_SUNLOCK
137 #if defined(AFS_NBSD50_ENV)
138 extern kmutex_t afs_global_mtx;
139 #define AFS_GLOCK() \
140 do { \
141 mutex_enter(&afs_global_mtx); \
142 } while (0)
143 #define AFS_GUNLOCK() \
144 do { \
145 mutex_exit(&afs_global_mtx); \
146 } while (0)
147 #define ISAFS_GLOCK() (mutex_owned(&afs_global_mtx))
148 #define osi_InitGlock() \
149 do { \
150 mutex_init(&afs_global_mtx, MUTEX_DEFAULT, IPL_NONE); \
151 } while (0)
152 #else /* !50 */
153 extern struct lock afs_global_lock;
154 #if defined(LOCKDEBUG)
155 #define AFS_GLOCK() \
156 do { \
157 _lockmgr(&afs_global_lock, LK_EXCLUSIVE, NULL, __FILE__, __LINE__); \
158 } while(0);
159 #define AFS_GUNLOCK() \
160 do { \
161 _lockmgr(&afs_global_lock, LK_RELEASE, NULL, __FILE__, __LINE__); \
162 } while(0);
163 #else
164 #define AFS_GLOCK() \
165 do { \
166 lockmgr(&afs_global_lock, LK_EXCLUSIVE, NULL); \
167 } while(0);
168 #define AFS_GUNLOCK() \
169 do { \
170 lockmgr(&afs_global_lock, LK_RELEASE, NULL); \
171 } while(0);
172 #endif /* LOCKDEBUG */
173 #endif /* !50 */
174 #else
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 */
183 #undef SPLVAR
184 #define SPLVAR int splvar
185 #undef NETPRI
186 #define NETPRI splvar=splnet()
187 #undef USERPRI
188 #define USERPRI splx(splvar)
189 #endif /* KERNEL */
191 #if !defined(ASSEMBLER) && !defined(__LANGUAGE_ASSEMBLY__) && !defined(IGNORE_STDS_H)
192 enum vcexcl { NONEXCL, EXCL };
194 #ifndef MIN
195 #define MIN(A,B) ((A) < (B) ? (A) : (B))
196 #endif
197 #ifndef MAX
198 #define MAX(A,B) ((A) > (B) ? (A) : (B))
199 #endif
201 #endif /* ASSEMBLER */
203 /* vnodes */
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_ */