mirror of
https://github.com/taglib/taglib.git
synced 2025-05-27 21:20:26 -04:00
Merge pull request #187 from TsudaKageyu/config
Removed config.h and moved macros into taglib_config.h
This commit is contained in:
commit
db06166330
@ -81,13 +81,13 @@ if(NOT WIN32 AND NOT BUILD_FRAMEWORK)
|
||||
endif()
|
||||
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
configure_file(config-taglib.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
||||
configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
||||
|
||||
if(WITH_ASF)
|
||||
set(TAGLIB_WITH_ASF TRUE)
|
||||
set(TAGLIB_WITH_ASF TRUE)
|
||||
endif()
|
||||
if(WITH_MP4)
|
||||
set(TAGLIB_WITH_MP4 TRUE)
|
||||
set(TAGLIB_WITH_MP4 TRUE)
|
||||
endif()
|
||||
|
||||
configure_file(taglib/taglib_config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/taglib_config.h)
|
||||
|
@ -7,30 +7,37 @@ include(CheckTypeSize)
|
||||
include(CheckCXXSourceCompiles)
|
||||
include(TestBigEndian)
|
||||
|
||||
# Determine the CPU byte order.
|
||||
# Check if the size of integral types are suitable.
|
||||
|
||||
test_big_endian(TAGLIB_BIG_ENDIAN)
|
||||
|
||||
if(NOT TAGLIB_BIG_ENDIAN)
|
||||
set(TAGLIB_LITTLE_ENDIAN 1)
|
||||
check_type_size("short" SIZEOF_SHORT)
|
||||
if(NOT ${SIZEOF_SHORT} EQUAL 2)
|
||||
MESSAGE(FATAL_ERROR "TagLib requires that short is 16-bit wide.")
|
||||
endif()
|
||||
|
||||
# Determine the size of integral types.
|
||||
check_type_size("int" SIZEOF_INT)
|
||||
if(NOT ${SIZEOF_INT} EQUAL 4)
|
||||
MESSAGE(FATAL_ERROR "TagLib requires that int is 32-bit wide.")
|
||||
endif()
|
||||
|
||||
check_type_size("short" SIZEOF_SHORT)
|
||||
check_type_size("int" SIZEOF_INT)
|
||||
check_type_size("long long" SIZEOF_LONGLONG)
|
||||
check_type_size("wchar_t" SIZEOF_WCHAR_T)
|
||||
if(NOT ${SIZEOF_LONGLONG} EQUAL 8)
|
||||
MESSAGE(FATAL_ERROR "TagLib requires that long long is 64-bit wide.")
|
||||
endif()
|
||||
|
||||
# Determine if your compiler supports std::wstring.
|
||||
check_type_size("wchar_t" SIZEOF_WCHAR_T)
|
||||
if(${SIZEOF_WCHAR_T} LESS 2)
|
||||
MESSAGE(FATAL_ERROR "TagLib requires that wchar_t is sufficient to store a UTF-16 char.")
|
||||
endif()
|
||||
|
||||
check_cxx_source_compiles("
|
||||
#include <string>
|
||||
int main() {
|
||||
std::wstring x(L\"ABC\");
|
||||
return 0;
|
||||
}
|
||||
" HAVE_STD_WSTRING)
|
||||
# Determine the CPU byte order.
|
||||
|
||||
test_big_endian(IS_BIG_ENDIAN)
|
||||
|
||||
if(NOT IS_BIG_ENDIAN)
|
||||
set(SYSTEM_BYTEORDER 1)
|
||||
else()
|
||||
set(SYSTEM_BYTEORDER 2)
|
||||
endif()
|
||||
|
||||
# Determine which kind of atomic operations your compiler supports.
|
||||
|
||||
|
@ -19,10 +19,7 @@
|
||||
* USA *
|
||||
***************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "taglib_config.h"
|
||||
#include <stdlib.h>
|
||||
#include <fileref.h>
|
||||
#include <tfile.h>
|
||||
|
@ -1,25 +1,8 @@
|
||||
/* config-taglib.h. Generated by cmake from config-taglib.h.cmake */
|
||||
/* config.h. Generated by cmake from config.h.cmake */
|
||||
|
||||
/* Indicates the endianness of your target system */
|
||||
#cmakedefine TAGLIB_LITTLE_ENDIAN 1
|
||||
#cmakedefine TAGLIB_BIG_ENDIAN 1
|
||||
|
||||
/* Size of integral types */
|
||||
#cmakedefine SIZEOF_SHORT ${SIZEOF_SHORT}
|
||||
#cmakedefine SIZEOF_INT ${SIZEOF_INT}
|
||||
#cmakedefine SIZEOF_LONGLONG ${SIZEOF_LONGLONG}
|
||||
#cmakedefine SIZEOF_WCHAR_T ${SIZEOF_WCHAR_T}
|
||||
|
||||
/* Defined if your compiler supports std::wstring */
|
||||
#cmakedefine HAVE_STD_WSTRING 1
|
||||
|
||||
/* Defined if your compiler supports some atomic operations */
|
||||
#cmakedefine HAVE_STD_ATOMIC 1
|
||||
#cmakedefine HAVE_BOOST_ATOMIC 1
|
||||
#cmakedefine HAVE_GCC_ATOMIC 1
|
||||
#cmakedefine HAVE_MAC_ATOMIC 1
|
||||
#cmakedefine HAVE_WIN_ATOMIC 1
|
||||
#cmakedefine HAVE_IA64_ATOMIC 1
|
||||
/* Indicates the byte order of your target system */
|
||||
/* 1 if little-endian, 2 if big-endian. */
|
||||
#cmakedefine SYSTEM_BYTEORDER ${SYSTEM_BYTEORDER}
|
||||
|
||||
/* Defined if your compiler supports some byte swap functions */
|
||||
#cmakedefine HAVE_GCC_BYTESWAP_16 1
|
||||
@ -33,11 +16,15 @@
|
||||
/* Defined if your compiler supports codecvt */
|
||||
#cmakedefine HAVE_STD_CODECVT 1
|
||||
|
||||
/* Defined if your compiler supports some atomic operations */
|
||||
#cmakedefine HAVE_STD_ATOMIC 1
|
||||
#cmakedefine HAVE_BOOST_ATOMIC 1
|
||||
#cmakedefine HAVE_GCC_ATOMIC 1
|
||||
#cmakedefine HAVE_MAC_ATOMIC 1
|
||||
#cmakedefine HAVE_WIN_ATOMIC 1
|
||||
#cmakedefine HAVE_IA64_ATOMIC 1
|
||||
|
||||
/* Defined if you have libz */
|
||||
#cmakedefine HAVE_ZLIB 1
|
||||
|
||||
#cmakedefine NO_ITUNES_HACKS 1
|
||||
#cmakedefine WITH_ASF 1
|
||||
#cmakedefine WITH_MP4 1
|
||||
|
||||
#cmakedefine TESTS_DIR "@TESTS_DIR@"
|
@ -50,6 +50,7 @@ set(tag_HDRS
|
||||
toolkit/tmap.h
|
||||
toolkit/tmap.tcc
|
||||
toolkit/tpropertymap.h
|
||||
toolkit/trefcounter.h
|
||||
mpeg/mpegfile.h
|
||||
mpeg/mpegproperties.h
|
||||
mpeg/mpegheader.h
|
||||
@ -289,6 +290,7 @@ set(toolkit_SRCS
|
||||
toolkit/tfilestream.cpp
|
||||
toolkit/tdebug.cpp
|
||||
toolkit/tpropertymap.cpp
|
||||
toolkit/trefcounter.cpp
|
||||
toolkit/unicode.cpp
|
||||
)
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include <taglib.h>
|
||||
#include <tdebug.h>
|
||||
#include "trefcounter.h"
|
||||
#include "asfattribute.h"
|
||||
#include "asffile.h"
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include <taglib.h>
|
||||
#include <tdebug.h>
|
||||
#include "trefcounter.h"
|
||||
#include "asfattribute.h"
|
||||
#include "asffile.h"
|
||||
#include "asfpicture.h"
|
||||
|
@ -23,8 +23,7 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "taglib_config.h"
|
||||
#include <tdebug.h>
|
||||
#include <tstring.h>
|
||||
#include "asfproperties.h"
|
||||
|
@ -23,8 +23,7 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "taglib_config.h"
|
||||
#include <tpropertymap.h>
|
||||
#include "asftag.h"
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <config.h>
|
||||
#include "taglib_config.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
# include <Shlwapi.h>
|
||||
@ -36,6 +36,7 @@
|
||||
#include <tfile.h>
|
||||
#include <tstring.h>
|
||||
#include <tdebug.h>
|
||||
#include "trefcounter.h"
|
||||
|
||||
#include "fileref.h"
|
||||
#include "asffile.h"
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include <taglib.h>
|
||||
#include <tdebug.h>
|
||||
#include "trefcounter.h"
|
||||
#include "mp4coverart.h"
|
||||
|
||||
using namespace TagLib;
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include <taglib.h>
|
||||
#include <tdebug.h>
|
||||
#include "trefcounter.h"
|
||||
#include "mp4item.h"
|
||||
|
||||
using namespace TagLib;
|
||||
|
@ -23,8 +23,7 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "taglib_config.h"
|
||||
#include <tdebug.h>
|
||||
#include <tstring.h>
|
||||
#include "mp4file.h"
|
||||
|
@ -23,8 +23,7 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "taglib_config.h"
|
||||
#include <tdebug.h>
|
||||
#include <tstring.h>
|
||||
#include <tpropertymap.h>
|
||||
|
@ -24,6 +24,7 @@
|
||||
***************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
#include "taglib_config.h"
|
||||
|
||||
#if HAVE_ZLIB
|
||||
#include <zlib.h>
|
||||
|
@ -24,7 +24,7 @@
|
||||
***************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "taglib_config.h"
|
||||
#include <tdebug.h>
|
||||
|
||||
#include "id3v2framefactory.h"
|
||||
@ -134,7 +134,7 @@ Frame *FrameFactory::createFrame(const ByteVector &origData, Header *tagHeader)
|
||||
// TagLib doesn't mess with encrypted frames, so just treat them
|
||||
// as unknown frames.
|
||||
|
||||
#if HAVE_ZLIB == 0
|
||||
#if !defined(HAVE_ZLIB) || HAVE_ZLIB == 0
|
||||
if(header->compression()) {
|
||||
debug("Compressed frames are currently not supported.");
|
||||
return new UnknownFrame(data, header);
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <tbytevector.h>
|
||||
#include <tstring.h>
|
||||
#include <tdebug.h>
|
||||
#include "trefcounter.h"
|
||||
|
||||
#include "mpegheader.h"
|
||||
|
||||
|
@ -2,3 +2,4 @@
|
||||
|
||||
#define TAGLIB_WITH_ASF 1
|
||||
#define TAGLIB_WITH_MP4 1
|
||||
|
||||
|
@ -40,8 +40,4 @@
|
||||
#define TAGLIB_EXPORT
|
||||
#endif
|
||||
|
||||
#ifndef TAGLIB_NO_CONFIG
|
||||
#include "taglib_config.h"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -26,7 +26,7 @@
|
||||
#ifndef TAGLIB_H
|
||||
#define TAGLIB_H
|
||||
|
||||
#include "config.h"
|
||||
#include "taglib_config.h"
|
||||
|
||||
#define TAGLIB_MAJOR_VERSION 1
|
||||
#define TAGLIB_MINOR_VERSION 8
|
||||
@ -45,113 +45,6 @@
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
#include <climits>
|
||||
|
||||
// Check the widths of integral types.
|
||||
|
||||
#if SIZEOF_SHORT != 2
|
||||
# error TagLib requires that short is 16-bit wide.
|
||||
#endif
|
||||
|
||||
#if SIZEOF_INT != 4
|
||||
# error TagLib requires that int is 32-bit wide.
|
||||
#endif
|
||||
|
||||
#if SIZEOF_LONGLONG != 8
|
||||
# error TagLib requires that long long is 64-bit wide.
|
||||
#endif
|
||||
|
||||
#if SIZEOF_WCHAR_T < 2
|
||||
# error TagLib requires that wchar_t is sufficient to store a UTF-16 char.
|
||||
#endif
|
||||
|
||||
// Atomic increment/decrement operations
|
||||
|
||||
#if defined(HAVE_STD_ATOMIC)
|
||||
# include <atomic>
|
||||
# define TAGLIB_ATOMIC_INT std::atomic<unsigned int>
|
||||
# define TAGLIB_ATOMIC_INC(x) x.fetch_add(1)
|
||||
# define TAGLIB_ATOMIC_DEC(x) (x.fetch_sub(1) - 1)
|
||||
#elif defined(HAVE_BOOST_ATOMIC)
|
||||
# include <boost/atomic.hpp>
|
||||
# define TAGLIB_ATOMIC_INT boost::atomic<unsigned int>
|
||||
# define TAGLIB_ATOMIC_INC(x) x.fetch_add(1)
|
||||
# define TAGLIB_ATOMIC_DEC(x) (x.fetch_sub(1) - 1)
|
||||
#elif defined(HAVE_GCC_ATOMIC)
|
||||
# define TAGLIB_ATOMIC_INT int
|
||||
# define TAGLIB_ATOMIC_INC(x) __sync_add_and_fetch(&x, 1)
|
||||
# define TAGLIB_ATOMIC_DEC(x) __sync_sub_and_fetch(&x, 1)
|
||||
#elif defined(HAVE_WIN_ATOMIC)
|
||||
# if !defined(NOMINMAX)
|
||||
# define NOMINMAX
|
||||
# endif
|
||||
# include <windows.h>
|
||||
# define TAGLIB_ATOMIC_INT long
|
||||
# define TAGLIB_ATOMIC_INC(x) InterlockedIncrement(&x)
|
||||
# define TAGLIB_ATOMIC_DEC(x) InterlockedDecrement(&x)
|
||||
#elif defined(HAVE_MAC_ATOMIC)
|
||||
# include <libkern/OSAtomic.h>
|
||||
# define TAGLIB_ATOMIC_INT int32_t
|
||||
# define TAGLIB_ATOMIC_INC(x) OSAtomicIncrement32Barrier(&x)
|
||||
# define TAGLIB_ATOMIC_DEC(x) OSAtomicDecrement32Barrier(&x)
|
||||
#elif defined(HAVE_IA64_ATOMIC)
|
||||
# include <ia64intrin.h>
|
||||
# define TAGLIB_ATOMIC_INT int
|
||||
# define TAGLIB_ATOMIC_INC(x) __sync_add_and_fetch(&x, 1)
|
||||
# define TAGLIB_ATOMIC_DEC(x) __sync_sub_and_fetch(&x, 1)
|
||||
#else
|
||||
# define TAGLIB_ATOMIC_INT int
|
||||
# define TAGLIB_ATOMIC_INC(x) (++x)
|
||||
# define TAGLIB_ATOMIC_DEC(x) (--x)
|
||||
#endif
|
||||
|
||||
// Optimized byte swap functions.
|
||||
|
||||
#if defined(HAVE_MSC_BYTESWAP)
|
||||
# include <stdlib.h>
|
||||
#elif defined(HAVE_GLIBC_BYTESWAP)
|
||||
# include <byteswap.h>
|
||||
#elif defined(HAVE_MAC_BYTESWAP)
|
||||
# include <libkern/OSByteOrder.h>
|
||||
#elif defined(HAVE_OPENBSD_BYTESWAP)
|
||||
# include <sys/endian.h>
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_GCC_BYTESWAP_16)
|
||||
# define TAGLIB_BYTESWAP_16(x) __builtin_bswap16(x)
|
||||
#elif defined(HAVE_MSC_BYTESWAP)
|
||||
# define TAGLIB_BYTESWAP_16(x) _byteswap_ushort(x)
|
||||
#elif defined(HAVE_GLIBC_BYTESWAP)
|
||||
# define TAGLIB_BYTESWAP_16(x) __bswap_16(x)
|
||||
#elif defined(HAVE_MAC_BYTESWAP)
|
||||
# define TAGLIB_BYTESWAP_16(x) OSSwapInt16(x)
|
||||
#elif defined(HAVE_OPENBSD_BYTESWAP)
|
||||
# define TAGLIB_BYTESWAP_16(x) swap16(x)
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_GCC_BYTESWAP_32)
|
||||
# define TAGLIB_BYTESWAP_32(x) __builtin_bswap32(x)
|
||||
#elif defined(HAVE_MSC_BYTESWAP)
|
||||
# define TAGLIB_BYTESWAP_32(x) _byteswap_ulong(x)
|
||||
#elif defined(HAVE_GLIBC_BYTESWAP)
|
||||
# define TAGLIB_BYTESWAP_32(x) __bswap_32(x)
|
||||
#elif defined(HAVE_MAC_BYTESWAP)
|
||||
# define TAGLIB_BYTESWAP_32(x) OSSwapInt32(x)
|
||||
#elif defined(HAVE_OPENBSD_BYTESWAP)
|
||||
# define TAGLIB_BYTESWAP_32(x) swap32(x)
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_GCC_BYTESWAP_64)
|
||||
# define TAGLIB_BYTESWAP_64(x) __builtin_bswap64(x)
|
||||
#elif defined(HAVE_MSC_BYTESWAP)
|
||||
# define TAGLIB_BYTESWAP_64(x) _byteswap_uint64(x)
|
||||
#elif defined(HAVE_GLIBC_BYTESWAP)
|
||||
# define TAGLIB_BYTESWAP_64(x) __bswap_64(x)
|
||||
#elif defined(HAVE_MAC_BYTESWAP)
|
||||
# define TAGLIB_BYTESWAP_64(x) OSSwapInt64(x)
|
||||
#elif defined(HAVE_OPENBSD_BYTESWAP)
|
||||
# define TAGLIB_BYTESWAP_64(x) swap64(x)
|
||||
#endif
|
||||
|
||||
//! A namespace for all TagLib related classes and functions
|
||||
|
||||
@ -180,35 +73,7 @@ namespace TagLib {
|
||||
* Unfortunately std::wstring isn't defined on some systems, (i.e. GCC < 3)
|
||||
* so I'm providing something here that should be constant.
|
||||
*/
|
||||
#ifdef HAVE_STD_WSTRING
|
||||
typedef std::wstring wstring;
|
||||
#else
|
||||
typedef std::basic_string<wchar> wstring;
|
||||
#endif
|
||||
|
||||
#ifndef DO_NOT_DOCUMENT // Tell Doxygen to skip this class.
|
||||
/*!
|
||||
* \internal
|
||||
* This is just used as a base class for shared classes in TagLib.
|
||||
*
|
||||
* \warning This <b>is not</b> part of the TagLib public API!
|
||||
*/
|
||||
|
||||
class RefCounter
|
||||
{
|
||||
public:
|
||||
RefCounter() : refCount(1) {}
|
||||
|
||||
void ref() { TAGLIB_ATOMIC_INC(refCount); }
|
||||
bool deref() { return (TAGLIB_ATOMIC_DEC(refCount) == 0); }
|
||||
int count() { return refCount; }
|
||||
|
||||
private:
|
||||
volatile TAGLIB_ATOMIC_INT refCount;
|
||||
};
|
||||
|
||||
#endif // DO_NOT_DOCUMENT
|
||||
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -23,11 +23,25 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
#if defined(HAVE_MSC_BYTESWAP)
|
||||
# include <stdlib.h>
|
||||
#elif defined(HAVE_GLIBC_BYTESWAP)
|
||||
# include <byteswap.h>
|
||||
#elif defined(HAVE_MAC_BYTESWAP)
|
||||
# include <libkern/OSByteOrder.h>
|
||||
#elif defined(HAVE_OPENBSD_BYTESWAP)
|
||||
# include <sys/endian.h>
|
||||
#endif
|
||||
|
||||
#include <tstring.h>
|
||||
#include <tdebug.h>
|
||||
#include "trefcounter.h"
|
||||
|
||||
#include "tbytevector.h"
|
||||
|
||||
@ -185,9 +199,25 @@ T byteSwap(T x)
|
||||
template <>
|
||||
ushort byteSwap<ushort>(ushort x)
|
||||
{
|
||||
#ifdef TAGLIB_BYTESWAP_16
|
||||
#if defined(HAVE_GCC_BYTESWAP_16)
|
||||
|
||||
return TAGLIB_BYTESWAP_16(x);
|
||||
return __builtin_bswap16(x);
|
||||
|
||||
#elif defined(HAVE_MSC_BYTESWAP)
|
||||
|
||||
return _byteswap_ushort(x);
|
||||
|
||||
#elif defined(HAVE_GLIBC_BYTESWAP)
|
||||
|
||||
return __bswap_16(x);
|
||||
|
||||
#elif defined(HAVE_MAC_BYTESWAP)
|
||||
|
||||
return OSSwapInt16(x);
|
||||
|
||||
#elif defined(HAVE_OPENBSD_BYTESWAP)
|
||||
|
||||
return swap16(x);
|
||||
|
||||
#else
|
||||
|
||||
@ -199,9 +229,25 @@ ushort byteSwap<ushort>(ushort x)
|
||||
template <>
|
||||
uint byteSwap<uint>(uint x)
|
||||
{
|
||||
#ifdef TAGLIB_BYTESWAP_32
|
||||
#if defined(HAVE_GCC_BYTESWAP_32)
|
||||
|
||||
return TAGLIB_BYTESWAP_32(x);
|
||||
return __builtin_bswap32(x);
|
||||
|
||||
#elif defined(HAVE_MSC_BYTESWAP)
|
||||
|
||||
return _byteswap_ulong(x);
|
||||
|
||||
#elif defined(HAVE_GLIBC_BYTESWAP)
|
||||
|
||||
return __bswap_32(x);
|
||||
|
||||
#elif defined(HAVE_MAC_BYTESWAP)
|
||||
|
||||
return OSSwapInt32(x);
|
||||
|
||||
#elif defined(HAVE_OPENBSD_BYTESWAP)
|
||||
|
||||
return swap32(x);
|
||||
|
||||
#else
|
||||
|
||||
@ -216,9 +262,25 @@ uint byteSwap<uint>(uint x)
|
||||
template <>
|
||||
ulonglong byteSwap<ulonglong>(ulonglong x)
|
||||
{
|
||||
#ifdef TAGLIB_BYTESWAP_64
|
||||
#if defined(HAVE_GCC_BYTESWAP_64)
|
||||
|
||||
return TAGLIB_BYTESWAP_64(x);
|
||||
return __builtin_bswap64(x);
|
||||
|
||||
#elif defined(HAVE_MSC_BYTESWAP)
|
||||
|
||||
return _byteswap_uint64(x);
|
||||
|
||||
#elif defined(HAVE_GLIBC_BYTESWAP)
|
||||
|
||||
return __bswap_64(x);
|
||||
|
||||
#elif defined(HAVE_MAC_BYTESWAP)
|
||||
|
||||
return OSSwapInt64(x);
|
||||
|
||||
#elif defined(HAVE_OPENBSD_BYTESWAP)
|
||||
|
||||
return swap64(x);
|
||||
|
||||
#else
|
||||
|
||||
@ -246,7 +308,7 @@ T toNumber(const ByteVector &v, size_t offset, bool mostSignificantByteFirst)
|
||||
T tmp;
|
||||
::memcpy(&tmp, v.data() + offset, sizeof(T));
|
||||
|
||||
#ifdef TAGLIB_LITTLE_ENDIAN
|
||||
#if SYSTEM_BYTEORDER == 1
|
||||
const bool swap = mostSignificantByteFirst;
|
||||
#else
|
||||
const bool swap != mostSignificantByteFirst;
|
||||
@ -279,7 +341,7 @@ ByteVector fromNumber(T value, bool mostSignificantByteFirst)
|
||||
{
|
||||
const size_t size = sizeof(T);
|
||||
|
||||
#ifdef TAGLIB_LITTLE_ENDIAN
|
||||
#if SYSTEM_BYTEORDER == 1
|
||||
const bool swap = mostSignificantByteFirst;
|
||||
#else
|
||||
const bool swap != mostSignificantByteFirst;
|
||||
|
@ -24,6 +24,7 @@
|
||||
***************************************************************************/
|
||||
|
||||
#include <algorithm>
|
||||
#include "trefcounter.h"
|
||||
|
||||
namespace TagLib {
|
||||
|
||||
|
@ -23,6 +23,8 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "trefcounter.h"
|
||||
|
||||
namespace TagLib {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
105
taglib/toolkit/trefcounter.cpp
Normal file
105
taglib/toolkit/trefcounter.cpp
Normal file
@ -0,0 +1,105 @@
|
||||
/***************************************************************************
|
||||
copyright : (C) 2013 by Tsuda Kageyu
|
||||
email : tsuda.kageyu@gmail.com
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
#include "trefcounter.h"
|
||||
|
||||
#if defined(HAVE_STD_ATOMIC)
|
||||
# include <atomic>
|
||||
# define ATOMIC_INT std::atomic<unsigned int>
|
||||
# define ATOMIC_INC(x) x.fetch_add(1)
|
||||
# define ATOMIC_DEC(x) (x.fetch_sub(1) - 1)
|
||||
#elif defined(HAVE_BOOST_ATOMIC)
|
||||
# include <boost/atomic.hpp>
|
||||
# define ATOMIC_INT boost::atomic<unsigned int>
|
||||
# define ATOMIC_INC(x) x.fetch_add(1)
|
||||
# define ATOMIC_DEC(x) (x.fetch_sub(1) - 1)
|
||||
#elif defined(HAVE_GCC_ATOMIC)
|
||||
# define ATOMIC_INT int
|
||||
# define ATOMIC_INC(x) __sync_add_and_fetch(&x, 1)
|
||||
# define ATOMIC_DEC(x) __sync_sub_and_fetch(&x, 1)
|
||||
#elif defined(HAVE_WIN_ATOMIC)
|
||||
# if !defined(NOMINMAX)
|
||||
# define NOMINMAX
|
||||
# endif
|
||||
# include <windows.h>
|
||||
# define ATOMIC_INT long
|
||||
# define ATOMIC_INC(x) InterlockedIncrement(&x)
|
||||
# define ATOMIC_DEC(x) InterlockedDecrement(&x)
|
||||
#elif defined(HAVE_MAC_ATOMIC)
|
||||
# include <libkern/OSAtomic.h>
|
||||
# define ATOMIC_INT int32_t
|
||||
# define ATOMIC_INC(x) OSAtomicIncrement32Barrier(&x)
|
||||
# define ATOMIC_DEC(x) OSAtomicDecrement32Barrier(&x)
|
||||
#elif defined(HAVE_IA64_ATOMIC)
|
||||
# include <ia64intrin.h>
|
||||
# define ATOMIC_INT int
|
||||
# define ATOMIC_INC(x) __sync_add_and_fetch(&x, 1)
|
||||
# define ATOMIC_DEC(x) __sync_sub_and_fetch(&x, 1)
|
||||
#else
|
||||
# define ATOMIC_INT int
|
||||
# define ATOMIC_INC(x) (++x)
|
||||
# define ATOMIC_DEC(x) (--x)
|
||||
#endif
|
||||
|
||||
namespace TagLib
|
||||
{
|
||||
class RefCounter::RefCounterPrivate
|
||||
{
|
||||
public:
|
||||
RefCounterPrivate() : refCount(1) {}
|
||||
|
||||
void ref() { ATOMIC_INC(refCount); }
|
||||
bool deref() { return (ATOMIC_DEC(refCount) == 0); }
|
||||
int count() const { return refCount; }
|
||||
|
||||
volatile ATOMIC_INT refCount;
|
||||
};
|
||||
|
||||
RefCounter::RefCounter()
|
||||
: d(new RefCounterPrivate())
|
||||
{
|
||||
}
|
||||
|
||||
RefCounter::~RefCounter()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
void RefCounter::ref()
|
||||
{
|
||||
d->ref();
|
||||
}
|
||||
|
||||
bool RefCounter::deref()
|
||||
{
|
||||
return d->deref();
|
||||
}
|
||||
|
||||
int RefCounter::count() const
|
||||
{
|
||||
return d->count();
|
||||
}
|
||||
}
|
57
taglib/toolkit/trefcounter.h
Normal file
57
taglib/toolkit/trefcounter.h
Normal file
@ -0,0 +1,57 @@
|
||||
/***************************************************************************
|
||||
copyright : (C) 2013 by Tsuda Kageyu
|
||||
email : tsuda.kageyu@gmail.com
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef TAGLIB_REFCOUNTER_H
|
||||
#define TAGLIB_REFCOUNTER_H
|
||||
|
||||
#include "taglib.h"
|
||||
|
||||
#ifndef DO_NOT_DOCUMENT // Tell Doxygen to skip this class.
|
||||
/*!
|
||||
* \internal
|
||||
* This is just used as a base class for shared classes in TagLib.
|
||||
*
|
||||
* \warning This <b>is not</b> part of the TagLib public API!
|
||||
*/
|
||||
namespace TagLib
|
||||
{
|
||||
class RefCounter
|
||||
{
|
||||
public:
|
||||
RefCounter();
|
||||
virtual ~RefCounter();
|
||||
|
||||
void ref();
|
||||
bool deref();
|
||||
int count() const;
|
||||
|
||||
private:
|
||||
class RefCounterPrivate;
|
||||
RefCounterPrivate *d;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // DO_NOT_DOCUMENT
|
||||
#endif
|
@ -25,17 +25,24 @@
|
||||
|
||||
// This class assumes that std::basic_string<T> has a contiguous and null-terminated buffer.
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "tstring.h"
|
||||
#include "tdebug.h"
|
||||
#include "tstringlist.h"
|
||||
#include "trefcounter.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <string.h>
|
||||
|
||||
// x86 CPUs are alignment-tolerant or allow pointer casts from smaller types to larger types.
|
||||
#if defined(__i386__) || defined(_M_IX86) || defined(__amd64) || defined(__amd64__) \
|
||||
|| defined(_M_AMD64) || defined(__x86_64) || defined(__x86_64__) || defined(_M_X64)
|
||||
# define TAGLIB_ALIGNMENT_TOLERANT 1
|
||||
#if defined(HAVE_MSC_BYTESWAP)
|
||||
# include <stdlib.h>
|
||||
#elif defined(HAVE_GLIBC_BYTESWAP)
|
||||
# include <byteswap.h>
|
||||
#elif defined(HAVE_MAC_BYTESWAP)
|
||||
# include <libkern/OSByteOrder.h>
|
||||
#elif defined(HAVE_OPENBSD_BYTESWAP)
|
||||
# include <sys/endian.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STD_CODECVT
|
||||
@ -48,13 +55,29 @@ namespace
|
||||
{
|
||||
inline TagLib::ushort byteSwap(TagLib::ushort x)
|
||||
{
|
||||
#ifdef TAGLIB_BYTESWAP_16
|
||||
#if defined(HAVE_GCC_BYTESWAP_16)
|
||||
|
||||
return TAGLIB_BYTESWAP_16(x);
|
||||
return __builtin_bswap16(x);
|
||||
|
||||
#elif defined(HAVE_MSC_BYTESWAP)
|
||||
|
||||
return _byteswap_ushort(x);
|
||||
|
||||
#elif defined(HAVE_GLIBC_BYTESWAP)
|
||||
|
||||
return __bswap_16(x);
|
||||
|
||||
#elif defined(HAVE_MAC_BYTESWAP)
|
||||
|
||||
return OSSwapInt16(x);
|
||||
|
||||
#elif defined(HAVE_OPENBSD_BYTESWAP)
|
||||
|
||||
return swap16(x);
|
||||
|
||||
#else
|
||||
|
||||
return((x >> 8) & 0xff) | ((x & 0xff) << 8);
|
||||
return ((x >> 8) & 0xff) | ((x & 0xff) << 8);
|
||||
|
||||
#endif
|
||||
}
|
||||
@ -813,12 +836,6 @@ void String::copyFromUTF16(const wchar_t *s, size_t length, Type t)
|
||||
|
||||
void String::copyFromUTF16(const char *s, size_t length, Type t)
|
||||
{
|
||||
#if SIZEOF_WCHAR_T == 2 && defined(TAGLIB_ALIGNMENT_TOLERANT)
|
||||
|
||||
copyFromUTF16(reinterpret_cast<const wchar_t*>(s), length / 2, t);
|
||||
|
||||
#else
|
||||
|
||||
bool swap;
|
||||
if(t == UTF16) {
|
||||
if(length < 2) {
|
||||
@ -850,11 +867,9 @@ void String::copyFromUTF16(const char *s, size_t length, Type t)
|
||||
d->data[i] = swap ? combine(*s, *(s + 1)) : combine(*(s + 1), *s);
|
||||
s += 2;
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef TAGLIB_LITTLE_ENDIAN
|
||||
#if SYSTEM_BYTEORDER == 1
|
||||
|
||||
const String::Type String::WCharByteOrder = String::UTF16LE;
|
||||
|
||||
|
@ -6,9 +6,6 @@
|
||||
#include <vorbisfile.h>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include "utils.h"
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
using namespace TagLib;
|
||||
|
@ -1,6 +1,5 @@
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
#include "config.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#else
|
||||
|
Loading…
Reference in New Issue
Block a user