initial-freebsd-port-work-20010414
[openafs.git] / src / afs / FBSD / 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  *
12  * DUX OSI header file. Extends afs_osi.h.
13  *
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.
17  */
18
19 #ifndef _OSI_MACHDEP_H_
20 #define _OSI_MACHDEP_H_
21
22 #include <sys/lock.h>
23 /* #include <kern/sched_prim.h> */
24 /* #include <sys/unix_defs.h> */
25
26 #define getpid()                curproc
27 extern struct simplelock afs_rxglobal_lock;
28
29 /* 
30  * Time related macros
31  */
32 extern struct timeval time;
33 #define osi_Time() (time.tv_sec)
34 #define afs_hz      hz
35
36 #define PAGESIZE 8192
37
38 #define AFS_UCRED       ucred
39 #define AFS_PROC        struct proc
40
41 #define afs_bufferpages bufpages
42
43 #define osi_vnhold(avc,r)  do { \
44        if ((avc)->vrefCount) { VN_HOLD((struct vnode *)(avc)); } \
45        else osi_Panic("refcnt==0");  } while(0)
46
47 #define gop_rdwr(rw,gp,base,len,offset,segflg,unit,cred,aresid) \
48   vn_rdwr((rw),(gp),(base),(len),(offset),(segflg),(unit),(cred),(aresid), curproc)
49
50 #undef afs_suser
51
52 #ifdef KERNEL
53 extern struct simplelock afs_global_lock;
54 #if 0
55 extern thread_t afs_global_owner;
56 #define AFS_GLOCK() \
57     do { \
58         usimple_lock(&afs_global_lock); \
59         osi_Assert(afs_global_owner == (thread_t)0); \
60         afs_global_owner = current_thread(); \
61     } while (0)
62 #define AFS_GUNLOCK() \
63     do { \
64         osi_Assert(afs_global_owner == current_thread()); \
65         afs_global_owner = (thread_t)0; \
66         usimple_unlock(&afs_global_lock); \
67     } while(0)
68 #define ISAFS_GLOCK() (afs_global_owner == current_thread())
69 #else
70 #define AFS_GLOCK() \
71     do { \
72         simple_lock(&afs_global_lock); \
73     } while (0)
74 #define AFS_GUNLOCK() \
75     do { \
76         simple_unlock(&afs_global_lock); \
77     } while(0)
78 #endif /* 0 */
79 #define AFS_RXGLOCK()
80 #define AFS_RXGUNLOCK()
81 #define ISAFS_RXGLOCK() 1
82
83 #undef SPLVAR
84 #define SPLVAR
85 #undef NETPRI
86 #define NETPRI
87 #undef USERPRI
88 #define USERPRI
89 #endif /* KERNEL */
90
91 #endif /* _OSI_MACHDEP_H_ */