afs: Always define our own osi_timeval32_t
[openafs.git] / src / afs / afs_osi.h
index 916a656..b28b4a7 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright 2000, International Business Machines Corporation and others.
  * All Rights Reserved.
- * 
+ *
  * This software has been released under the terms of the IBM Public
  * License.  For details, see the LICENSE file in the top-level source
  * directory or online at http://www.openafs.org/dl/license10.html
@@ -11,7 +11,9 @@
 #define _AFS_OSI_
 
 #include "h/types.h"
+#if !defined(AFS_LINUX26_ENV)
 #include "h/param.h"
+#endif
 
 #ifdef AFS_FBSD_ENV
 #include <sys/condvar.h>
@@ -37,6 +39,13 @@ struct xfs_inode_info {
 #include "h/mm.h"
 #endif
 
+#if defined(AFS_NBSD50_ENV)
+# if !defined(DEF_CADDR_T)
+typedef char * caddr_t;
+#define DEF_CADDR_T
+# endif
+#endif
+
 
 /* this is just a dummy type decl, we're really using struct sockets here */
 struct osi_socket {
@@ -117,12 +126,7 @@ struct afs_osi_WaitHandle {
 
 #define        osi_NPACKETS    20      /* number of cluster pkts to alloc */
 
-/*
- * Alloc declarations.
- */
-#if !defined(AFS_OBSD44_ENV) && !defined(AFS_NBSD_ENV)
-#define afs_osi_Alloc_NoSleep afs_osi_Alloc
-#endif
+
 
 /*
  * Default vnode related macros
@@ -130,23 +134,32 @@ struct afs_osi_WaitHandle {
  * Darwin, all of the BSDs, and Linux have their own
  */
 #if !defined(AFS_DARWIN_ENV) && !defined(AFS_XBSD_ENV) && !defined(AFS_LINUX20_ENV)
-# define       vType(vc)           (vc)->v.v_type
-# define       vSetType(vc,type)   (vc)->v.v_type = (type)
-# define       vSetVfsp(vc,vfsp)   (vc)->v.v_vfsp = (vfsp)
+# define       vType(vc)           AFSTOV(vc)->v_type
+# define       vSetType(vc,type)   AFSTOV(vc)->v_type = (type)
+# define       vSetVfsp(vc,vfsp)   AFSTOV(vc)->v_vfsp = (vfsp)
 extern struct vnodeops *afs_ops;
 # define       IsAfsVnode(v)       ((v)->v_op == afs_ops)
 # define       SetAfsVnode(v)      (v)->v_op = afs_ops
 #endif
 
 struct vcache;
-extern int osi_TryEvictVCache(struct vcache *, int *);
+extern int osi_TryEvictVCache(struct vcache *, int *, int);
 extern struct vcache *osi_NewVnode(void);
 extern void osi_PrePopulateVCache(struct vcache *);
 extern void osi_PostPopulateVCache(struct vcache *);
 extern void osi_AttachVnode(struct vcache *, int seq);
 
+/**
+ * Increment the refcount on the given vcache.
+ *
+ * @retval 0 Success
+ * @retval nonzero Error obtaining reference; the vcache is no longer valid and
+ *                the caller should act as if it doesn't exist.
+ */
+extern int osi_vnhold(struct vcache *);
+
 /*
- * In IRIX 6.5 we cannot have DEBUG turned on since certain
+ * In IRIX 6.5 and NetBSD we cannot have DEBUG turned on since certain
  * system-defined structures are a different size with DEBUG on, the
  * kernel is compiled without DEBUG on, and the resulting differences
  * would break our ability to interact with the rest of the kernel.
@@ -154,35 +167,21 @@ extern void osi_AttachVnode(struct vcache *, int seq);
  * Is DEBUG only for turning the ASSERT() macro?  If so, we should
  * be able to eliminate DEBUG entirely.
  */
-#if !defined(AFS_SGI65_ENV)
+#if !defined(AFS_SGI65_ENV) && !defined(AFS_NBSD_ENV)
 #ifndef        DEBUG
 #define        DEBUG   1               /* Default is to enable debugging/logging */
 #endif
 #endif
 
-/* 
- * Time related macros
+/*
+ * We use osi_timeval32_t because the native timeval varies in size on
+ * different platforms.  We require a fixed size timeval, at least for the
+ * xstats.
  */
-#define osi_GetuTime(x) osi_GetTime(x)
-
-/* osi_timeval_t exists because SGI 6.x has two sizes of timeval. */
-/** In 64 bit Solaris the timeval structure has members that are 64 bit
-  * In the GetTime() interface we expect pointers to afs_int32. So the need to
-  * define osi_timeval_t to have 32 bit members. To make this less ambiguous
-  * we now use 32 bit quantities consistently all over the code.
-  * In 64 bit HP-UX the timeval structure has a 64 bit member.
-  */
-
-#if defined(AFS_HPUX_ENV) || defined(AFS_LINUX_64BIT_KERNEL) || (defined(AFS_SGI61_ENV) && defined(KERNEL) && defined(_K64U64))
 typedef struct {
     afs_int32 tv_sec;
     afs_int32 tv_usec;
-} osi_timeval_t;
-#elif defined(AFS_SUN57_ENV)
-typedef struct timeval32 osi_timeval_t;
-#else
-typedef struct timeval osi_timeval_t;
-#endif /* AFS_SGI61_ENV */
+} osi_timeval32_t;
 
 #ifndef UKERNEL
 #define osi_getpid()           getpid()
@@ -197,8 +196,6 @@ typedef struct timeval osi_timeval_t;
 #ifdef AFS_FBSD_ENV
 /* should use curthread, but 'ps' can't display it */
 #define osi_ThreadUnique()     (curproc->p_pid)
-#elif defined(AFS_LINUX_ENV)
-#define osi_ThreadUnique()     (current->pid)
 #elif defined(UKERNEL)
 #define osi_ThreadUnique()     osi_getpid()
 #else
@@ -231,7 +228,7 @@ typedef struct timeval osi_timeval_t;
 
 /* On an MP that uses multithreading, splnet is not sufficient to provide
  * mutual exclusion because the other processors will not see it.  On some
- * early multiprocessors (SunOS413 & SGI5.2) splnet actually obtains a global
+ * early multiprocessors (SGI5.2) splnet actually obtains a global
  * mutex, which this works in the UP expected way, it means that the whole MP
  * can only take one interrupt at a time; a serious performance penalty. */
 
@@ -258,15 +255,6 @@ typedef struct timeval osi_timeval_t;
  * (Also, of course, the vnode is assumed to be one of ours.  Can't use this
  * macro for V-file vnodes.)
  */
-#if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
-/* Bare refcount manipulation would probably work on this platform, but just
-   calling VREF does not */
-#define AFS_FAST_HOLD(vp) osi_vnhold((vp),0)
-#elif defined(AFS_AIX_ENV)
-#define AFS_FAST_HOLD(vp) VREFCOUNT_INC(vp)
-#else
-#define AFS_FAST_HOLD(vp) VN_HOLD(AFSTOV(vp))
-#endif
 #ifdef AFS_AIX_ENV
 #define AFS_FAST_RELE(vp) VREFCOUNT_DEC(vp)
 #else
@@ -374,7 +362,7 @@ typedef struct timeval osi_timeval_t;
            uio_setrw((UIO),(RW));                              \
            CODE = uiomove((SRC),(LEN),(UIO));                  \
        } while(0)
-#elif defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
+#elif defined(AFS_DARWIN_ENV) || (defined(AFS_XBSD_ENV) && !defined(AFS_NBSD40_ENV))
 #define AFS_UIOMOVE(SRC,LEN,RW,UIO,CODE)                       \
        do {                                                    \
            (UIO)->uio_rw = (RW);                               \
@@ -427,7 +415,7 @@ typedef struct timeval osi_timeval_t;
 
 
 /*
-** Macro for Solaris 2.6 returns 1 if file is larger than 2GB; else returns 0 
+** Macro for Solaris 2.6 returns 1 if file is larger than 2GB; else returns 0
 */
 #define AfsLargeFileUio(uio)       0
 #define AfsLargeFileSize(pos, off) 0
@@ -446,4 +434,10 @@ extern afs_ucred_t afs_osi_cred, *afs_osi_credp;
 #define osi_curcred() (u.u_cred)
 #endif
 
+#ifdef AFS_PAG_ONEGROUP_ENV
+#define AFS_NUMPAGGROUPS 1
+#else
+#define AFS_NUMPAGGROUPS 2
+#endif
+
 #endif /* _AFS_OSI_ */