Browse Source

Allow tools to work properly on big endian systems

puppycam
A. Wilcox 11 months ago
committed by Christine Dodrill
parent
commit
504b225b62
  1. 7
      tools/aifc_decode.c
  2. 5
      tools/aiff_extract_codebook.c
  3. 2
      tools/sdk-tools/adpcm/vadpcm.h
  4. 2
      tools/utils.c

7
tools/aifc_decode.c

@ -19,10 +19,17 @@ typedef unsigned int u32;
typedef unsigned long long u64;
typedef float f32;
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
#define bswap16(x) x
#define bswap32(x) x
#define BSWAP16(x) x = x
#define BSWAP32(x) x = x
#else
#define bswap16(x) __builtin_bswap16(x)
#define bswap32(x) __builtin_bswap32(x)
#define BSWAP16(x) x = __builtin_bswap16(x)
#define BSWAP32(x) x = __builtin_bswap32(x)
#endif
#define BSWAP16_MANY(x, n) for (s32 _i = 0; _i < n; _i++) BSWAP16((x)[_i])
#define NORETURN __attribute__((noreturn))

5
tools/aiff_extract_codebook.c

@ -15,8 +15,13 @@ typedef int s32;
typedef unsigned char u8;
typedef unsigned int u32;
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
#define BSWAP16(x)
#define BSWAP32(x)
#else
#define BSWAP16(x) x = __builtin_bswap16(x)
#define BSWAP32(x) x = __builtin_bswap32(x)
#endif
#define NORETURN __attribute__((noreturn))
#define UNUSED __attribute__((unused))

2
tools/sdk-tools/adpcm/vadpcm.h

@ -14,7 +14,7 @@ typedef unsigned long long u64;
typedef float f32;
typedef double f64;
#ifdef __sgi
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
# define BSWAP16(x)
# define BSWAP32(x)
# define BSWAP16_MANY(x, n)

2
tools/utils.c

@ -82,6 +82,7 @@ void swap_bytes(unsigned char *data, long length)
void reverse_endian(unsigned char *data, long length)
{
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
long i;
unsigned char tmp;
for (i = 0; i < length; i += 4) {
@ -92,6 +93,7 @@ void reverse_endian(unsigned char *data, long length)
data[i+1] = data[i+2];
data[i+2] = tmp;
}
#endif
}
long filesize(const char *filename)

Loading…
Cancel
Save