| Index: include/share/endswap.h
|
| diff --git a/include/FLAC/ordinals.h b/include/share/endswap.h
|
| similarity index 58%
|
| copy from include/FLAC/ordinals.h
|
| copy to include/share/endswap.h
|
| index a7a5cd96135929ad078755f16d8f4d16a9d3f386..4fde4c15684f1bb6306426ba00a9b2a9bbd2097e 100644
|
| --- a/include/FLAC/ordinals.h
|
| +++ b/include/share/endswap.h
|
| @@ -1,5 +1,5 @@
|
| /* libFLAC - Free Lossless Audio Codec library
|
| - * Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007 Josh Coalson
|
| + * Copyright (C) 2012-2014 Xiph.org Foundation
|
| *
|
| * Redistribution and use in source and binary forms, with or without
|
| * modification, are permitted provided that the following conditions
|
| @@ -29,52 +29,50 @@
|
| * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| */
|
|
|
| -#ifndef FLAC__ORDINALS_H
|
| -#define FLAC__ORDINALS_H
|
| +/* It is assumed that this header will be included after "config.h". */
|
|
|
| -#if !(defined(_MSC_VER) || defined(__BORLANDC__) || defined(__EMX__))
|
| -#include <inttypes.h>
|
| +#if HAVE_BSWAP32 /* GCC and Clang */
|
| +
|
| +/* GCC prior to 4.8 didn't provide bswap16 on x86_64 */
|
| +#if ! HAVE_BSWAP16
|
| +static inline unsigned short __builtin_bswap16(unsigned short a)
|
| +{
|
| + return (a<<8)|(a>>8);
|
| +}
|
| #endif
|
|
|
| -typedef signed char FLAC__int8;
|
| -typedef unsigned char FLAC__uint8;
|
| -
|
| -#if defined(_MSC_VER) || defined(__BORLANDC__)
|
| -typedef __int16 FLAC__int16;
|
| -typedef __int32 FLAC__int32;
|
| -typedef __int64 FLAC__int64;
|
| -typedef unsigned __int16 FLAC__uint16;
|
| -typedef unsigned __int32 FLAC__uint32;
|
| -typedef unsigned __int64 FLAC__uint64;
|
| -#elif defined(__EMX__)
|
| -typedef short FLAC__int16;
|
| -typedef long FLAC__int32;
|
| -typedef long long FLAC__int64;
|
| -typedef unsigned short FLAC__uint16;
|
| -typedef unsigned long FLAC__uint32;
|
| -typedef unsigned long long FLAC__uint64;
|
| +#define ENDSWAP_16(x) (__builtin_bswap16 (x))
|
| +#define ENDSWAP_32(x) (__builtin_bswap32 (x))
|
| +
|
| +#elif defined _MSC_VER /* Windows. Apparently in <stdlib.h>. */
|
| +
|
| +#define ENDSWAP_16(x) (_byteswap_ushort (x))
|
| +#define ENDSWAP_32(x) (_byteswap_ulong (x))
|
| +
|
| +#elif defined HAVE_BYTESWAP_H /* Linux */
|
| +
|
| +#include <byteswap.h>
|
| +
|
| +#define ENDSWAP_16(x) (bswap_16 (x))
|
| +#define ENDSWAP_32(x) (bswap_32 (x))
|
| +
|
| #else
|
| -typedef int16_t FLAC__int16;
|
| -typedef int32_t FLAC__int32;
|
| -typedef int64_t FLAC__int64;
|
| -typedef uint16_t FLAC__uint16;
|
| -typedef uint32_t FLAC__uint32;
|
| -typedef uint64_t FLAC__uint64;
|
| +
|
| +#define ENDSWAP_16(x) ((((x) >> 8) & 0xFF) | (((x) & 0xFF) << 8))
|
| +#define ENDSWAP_32(x) ((((x) >> 24) & 0xFF) | (((x) >> 8) & 0xFF00) | (((x) & 0xFF00) << 8) | (((x) & 0xFF) << 24))
|
| +
|
| #endif
|
|
|
| -typedef int FLAC__bool;
|
|
|
| -typedef FLAC__uint8 FLAC__byte;
|
| +/* Host to little-endian byte swapping. */
|
| +#if CPU_IS_BIG_ENDIAN
|
|
|
| -#ifdef true
|
| -#undef true
|
| -#endif
|
| -#ifdef false
|
| -#undef false
|
| -#endif
|
| -#ifndef __cplusplus
|
| -#define true 1
|
| -#define false 0
|
| -#endif
|
| +#define H2LE_16(x) ENDSWAP_16 (x)
|
| +#define H2LE_32(x) ENDSWAP_32 (x)
|
| +
|
| +#else
|
| +
|
| +#define H2LE_16(x) (x)
|
| +#define H2LE_32(x) (x)
|
|
|
| #endif
|
|
|