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
11 * MACOS OSI header file. Extends afs_osi.h.
13 * afs_osi.h includes this file, which is the only way this file should
14 * be included in a source file. This file can redefine macros declared in
18 #ifndef _OSI_MACHDEP_H_
19 #define _OSI_MACHDEP_H_
21 #ifdef XAFS_DARWIN_ENV
24 typedef unsigned short etap_event_t;
28 #ifdef AFS_DARWIN80_ENV
29 #include <kern/locks.h>
33 #include <kern/thread.h>
36 #ifdef AFS_DARWIN80_ENV
37 #define getpid() proc_selfpid()
38 #define getppid() proc_selfppid()
40 #define getpid() current_proc()->p_pid
41 #define getppid() current_proc()->p_pptr->p_pid
44 #define gop_lookupname osi_lookupname
48 /* vcexcl - used only by afs_create */
49 enum vcexcl { EXCL, NONEXCL };
51 #ifdef AFS_DARWIN80_ENV
52 #define vrele vnode_rele
53 #define vput vnode_put
54 #define vref vnode_ref
60 #ifndef AFS_DARWIN60_ENV
61 extern struct timeval time;
63 #define osi_Time() (time.tv_sec)
68 #define AFS_UCRED ucred
70 #define AFS_PROC struct proc
72 #define osi_vnhold(avc,r) VN_HOLD(AFSTOV(avc))
73 #define VN_HOLD(vp) darwin_vn_hold(vp)
74 #define VN_RELE(vp) vrele(vp);
77 #define gop_rdwr(rw,gp,base,len,offset,segflg,unit,cred,aresid) \
78 vn_rdwr((rw),(gp),(base),(len),(offset),(segflg),(unit),(cred),(aresid),current_proc())
83 extern thread_t afs_global_owner;
84 /* simple locks cannot be used since sleep can happen at any time */
85 #ifdef AFS_DARWIN80_ENV
86 /* mach locks still don't have an exported try, but we are forced to use them */
87 extern lck_mtx_t *afs_global_lock;
90 lk_mtx_lock(afs_global_lock); \
91 osi_Assert(afs_global_owner == 0); \
92 afs_global_owner = current_thread(); \
94 #define AFS_GUNLOCK() \
96 osi_Assert(afs_global_owner == current_thread()); \
97 afs_global_owner = 0; \
98 lk_mtx_unlock(afs_global_lock); \
101 /* Should probably use mach locks rather than bsd locks, since we use the
102 mach thread control api's elsewhere (mach locks not used for consistency
103 with rx, since rx needs lock_write_try() in order to use mach locks
105 extern struct lock__bsd__ afs_global_lock;
106 #define AFS_GLOCK() \
108 lockmgr(&afs_global_lock, LK_EXCLUSIVE, 0, current_proc()); \
109 osi_Assert(afs_global_owner == 0); \
110 afs_global_owner = current_thread(); \
112 #define AFS_GUNLOCK() \
114 osi_Assert(afs_global_owner == current_thread()); \
115 afs_global_owner = 0; \
116 lockmgr(&afs_global_lock, LK_RELEASE, 0, current_proc()); \
119 #define ISAFS_GLOCK() (afs_global_owner == current_thread())
126 #define SPLVAR int x;
128 #define NETPRI x=splnet();
130 #define USERPRI splx(x);
133 #define AFS_APPL_UFS_CACHE 1
134 #define AFS_APPL_HFS_CACHE 2
136 extern ino_t VnodeToIno(vnode_t * vp);
137 extern dev_t VnodeToDev(vnode_t * vp);
139 #define osi_curproc() current_proc()
142 #define osi_curcred() &afs_osi_cred
146 #endif /* _OSI_MACHDEP_H_ */