23060fdd8a18ddf7052f7515d1c0137cc4859db8
[openafs.git] / src / afs / AIX / 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  * AIX 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
22 #undef osi_ThreadUnique
23 #define osi_ThreadUnique()      thread_self()
24
25 #define afs_hz      HZ
26 extern long time;
27 #define osi_Time() (time)
28
29 typedef struct ucred afs_ucred_t;
30 typedef struct proc afs_proc_t;
31
32 #define afs_bufferpages v.v_bufhw
33
34 #undef gop_lookupname
35 #define gop_lookupname(fnamep,segflg,followlink,compvpp) \
36         lookupvp((fnamep), (followlink), (compvpp), &afs_osi_cred)
37
38 #undef gop_lookupname_user
39 #define gop_lookupname_user(fnamep,segflg,followlink,compvpp) \
40         lookupvp((fnamep), (followlink), (compvpp), &afs_osi_cred)
41
42 #undef afs_suser
43
44 #undef setuerror
45 #undef getuerror
46 /* #undef getpid                getpid() provided by native kernel */
47 #include <ulimit.h>
48 #define get_ulimit()            (ulimit(GET_FSIZE, 0) << UBSHIFT)
49
50 #include <sys/lockl.h>
51 #include <sys/lock_def.h>
52 #include <sys/lock_alloc.h>
53 #include <sys/sleep.h>
54
55 extern simple_lock_data afs_global_lock;
56 #define AFS_GLOCK()     do {                                            \
57                             if (lock_mine((void *)&afs_global_lock))    \
58                                 osi_Panic("AFS_GLOCK %s %d",            \
59                                           __FILE__, __LINE__);          \
60                             simple_lock((void *)&afs_global_lock);      \
61                         } while(0)
62 #define AFS_GUNLOCK()   do {                                            \
63                             if (!lock_mine((void *)&afs_global_lock))   \
64                                 osi_Panic("AFS_GUNLOCK %s %d",          \
65                                           __FILE__, __LINE__);          \
66                             simple_unlock((void *)&afs_global_lock);    \
67                         } while(0)
68 #define ISAFS_GLOCK()   lock_mine((void *)&afs_global_lock)
69
70 #if defined(AFS_AIX41_ENV)
71 #define osi_InitGlock() \
72         do {                                                            \
73             lock_alloc((void *)&afs_global_lock, LOCK_ALLOC_PIN, 1, 1); \
74             simple_lock_init((void *)&afs_global_lock);                 \
75         } while(0)
76 #else
77 #define osi_InitGlock() \
78         mutex_init(&afs_global_lock, "afs_global_lock", MUTEX_DEFAULT, NULL)
79 #endif
80
81 /* Reading the current proc name from kernelspace is difficult. It is
82  * probably possible via indexing into v.vb_proc, but for now don't bother.
83  * To actually obtain the proc name, look at afs_procsize_init and
84  * src/afs/AIX/osi_gcpags.c for how to look at the process list */
85 #define osi_procname(procname, size) strncpy(procname, "", size)
86
87 #define osi_GetTime(x)          do {curtime(x); (x)->tv_usec = (x)->tv_usec/1000;} while (0)
88
89 #endif /* _OSI_MACHDEP_H_ */