#ifndef __SOUND_TYPE_COMPAT_H
#define __SOUND_TYPE_COMPAT_H

#ifndef DOC_HIDDEN
#include <stdint.h>
#ifdef __linux__
#include <linux/types.h>
#else
typedef uint8_t __u8;
typedef uint16_t __u16;
typedef uint32_t __u32;
typedef uint64_t __u64;
typedef int8_t __s8;
typedef int16_t __s16;
typedef int32_t __s32;
typedef int64_t __s64;

#ifndef __sun
#include <endian.h>
#endif
#if defined(__NetBSD__)
#include <machine/bswap.h>
#if BYTE_ORDER == LITTLE_ENDIAN
#define __cpu_to_le32(x) (x)
#define __cpu_to_be32(x) bswap32(x)
#define __cpu_to_le16(x) (x)
#define __cpu_to_be16(x) bswap16(x)
#else
#define __cpu_to_le32(x) bswap32(x)
#define __cpu_to_be32(x) (x)
#define __cpu_to_le16(x) bswap16(x)
#define __cpu_to_be16(x) (x)
#endif
#else
#ifdef __sun
#include <sys/byteorder.h>
#define __cpu_to_le32(x) LE_32(x)
#define __cpu_to_be32(x) BE_32(x)
#define __cpu_to_le16(x) LE_16(x)
#define __cpu_to_be16(x) BE_16(x)
#else
#include <byteswap.h>
#if __BYTE_ORDER == __LITTLE_ENDIAN
#define __cpu_to_le32(x) (x)
#define __cpu_to_be32(x) bswap_32(x)
#define __cpu_to_le16(x) (x)
#define __cpu_to_be16(x) bswap_16(x)
#else
#define __cpu_to_le32(x) bswap_32(x)
#define __cpu_to_be32(x) (x)
#define __cpu_to_le16(x) bswap_16(x)
#define __cpu_to_be16(x) (x)
#endif
#endif
#endif

#define __le32_to_cpu __cpu_to_le32
#define __be32_to_cpu __cpu_to_be32
#define __le16_to_cpu __cpu_to_le16
#define __be16_to_cpu __cpu_to_be16

#define __le64 __u64
#define __le32 __u32
#define __le16 __u16
#define __le8  __u8
#define __be64 __u64
#define __be32 __u32
#define __be16 __u16
#define __be8  __u8
#endif

#ifndef __kernel_long_t
#define __kernel_long_t long
#endif

#ifndef __user
#define __user
#endif

#ifndef __packed
#define __packed __attribute__((__packed__))
#endif

#endif /* DOC_HIDDEN */

#endif /* __SOUND_TYPE_COMPAT_H */
