Initial IBM OpenAFS 1.0 tree
[openafs.git] / src / afs / SOLARIS / osi_machdep.h
1 /* Copyright (C) 1995 Transarc Corporation - All rights reserved. */
2 /*
3  *
4  * Solaris OSI header file. Extends afs_osi.h.
5  *
6  * afs_osi.h includes this file, which is the only way this file should
7  * be included in a source file. This file can redefine macros declared in
8  * afs_osi.h.
9  */
10
11 #ifndef _OSI_MACHDEP_H_
12 #define _OSI_MACHDEP_H_
13
14 #ifdef AFS_SUN57_64BIT_ENV
15 #include <sys/model.h>  /* for get_udatamodel() */
16 #endif
17
18 #define getpid()                curproc->p_pid
19
20 /**
21   * The location of the NFSSRV module
22   * Used in osi_vfsops.c when checking to see if the nfssrv module is
23   * loaded
24   */
25 #define NFSSRV          "/kernel/misc/nfssrv"
26 #define NFSSRV_V9       "/kernel/misc/sparcv9/nfssrv"
27
28 #define AFS_UCRED cred
29 #define AFS_PROC struct proc
30
31 /* 
32  * Time related macros
33  */
34 #define afs_hz      hz
35 #define osi_Time() (hrestime.tv_sec)
36
37 #undef afs_osi_Alloc_NoSleep
38 extern void *afs_osi_Alloc_NoSleep(size_t size);
39
40 #define osi_vnhold(avc, r)  do { VN_HOLD((struct vnode *)(avc)); } while(0)
41 #define gop_rdwr(rw,gp,base,len,offset,segflg,ioflag,ulimit,cr,aresid) \
42   vn_rdwr((rw),(gp),(base),(len),(offset),(segflg),(ioflag),(ulimit),(cr),(aresid))
43
44 #define afs_suser           suser
45
46
47 #ifdef KERNEL
48 /*
49  * Global lock support. 
50  */
51 #include <sys/mutex.h>
52 extern kmutex_t afs_global_lock;
53 extern kmutex_t afs_rxglobal_lock;
54
55 #define AFS_GLOCK()     mutex_enter(&afs_global_lock);          
56 #define AFS_GUNLOCK()   mutex_exit(&afs_global_lock);
57 #define ISAFS_GLOCK()   mutex_owned(&afs_global_lock)
58
59 #define AFS_RXGLOCK()
60 #define AFS_RXGUNLOCK()
61 #define ISAFS_RXGLOCK() 1
62 #endif
63
64
65 /* Associate the Berkley signal equivalent lock types to System V's */
66 #define LOCK_SH 1       /* F_RDLCK */
67 #define LOCK_EX 2       /* F_WRLCK */
68 #define LOCK_NB 4       /* XXX */
69 #define LOCK_UN 8       /* F_UNLCK */
70
71 #ifndef IO_APPEND
72 #define IO_APPEND       FAPPEND
73 #endif
74
75 #ifndef IO_SYNC
76 #define IO_SYNC         FSYNC
77 #endif
78
79 #if     defined(AFS_SUN56_ENV)
80 /*
81 ** Macro returns 1 if file is larger than 2GB; else returns 0 
82 */
83 #undef AfsLargeFileUio
84 #define AfsLargeFileUio(uio)       ( (uio)->_uio_offset._p._u ? 1 : 0 )
85 #undef AfsLargeFileSize
86 #define AfsLargeFileSize(pos, off) ( ((offset_t)(pos)+(offset_t)(off) > (offset_t)MAXOFF_T)?1:0)
87 #endif
88
89 #endif /* _OSI_MACHDEP_H_ */
90