libafs: Tidy up iovec allocation and trimming
[openafs.git] / src / afs / DARWIN / osi_machdep.h
index a82d388..e186d3a 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
@@ -97,7 +97,7 @@ enum vcexcl { EXCL, NONEXCL };
 #define va_atime va_access_time
 #define va_mtime va_modify_time
 #define va_ctime va_change_time
-#define va_bytes va_total_alloc 
+#define va_bytes va_total_alloc
 #define va_blocksize va_iosize
 #define va_nodeid va_fileid
 
@@ -117,13 +117,12 @@ enum vcexcl { EXCL, NONEXCL };
 extern vfs_context_t afs_osi_ctxtp;
 extern int afs_osi_ctxtp_initialized;
 #endif
+extern u_int32_t afs_darwin_realmodes;
+extern u_int32_t afs_darwin_fsevents;
 
-/* 
+/*
  * Time related macros
  */
-#ifndef AFS_DARWIN60_ENV
-extern struct timeval time;
-#endif
 #ifdef AFS_DARWIN80_ENV
 static inline time_t osi_Time(void) {
     struct timeval _now;
@@ -146,16 +145,12 @@ typedef struct proc afs_proc_t;
 #define VN_RELE(vp) vrele(vp);
 
 void darwin_vn_hold(struct vnode *vp);
-#ifdef AFS_DARWIN80_ENV
-void darwin_vn_rele(struct vnode *vp);
-#endif
 
 #define gop_rdwr(rw,gp,base,len,offset,segflg,unit,cred,aresid) \
   vn_rdwr((rw),(gp),(base),(len),(offset),(segflg),(unit),(cred),(aresid),current_proc())
 
 #undef afs_suser
 
-#ifdef KERNEL
 extern thread_t afs_global_owner;
 /* simple locks cannot be used since sleep can happen at any time */
 #ifdef AFS_DARWIN80_ENV
@@ -174,6 +169,10 @@ extern lck_mtx_t  *afs_global_lock;
        afs_global_owner = 0; \
         lck_mtx_unlock(afs_global_lock); \
     } while(0)
+#define osi_InitGlock() \
+    do { \
+       afs_global_owner = 0; \
+    } while (0)
 #else
 /* Should probably use mach locks rather than bsd locks, since we use the
    mach thread control api's elsewhere (mach locks not used for consistency
@@ -192,6 +191,11 @@ extern struct lock__bsd__ afs_global_lock;
        afs_global_owner = 0; \
         lockmgr(&afs_global_lock, LK_RELEASE, 0, current_proc()); \
     } while(0)
+#define osi_InitGlock() \
+    do { \
+       lockinit(&afs_global_lock, PLOCK, "afs global lock", 0, 0); \
+       afs_global_owner = 0; \
+    } while (0)
 #endif
 #define ISAFS_GLOCK() (afs_global_owner == current_thread())
 
@@ -218,26 +222,36 @@ extern int igetinode(mount_t vfsp, dev_t dev , ino_t inode, vnode_t *vpp,
 #define osi_curproc() current_proc()
 
 /* FIXME */
-#define osi_curcred() &afs_osi_cred 
+#define osi_curcred() &afs_osi_cred
 
 #ifdef AFS_DARWIN80_ENV
-uio_t afsio_darwin_partialcopy(uio_t auio, int size);
+# define afsio_free(X) uio_free(X)
+# define afsio_setoffset(X, Y) uio_setoffset(X, Y)
+# define uprintf printf
+#endif
 
-#define uprintf printf
+/* Vnode related macros */
+
+#if defined(AFS_DARWIN80_ENV)
+extern int afs_vfs_typenum;
+# define vType(vc)               vnode_vtype(AFSTOV(vc))
+# define vSetVfsp(vc, vfsp)
+# define vSetType(vc, type)      (vc)->f.m.Type = (type)
+# define SetAfsVnode(vn)         /* nothing; done in getnewvnode() */
+# define IsAfsVnode(v) (vfs_typenum(vnode_mount((v))) == afs_vfs_typenum)
+#else
+extern int (**afs_vnodeop_p) ();
+# define vType(vc)               AFSTOV(vc)->v_type
+# define vSetVfsp(vc, vfsp)      AFSTOV(vc)->v_mount = (vfsp)
+# define vSetType(vc, type)      AFSTOV(vc)->v_type = (type)
+# define IsAfsVnode(v)      ((v)->v_op == afs_vnodeop_p)
+# define SetAfsVnode(v)     /* nothing; done in getnewvnode() */
 #endif
 
-#ifndef AFS_DARWIN80_ENV
-#define ifaddr_address_family(x) (x)->ifa_addr->sa_family
-#define ifaddr_address(x, y, z) memcpy(y, (x)->ifa_addr, z)
-#define ifaddr_netmask(x, y, z) memcpy(y, (x)->ifa_netmask, z)
-#define ifaddr_dstaddress(x, y, z) memcpy(y, (x)->ifa_dstaddr, z)
-#define ifaddr_ifnet(x) (x?(x)->ifa_ifp:0)
-#define ifnet_flags(x) (x?(x)->if_flags:0)
-#define ifnet_metric(x) (x?(x)->if_data.ifi_metric:0)
-/*#define ifnet_mtu(x) (x)->if_mtu*/
-#define ifaddr_withnet(x) ifa_ifwithnet(x)
-#endif
-
-#endif /* KERNEL */
+#ifdef AFS_DARWIN80_ENV
+#define osi_procname(procname, size) proc_selfname(procname, size)
+#else
+#define osi_procname(procname, size) strncpy(procname, curproc->p_comm, size)
+#endif
 
 #endif /* _OSI_MACHDEP_H_ */