97fa93f6917022d798d7fdee3b7a8fcd0e4b0fb8
[openafs.git] / src / afs / UKERNEL / 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  * UKERNEL 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 "afs/sysincludes.h"
22
23 #define MAX_OSI_PATH            1024
24 #define MAX_OSI_FILES           1024
25 #define MAX_OSI_LINKS           25
26 #define OSI_WAITHASH_SIZE       128     /* must be power of two */
27 #define MAX_HOSTADDR            32
28
29 /* XXX
30  *
31  * UKERNEL cannot trivially make use of typedef for afs_ucred_t and
32  * afs_proc_t, as in the present design, the types are already introduced
33  * with incorrect reference, so fall back to preprocessor for now
34  */
35
36 #define afs_ucred_t struct usr_ucred
37 #define afs_proc_t struct usr_proc
38
39 #define AFS_KALLOC(A)           afs_osi_Alloc(A)
40
41 /*
42  * Time related macros
43  */
44 #define afs_hz      HZ
45 #define osi_Time() (time(NULL))
46
47 #undef gop_lookupname
48 #define gop_lookupname(fnamep,segflg,followlink,compvpp) lookupname((fnamep),(segflg),(followlink),(compvpp))
49 #undef gop_lookupname_user
50 #define gop_lookupname_user(fnamep,segflg,followlink,compvpp) lookupname((fnamep),(segflg),(followlink),(compvpp))
51
52 #define osi_vnhold(avc, r)  do { VN_HOLD(AFSTOV(avc)); } while(0)
53
54 /*
55  * Global lock support.
56  */
57
58 extern usr_thread_t afs_global_owner;
59 extern usr_mutex_t afs_global_lock;
60
61 #define ISAFS_GLOCK() (usr_thread_self() == afs_global_owner)
62
63 #define AFS_GLOCK() \
64     do { \
65         usr_mutex_lock(&afs_global_lock); \
66         afs_global_owner = usr_thread_self(); \
67     } while(0)
68 #define AFS_GUNLOCK() \
69     do { \
70         AFS_ASSERT_GLOCK(); \
71         memset(&afs_global_owner, 0, sizeof(usr_thread_t)); \
72         usr_mutex_unlock(&afs_global_lock); \
73     } while(0)
74 #define AFS_ASSERT_GLOCK() \
75     do { if (!ISAFS_GLOCK()) { osi_Panic("afs global lock not held"); } } while(0)
76 #define osi_GlockInit() \
77     usr_mutex_init(&afs_global_lock, "afs_global_lock", MUTEX_DEFAULT, NULL)
78
79 extern int afs_bufferpages;
80
81 extern int afs_suser(afs_ucred_t *credp);
82
83 #define setuerror(erval) get_user_struct()->u_error = (erval)
84 #define getuerror(erval) get_user_struct()->u_error
85 #define osi_curcred()    get_user_struct()->u_cred
86
87 #define osi_procname(procname, size) strncpy(procname, "(unknown)", size)
88 #endif /* _OSI_MACHDEP_H_ */