darwin-updates-20020821
[openafs.git] / src / afs / DARWIN / osi_machdep.h
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
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  */
9 /*
10  *
11  * MACOS OSI header file. Extends afs_osi.h.
12  *
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
15  * afs_osi.h.
16  */
17
18 #ifndef _OSI_MACHDEP_H_
19 #define _OSI_MACHDEP_H_
20
21 #ifdef XAFS_DARWIN_ENV
22 #ifndef _MACH_ETAP_H_
23 #define _MACH_ETAP_H_
24 typedef unsigned short                  etap_event_t;
25 #endif
26 #endif
27
28 #include <sys/lock.h>
29 #include <kern/thread.h>
30 #include <sys/user.h>
31
32 #define getpid()                current_proc()->p_pid
33 #define getppid()               current_proc()->p_pptr->p_pid
34 #undef gop_lookupname
35 #define gop_lookupname osi_lookupname
36
37 #define FTRUNC 0
38
39 /* vcexcl - used only by afs_create */
40 enum vcexcl { EXCL, NONEXCL } ;
41
42 /* 
43  * Time related macros
44  */
45 #ifndef AFS_DARWIN60_ENV
46 extern struct timeval time;
47 #endif
48 #define osi_Time() (time.tv_sec)
49 #define afs_hz      hz
50
51 #define PAGESIZE 8192
52
53 #define AFS_UCRED       ucred
54
55 #define AFS_PROC        struct proc
56
57 #define osi_vnhold(avc,r)  do { \
58        if ((avc)->vrefCount) { VN_HOLD(&((avc)->v)); } \
59        else (avc)->vrefCount = 1;  } while(0)
60
61 #define gop_rdwr(rw,gp,base,len,offset,segflg,unit,cred,aresid) \
62   vn_rdwr((rw),(gp),(base),(len),(offset),(segflg),(unit),(cred),(aresid),current_proc())
63
64 #undef afs_suser
65
66 #ifdef KERNEL
67 extern thread_t afs_global_owner;
68 /* simple locks cannot be used since sleep can happen at any time */
69 /* Should probably use mach locks rather than bsd locks, since we use the
70    mach thread control api's elsewhere (mach locks not used for consistency
71    with rx, since rx needs lock_write_try() in order to use mach locks
72  */
73 extern struct lock__bsd__ afs_global_lock;
74 #define AFS_GLOCK() \
75     do { \
76         lockmgr(&afs_global_lock, LK_EXCLUSIVE, 0, current_proc()); \
77         osi_Assert(afs_global_owner == 0); \
78         afs_global_owner = current_thread(); \
79     } while (0)
80 #define AFS_GUNLOCK() \
81     do { \
82         osi_Assert(afs_global_owner == current_thread()); \
83         afs_global_owner = 0; \
84         lockmgr(&afs_global_lock, LK_RELEASE, 0, current_proc()); \
85     } while(0)
86 #define ISAFS_GLOCK() (afs_global_owner == current_thread())
87 #define AFS_RXGLOCK()
88 #define AFS_RXGUNLOCK()
89 #define ISAFS_RXGLOCK() 1
90
91 #define SPLVAR
92 #define NETPRI
93 #define USERPRI
94 #if 0
95 #undef SPLVAR
96 #define SPLVAR int x;
97 #undef NETPRI
98 #define NETPRI x=splnet();
99 #undef USERPRI
100 #define USERPRI splx(x);
101 #endif
102
103 #define AFS_APPL_UFS_CACHE 1
104 #define AFS_APPL_HFS_CACHE 2
105
106 extern ino_t VnodeToIno(vnode_t *vp);
107 extern dev_t VnodeToDev(vnode_t *vp);
108
109 #endif /* KERNEL */
110
111 #endif /* _OSI_MACHDEP_H_ */