--- kerncompat.h.orig 2009-02-15 13:25:46.000000000 +0100 +++ kerncompat.h 2009-02-15 13:28:49.000000000 +0100 @@ -22,8 +22,13 @@ #include <stdlib.h> #include <errno.h> #include <string.h> +#ifdef __APPLE__ +#include <stdint.h> +#include <libkern/OSByteOrder.h> +#else #include <endian.h> #include <byteswap.h> +#endif #include <assert.h> #ifndef READ @@ -42,7 +47,7 @@ #define GFP_NOFS 0 #define __read_mostly #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) -#define ULONG_MAX (~0UL) +//#define ULONG_MAX (~0UL) #define BUG() abort() #ifdef __CHECKER__ #define __force __attribute__((force)) @@ -53,11 +58,18 @@ #endif #ifndef __CHECKER__ +#ifdef __APPLE__ +typedef uint32_t u32; +typedef uint64_t u64; +typedef uint16_t u16; +typedef uint8_t u8; +#else #include <asm/types.h> typedef __u32 u32; typedef __u64 u64; typedef __u16 u16; typedef __u8 u8; +#endif /* __APPLE__ */ #else typedef unsigned int u32; typedef unsigned int __u32; @@ -236,12 +248,21 @@ #define __le8 u8 #if __BYTE_ORDER == __BIG_ENDIAN +#ifdef __APPLE__ +#define cpu_to_le64(x) ((__force __le64)(u64)(OSSwapHostToLittleInt64(x))) +#define le64_to_cpu(x) ((__force u64)(__le64)(OSSwapLittleToHostInt64(x))) +#define cpu_to_le32(x) ((__force __le32)(u32)(OSSwapHostToLittleInt32(x))) +#define le32_to_cpu(x) ((__force u32)(__le32)(OSSwapLittleToHostInt32(x))) +#define cpu_to_le16(x) ((__force __le16)(u16)(OSSwapHostToLittleInt16(x))) +#define le16_to_cpu(x) ((__force u16)(__le16)(OSSwapLittleToHostInt16(x))) +#else #define cpu_to_le64(x) ((__force __le64)(u64)(bswap_64(x))) #define le64_to_cpu(x) ((__force u64)(__le64)(bswap_64(x))) #define cpu_to_le32(x) ((__force __le32)(u32)(bswap_32(x))) #define le32_to_cpu(x) ((__force u32)(__le32)(bswap_32(x))) #define cpu_to_le16(x) ((__force __le16)(u16)(bswap_16(x))) #define le16_to_cpu(x) ((__force u16)(__le16)(bswap_16(x))) +#endif /* __APPLE__ */ #else #define cpu_to_le64(x) ((__force __le64)(u64)(x)) #define le64_to_cpu(x) ((__force u64)(__le64)(x))