1001e676a794b8f405f1e6058b01f0d7dd04e0aa
[openafs.git] / src / afs / OBSD / 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  * OpenBSD 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 /* Id: $ */
20
21 #ifndef _OSI_MACHDEP_H_
22 #define _OSI_MACHDEP_H_
23
24 #include <sys/lock.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 M_AFSFID        (M_TEMP-1)
37 #define M_AFSBUFHDR     (M_TEMP-2)
38 #define M_AFSBUFFER     (M_TEMP-3)
39 #define M_AFSGENERIC    (M_TEMP-4)
40
41 #define PAGESIZE 8192
42
43 #define AFS_UCRED       ucred
44 #define AFS_PROC        struct proc
45
46 #define afs_bufferpages bufpages
47
48 #define osi_vnhold(avc,r)  do { \
49        if ((avc)->vrefCount) { VN_HOLD((struct vnode *)(avc)); } \
50        else osi_Panic("refcnt==0");  } while(0)
51
52 #define gop_rdwr(rw,gp,base,len,offset,segflg,unit,cred,aresid) \
53   vn_rdwr((rw),(gp),(base),(len),(offset),(segflg),(unit),(cred),(aresid), curproc)
54
55 #define afs_suser() afs_osi_suser(osi_curcred()) 
56
57 extern int (**afs_vnodeop_p)();
58 #define SetAfsVnode(vn) /* nothing; done in getnewvnode() */
59 #define IsAfsVnode(vn)      ((vn)->v_op == afs_vnodeop_p)
60
61 #define AFS_HOLD(vp) afs_nbsd_ref(vp)
62 #define AFS_RELE(vp) afs_nbsd_rele(vp)
63 extern void afs_nbsd_ref(struct vnode *);
64 extern void afs_nbsd_rele(struct vnode *);
65
66 #define va_nodeid va_fileid
67 #define v_vfsp v_mount
68 #define vfs_vnodecovered mnt_vnodecovered
69 #define vfs_bsize mnt_stat.f_bsize
70 typedef void (*osi_timeout_t)(void *);
71 #define osi_timeout_t_done
72 #define osi_curproc()           (curproc)
73 #define osi_curcred()           (curproc->p_cred->pc_ucred)
74 #define osi_vfs mount
75 #define osi_vfs_bsize mnt_stat.f_bsize
76 #define osi_vfs_fsid mnt_stat.f_fsid
77 #define afs_osi_alloc osi_Alloc
78 #define afs_osi_free osi_Free
79 #define printk printf                   /* for RX version of xdr_* */
80 #define vType(vc)               (vc)->v->v_type
81 #define vSetType(vc, type)      AFSTOV(vc)->v_type = (type)
82 #define vSetVfsp(vc, vfsp)      AFSTOV(vc)->v_mount = (vfsp)
83 #define FTRUNC O_TRUNC
84 #define FEXLOCK O_EXLOCK
85 #define FSHLOCK O_SHLOCK
86 #define UVM
87
88 /* no protoytpe 'cuz our includers don't always have uio_rw in scope first */
89 extern int afs_nbsd_rdwr();
90 extern int afs_nbsd_lookupname();
91 extern void afs_nbsd_getnewvnode();
92
93 #define VOP_RDWR afs_nbsd_rdwr
94 #define gop_lookupname(fnamep, segflg, followlink, dirvpp, compvpp) \
95         afs_nbsd_lookupname((fnamep), (segflg), (followlink), (dirvpp), (compvpp))
96
97 #ifdef KERNEL
98 extern struct simplelock afs_global_lock;
99
100 #ifndef AFS_GLOBAL_SUNLOCK
101 #define AFS_ASSERT_GLOCK()
102 #endif
103 #define AFS_GLOCK()
104 #define AFS_GUNLOCK()
105 #define AFS_RXGLOCK()
106 #define AFS_RXGUNLOCK()
107 #define ISAFS_RXGLOCK() 1
108 #define ISAFS_GLOCK() 1
109
110 #undef SPLVAR
111 #define SPLVAR
112 #undef NETPRI
113 #define NETPRI
114 #undef USERPRI
115 #define USERPRI
116 #endif /* KERNEL */
117
118 #endif /* _OSI_MACHDEP_H_ */