Whamcloud - gitweb
Landing b_hd_newconfig on HEAD
[fs/lustre-release.git] / lnet / include / libcfs / darwin / darwin-types.h
index b2762c0..0fd2966 100644 (file)
 #include <mach/mach_types.h>
 #include <sys/types.h>
 
-typedef u_int8_t  __u8;
-typedef u_int16_t __u16;
-typedef u_int32_t __u32;
-typedef u_int64_t __u64;
+#ifndef _BLKID_TYPES_H
+#define _BLKID_TYPES_H
+#endif
+
+typedef u_int8_t        __u8;
+typedef u_int16_t       __u16;
+typedef u_int32_t       __u32;
+typedef u_int64_t       __u64;
+typedef int8_t          __s8;
+typedef int16_t         __s16;
+typedef int32_t         __s32;
+typedef int64_t         __s64;
 
 #ifdef __KERNEL__
 
 #include <kern/kern_types.h>
 
-#ifndef __s32
-typedef __signed__ int                 __s32;
-#endif
-#ifndef __s64
-typedef __signed__ long long           __s64;
-#endif
 
 typedef struct { int e; }              event_chan_t;
 typedef dev_t                          kdev_t;
@@ -61,22 +63,30 @@ typedef struct { volatile uint32_t counter; }       atomic_t;
 #define ATOMIC_INIT(i)                 { (i) }
 #define atomic_read(a)                 ((a)->counter)
 #define atomic_set(a, v)               (((a)->counter) = (v))
+#ifdef __DARWIN8__
+#define atomic_add(v, a)               OSAddAtomic(v, (SInt32 *)&((a)->counter))
+#define atomic_sub(v, a)               OSAddAtomic(-(v), (SInt32 *)&((a)->counter))
+#define atomic_inc(a)                  OSIncrementAtomic((SInt32 *)&((a)->counter))
+#define atomic_dec(a)                  OSDecrementAtomic((SInt32 *)&((a)->counter))
+#else /* !__DARWIN8__ */
 #define atomic_add(v, a)               hw_atomic_add((uint32_t *)&((a)->counter), v)
 #define atomic_sub(v, a)               hw_atomic_sub((uint32_t *)&((a)->counter), v)
 #define atomic_inc(a)                  atomic_add(1, a)
 #define atomic_dec(a)                  atomic_sub(1, a)
-#define atomic_sub_and_test(v, a)      ( atomic_sub(v, a) == 0 )
-#define atomic_dec_and_test(a)         ( atomic_dec(a) == 0 )
+#endif /* !__DARWIN8__ */
+#define atomic_sub_and_test(v, a)      ( atomic_sub(v, a) == -(a) )
+#define atomic_dec_and_test(a)         ( atomic_dec(a) == 1 )
 
 #include <libsa/mach/mach.h>
-typedef uint64_t                       loff_t;
+typedef off_t                          loff_t;
 
 #else  /* !__KERNEL__ */
 
 #include <stdint.h>
 
-typedef uint64_t                       loff_t;
+typedef off_t                          loff_t;
 
 #endif /* __KERNEL END */
+typedef unsigned short                  umode_t;
 
 #endif  /* __XNU_CFS_TYPES_H__ */