Ticket #18502: patch-kerncompat.h.diff

File patch-kerncompat.h.diff, 2.0 KB (added by 0xffea@…, 16 years ago)
  • kerncompat.h

    old new  
    2222#include <stdlib.h>
    2323#include <errno.h>
    2424#include <string.h>
     25#ifdef __APPLE__
     26#include <stdint.h>
     27#include <libkern/OSByteOrder.h>
     28#else
    2529#include <endian.h>
    2630#include <byteswap.h>
     31#endif
    2732#include <assert.h>
    2833
    2934#ifndef READ
     
    4247#define GFP_NOFS 0
    4348#define __read_mostly
    4449#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
    45 #define ULONG_MAX       (~0UL)
     50//#define ULONG_MAX       (~0UL)
    4651#define BUG() abort()
    4752#ifdef __CHECKER__
    4853#define __force    __attribute__((force))
     
    5358#endif
    5459
    5560#ifndef __CHECKER__
     61#ifdef __APPLE__
     62typedef uint32_t u32;
     63typedef uint64_t u64;
     64typedef uint16_t u16;
     65typedef uint8_t u8;
     66#else
    5667#include <asm/types.h>
    5768typedef __u32 u32;
    5869typedef __u64 u64;
    5970typedef __u16 u16;
    6071typedef __u8 u8;
     72#endif /* __APPLE__ */
    6173#else
    6274typedef unsigned int u32;
    6375typedef unsigned int __u32;
     
    236248#define __le8 u8
    237249
    238250#if __BYTE_ORDER == __BIG_ENDIAN
     251#ifdef __APPLE__
     252#define cpu_to_le64(x) ((__force __le64)(u64)(OSSwapHostToLittleInt64(x)))
     253#define le64_to_cpu(x) ((__force u64)(__le64)(OSSwapLittleToHostInt64(x)))
     254#define cpu_to_le32(x) ((__force __le32)(u32)(OSSwapHostToLittleInt32(x)))
     255#define le32_to_cpu(x) ((__force u32)(__le32)(OSSwapLittleToHostInt32(x)))
     256#define cpu_to_le16(x) ((__force __le16)(u16)(OSSwapHostToLittleInt16(x)))
     257#define le16_to_cpu(x) ((__force u16)(__le16)(OSSwapLittleToHostInt16(x)))
     258#else
    239259#define cpu_to_le64(x) ((__force __le64)(u64)(bswap_64(x)))
    240260#define le64_to_cpu(x) ((__force u64)(__le64)(bswap_64(x)))
    241261#define cpu_to_le32(x) ((__force __le32)(u32)(bswap_32(x)))
    242262#define le32_to_cpu(x) ((__force u32)(__le32)(bswap_32(x)))
    243263#define cpu_to_le16(x) ((__force __le16)(u16)(bswap_16(x)))
    244264#define le16_to_cpu(x) ((__force u16)(__le16)(bswap_16(x)))
     265#endif /* __APPLE__ */
    245266#else
    246267#define cpu_to_le64(x) ((__force __le64)(u64)(x))
    247268#define le64_to_cpu(x) ((__force u64)(__le64)(x))