2 * This file has been modified for the cdrkit suite.
4 * The behaviour and appearence of the program code below can differ to a major
5 * extent from the version distributed by the original author(s).
7 * For details, see Changelog file distributed with the cdrkit package. If you
8 * received this file from another source then ask the distributing person for
9 * a log of modifications.
13 /* @(#)byteorder.h 1.3 03/07/20 Copyright 1998,1999 Heiko Eissfeldt */
15 #define MYBYTE_ORDER 1
16 /* supply the byte order macros */
18 #if defined (WORDS_BIGENDIAN)
19 # define MY_BIG_ENDIAN 1
20 # define MY_LITTLE_ENDIAN 0
22 # define MY_BIG_ENDIAN 0
23 # define MY_LITTLE_ENDIAN 1
35 # define revert4bytes(x) \
36 ((unsigned long int)((((unsigned long int)(x) & ULONG_C(0x000000ff)) << 24) | \
37 (((unsigned long int)(x) & ULONG_C(0x0000ff00)) << 8) | \
38 (((unsigned long int)(x) & ULONG_C(0x00ff0000)) >> 8) | \
39 (((unsigned long int)(x) & ULONG_C(0xff000000)) >> 24)))
40 # define revert2bytes(x) \
41 ((unsigned short int)((((unsigned short int)(x) & 0x00ff) << 8) | \
42 (((unsigned short int)(x) & 0xff00) >> 8)))
44 #if MY_BIG_ENDIAN == 1
45 # define cpu_to_le32(x) revert4bytes(x)
46 # define cpu_to_le16(x) revert2bytes(x)
47 # define le32_to_cpu(x) cpu_to_le32(x)
48 # define le16_to_cpu(x) cpu_to_le16(x)
49 # define cpu_to_be32(x) (x)
50 # define cpu_to_be16(x) (x)
51 # define be32_to_cpu(x) (x)
52 # define be16_to_cpu(x) (x)
54 # define cpu_to_be32(x) revert4bytes(x)
55 # define cpu_to_be16(x) revert2bytes(x)
56 # define be32_to_cpu(x) cpu_to_be32(x)
57 # define be16_to_cpu(x) cpu_to_be16(x)
58 # define cpu_to_le32(x) (x)
59 # define cpu_to_le16(x) (x)
60 # define le32_to_cpu(x) (x)
61 # define le16_to_cpu(x) (x)
64 #define GET_LE_UINT_FROM_CHARP(p) ((unsigned int)((*(p+3))<<24)|((*(p+2))<<16)|((*(p+1))<<8)|(*(p)))
65 #define GET_BE_UINT_FROM_CHARP(p) ((unsigned int)((*(p))<<24)|((*(p+1))<<16)|((*(p+2))<<8)|(*(p+3)))
67 #endif /* ifndef MYBYTE_ORDER */