reindent-20030715
[openafs.git] / src / afs / HPUX / 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  * HPUX 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 #include "h/kern_sem.h"
22
23 #define afs_hz      hz
24 extern struct timeval time;
25 #define osi_Time() (time.tv_sec)
26
27 #ifdef PAGESIZE
28 #undef PAGESIZE
29 #endif
30 #define PAGESIZE 8192
31
32 #define AFS_UCRED       ucred
33 #define AFS_PROC        proc_t
34
35 #define osi_vnhold(avc, r)  do { VN_HOLD(AFSTOV(avc)); } while(0)
36 #define gop_rdwr(rw,gp,base,len,offset,segflg,unit,aresid) \
37   vn_rdwr((rw),(gp),(base),(len),(offset),(segflg),(unit),(aresid),0)
38
39 #undef  afs_suser
40
41 #define osi_curcred()           (p_cred(u.u_procp))
42
43 #define getpid()                (afs_uint32)p_pid(u.u_procp)
44
45 #define getppid()               (afs_uint32)p_ppid(u.u_procp)
46
47 #ifdef KERNEL
48 /*
49  * Global lock support. 
50  *
51  * HP uses global mutex to protect afs land
52  */
53
54 #if !defined(AFS_HPUX110_ENV)
55 extern sema_t afs_global_sema;
56 #else
57 extern b_sema_t afs_global_sema;
58 #endif
59
60 extern void osi_InitGlock(void);
61
62 #if !defined(AFS_HPUX110_ENV)
63 extern void afsHash(int nbuckets);
64 extern sv_sema_t *afsHashInsertFind(tid_t key);
65 extern sv_sema_t *afsHashFind(tid_t key);
66 extern void afsHashRelease(tid_t key);
67
68 #define AFS_GLOCK_PID   kt_tid(u.u_kthreadp)
69 #define AFS_SAVE_SEMA   afsHashInsertFind(AFS_GLOCK_PID)
70 #define AFS_FIND_SEMA   afsHashFind(AFS_GLOCK_PID)
71
72 #define AFS_GLOCK()     MP_PXSEMA(&afs_global_sema, AFS_SAVE_SEMA)
73 #define AFS_GUNLOCK()   (AFS_ASSERT_GLOCK(), MP_VXSEMA(&afs_global_sema,AFS_FIND_SEMA), (!uniprocessor ? (afsHashRelease(AFS_GLOCK_PID),0) : 0))
74 #define ISAFS_GLOCK()   (!uniprocessor ? owns_sema(&afs_global_sema):1)
75
76 #else
77 #define AFS_GLOCK()  b_psema(&afs_global_sema)
78 #define AFS_GUNLOCK() b_vsema(&afs_global_sema)
79 #define ISAFS_GLOCK() b_owns_sema(&afs_global_sema)
80
81 #endif
82
83 #define AFS_RXGLOCK()
84 #define AFS_RXGUNLOCK()
85 #define ISAFS_RXGLOCK() 1
86
87 /* Uses splnet only in the SP case */
88 #define SPLVAR      register ulong_t splvar
89 #define NETPRI      NET_SPLNET(splvar)
90 #define USERPRI     NET_SPLX(splvar)
91 #endif /* KERNEL */
92
93 #if !defined(AFS_HPUX110_ENV)
94 /* 
95  * On HP, the global lock is an alpha semaphore, hence it is automatically
96  * released and reacquired aroubd a sleep() and wakeup().
97  */
98
99 #define afs_osi_Sleep(x)        sleep((caddr_t) x,PZERO-2)
100 #else
101 /*
102  * On 11.22 global lock is a beta semaphore, hence we need to
103  * release and reacquire around sllep and wakeup. We also need to
104  * use the get_sleep_lock.
105  * afs_osi_Sleep and afs_osi_Wakeup are defined
106  */
107 void afs_osi_Sleep(void *event);
108 int afs_osi_Wakeup(void *event);
109 #endif
110
111 #define osi_NullHandle(x)       ((x)->proc == (caddr_t) 0)
112
113 #if !defined(AFS_HPUX110_ENV)
114 extern caddr_t kmem_alloc();
115 #endif
116 #include <sys/kthread_iface.h>  /* for kt_cred() */
117
118 /* Expected to be available as a patch from HP */
119 /* See section D of the top level README for details */
120 #if defined(AFS_HPUX110_ENV)
121 #include <sys/vfs_vm.h>
122 #else
123 #include <vfs_vm.h>
124 #endif
125
126 #endif /* _OSI_MACHDEP_H_ */