26#ifndef TAGLIB_TUTILS_H
27#define TAGLIB_TUTILS_H
31#ifndef DO_NOT_DOCUMENT
42#if defined(HAVE_MSC_BYTESWAP)
44#elif defined(HAVE_GLIBC_BYTESWAP)
46#elif defined(HAVE_MAC_BYTESWAP)
47# include <libkern/OSByteOrder.h>
48#elif defined(HAVE_OPENBSD_BYTESWAP)
49# include <sys/endian.h>
64 inline uint16_t byteSwap(uint16_t x)
66#if defined(HAVE_GCC_BYTESWAP)
68 return __builtin_bswap16(x);
70#elif defined(HAVE_MSC_BYTESWAP)
72 return _byteswap_ushort(x);
74#elif defined(HAVE_GLIBC_BYTESWAP)
78#elif defined(HAVE_MAC_BYTESWAP)
80 return OSSwapInt16(x);
82#elif defined(HAVE_OPENBSD_BYTESWAP)
88 return ((x >> 8) & 0xff) | ((x & 0xff) << 8);
96 inline uint32_t byteSwap(uint32_t x)
98#if defined(HAVE_GCC_BYTESWAP)
100 return __builtin_bswap32(x);
102#elif defined(HAVE_MSC_BYTESWAP)
104 return _byteswap_ulong(x);
106#elif defined(HAVE_GLIBC_BYTESWAP)
108 return __bswap_32(x);
110#elif defined(HAVE_MAC_BYTESWAP)
112 return OSSwapInt32(x);
114#elif defined(HAVE_OPENBSD_BYTESWAP)
120 return ((x & 0xff000000u) >> 24)
121 | ((x & 0x00ff0000u) >> 8)
122 | ((x & 0x0000ff00u) << 8)
123 | ((x & 0x000000ffu) << 24);
131 inline uint64_t byteSwap(uint64_t x)
133#if defined(HAVE_GCC_BYTESWAP)
135 return __builtin_bswap64(x);
137#elif defined(HAVE_MSC_BYTESWAP)
139 return _byteswap_uint64(x);
141#elif defined(HAVE_GLIBC_BYTESWAP)
143 return __bswap_64(x);
145#elif defined(HAVE_MAC_BYTESWAP)
147 return OSSwapInt64(x);
149#elif defined(HAVE_OPENBSD_BYTESWAP)
155 return ((x & 0xff00000000000000ull) >> 56)
156 | ((x & 0x00ff000000000000ull) >> 40)
157 | ((x & 0x0000ff0000000000ull) >> 24)
158 | ((x & 0x000000ff00000000ull) >> 8)
159 | ((x & 0x00000000ff000000ull) << 8)
160 | ((x & 0x0000000000ff0000ull) << 24)
161 | ((x & 0x000000000000ff00ull) << 40)
162 | ((x & 0x00000000000000ffull) << 56);
171 inline String formatString(
const char *format, ...)
176 static const size_t BufferSize = 128;
179 va_start(args, format);
181 char buf[BufferSize];
184 length = std::vsnprintf(buf, BufferSize, format, args);
207 constexpr ByteOrder systemByteOrder()
209 constexpr union IntCharUnion {
212 constexpr IntCharUnion(
int j) : i(j) {}
A namespace for all TagLib related classes and functions.
Definition apefile.h:41