Merge in changes from the 3.9 branch.
This commit is contained in:
@@ -8,23 +8,78 @@ typedef unsigned long long UInt64;
|
|||||||
#define __TYPES__
|
#define __TYPES__
|
||||||
#include <libkern/OSByteOrder.h>
|
#include <libkern/OSByteOrder.h>
|
||||||
#undef __TYPES__
|
#undef __TYPES__
|
||||||
#include <AvailabilityMacros.h>
|
#define BACKTRACE_LOOKUP_METHOD_DARWIN_DYLD
|
||||||
#if (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_3)
|
#define BACKTRACE_METHOD_POWERPC_DARWIN
|
||||||
|
#define HAVE_VERSION_INFO
|
||||||
|
#define HAVE_CXA_DEMANGLE
|
||||||
|
#define HAVE_FFMPEG
|
||||||
|
#define HAVE_SDL
|
||||||
|
#define CRASH_HANDLER
|
||||||
|
// Looking ahead to "Universal binaries."
|
||||||
|
#ifdef __BIG_ENDIAN__
|
||||||
|
# define ENDIAN_BIG
|
||||||
|
#else
|
||||||
|
# define ENDIAN_LITTLE
|
||||||
|
#endif
|
||||||
|
#define ENDIAN_BIG
|
||||||
|
|
||||||
|
#ifndef __MACOSX__
|
||||||
|
# define __MACOSX__
|
||||||
|
#endif
|
||||||
|
#define ArchSwap32(n) OSSwapInt32((n))
|
||||||
|
#define ArchSwap24(n) (OSSwapInt32((n)) >> 8)
|
||||||
|
#define ArchSwap16(n) OSSwapInt16((n))
|
||||||
|
#define HAVE_BYTE_SWAPS
|
||||||
|
|
||||||
|
#include <bits/c++config.h>
|
||||||
|
#if ! _GLIBCPP_HAVE_POWF
|
||||||
# define NEED_POWF
|
# define NEED_POWF
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ! _GLIBCPP_HAVE_SQRTF
|
||||||
# define NEED_SQRTF
|
# define NEED_SQRTF
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ! _GLIBCPP_HAVE_SINF
|
||||||
# define NEED_SINF
|
# define NEED_SINF
|
||||||
# define NEED_COSF
|
#endif
|
||||||
|
|
||||||
|
#if ! _GLIBCPP_HAVE_TANF
|
||||||
# define NEED_TANF
|
# define NEED_TANF
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ! _GLIBCPP_HAVE_COSF
|
||||||
|
# define NEED_COSF
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ! _GLIBCPP_HAVE_ACOSF
|
||||||
# define NEED_ACOSF
|
# define NEED_ACOSF
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ! _GLIBCPP_HAVE_STRTOF
|
||||||
# define NEED_STRTOF
|
# define NEED_STRTOF
|
||||||
# include <cstddef>
|
#endif
|
||||||
# include <string>
|
|
||||||
# include <cstdlib>
|
// Define the work around if needed.
|
||||||
namespace std
|
#include <stdint.h>
|
||||||
{
|
#if _GLIBCPP_USE_C99
|
||||||
typedef basic_string<wchar_t> wstring;
|
# define NEED_CSTDLIB_WORKAROUND
|
||||||
}
|
#else
|
||||||
|
inline int64_t llabs(int64_t x) { return x < 0LL ? -x : x; }
|
||||||
|
|
||||||
|
/* This is not correct. It's possible that _GLIBCPP_USE_C99 could be false
|
||||||
|
* and yet have socklen_t defined. In the BSD world, this seems to come from
|
||||||
|
* <machine/ansi.h>. However, all apple headers that include this have:
|
||||||
|
* #ifndef __APPLE__
|
||||||
|
* #include <machine/ansi.h>
|
||||||
|
* #endif
|
||||||
|
* Since it appears we shouldn't include that for OS X builds, let's just
|
||||||
|
* make the assumption that if we can use c99 that socklen_t is defined and
|
||||||
|
* if we cannot, then it isn't. For the only two builds (on OS X) we care about,
|
||||||
|
* namely supporting 10.2.8 and the current OS, this _should_ hold true.
|
||||||
|
*/
|
||||||
typedef int socklen_t;
|
typedef int socklen_t;
|
||||||
|
|
||||||
/* cmath #undefs all of the math.h macros but fails to replace some of them
|
/* cmath #undefs all of the math.h macros but fails to replace some of them
|
||||||
* with functions if _GLIBCPP_USE_C99 is not defined. As such, yank the
|
* with functions if _GLIBCPP_USE_C99 is not defined. As such, yank the
|
||||||
* definition out of math.h.
|
* definition out of math.h.
|
||||||
@@ -35,27 +90,80 @@ typedef int socklen_t;
|
|||||||
( sizeof ( x ) == sizeof( float) ) ? \
|
( sizeof ( x ) == sizeof( float) ) ? \
|
||||||
__isnanf ( x ) : \
|
__isnanf ( x ) : \
|
||||||
__isnan ( x ) )
|
__isnan ( x ) )
|
||||||
// llabs is not defined either, copy it
|
|
||||||
inline long long llabs(long long __x) { return __x >= 0 ? __x : -__x; }
|
|
||||||
#else
|
|
||||||
# define NEED_CSTDLIB_WORKAROUND
|
|
||||||
#endif
|
#endif
|
||||||
#define BACKTRACE_LOOKUP_METHOD_DARWIN_DYLD
|
|
||||||
#define BACKTRACE_METHOD_POWERPC_DARWIN
|
#include <string>
|
||||||
#define HAVE_VERSION_INFO
|
#if ! _GLIBCPP_USE_WCHAR_T
|
||||||
#define HAVE_CXA_DEMANGLE
|
|
||||||
#define HAVE_FFMPEG
|
extern "C"
|
||||||
#define HAVE_SDL
|
{
|
||||||
#define CRASH_HANDLER
|
extern size_t wcslen(const wchar_t *ws);
|
||||||
#define ENDIAN_BIG
|
extern wchar_t *wmemchr(const wchar_t *ws, wchar_t wc, size_t n);
|
||||||
#define CRYPTOPP_UNIX_AVAILABLE
|
extern int wmemcmp(const wchar_t *ws1, const wchar_t *ws2, size_t n);
|
||||||
#ifndef __MACOSX__
|
extern wchar_t *wmemcpy(wchar_t *ws1, const wchar_t *ws2, size_t n);
|
||||||
# define __MACOSX__
|
extern wchar_t *wmemmove(wchar_t *ws1, const wchar_t *ws2, size_t n);
|
||||||
|
extern wchar_t *wmemset(wchar_t *ws , wchar_t wc, size_t n);
|
||||||
|
}
|
||||||
|
// C++ defines the wchar_t type even if glibc++ doesn't have the functions
|
||||||
|
namespace std
|
||||||
|
{
|
||||||
|
/* This is actually illegal but it should work. =)
|
||||||
|
* In addition, it's not complete, but it's good enough for us.
|
||||||
|
* http://www.unl.csi.cuny.edu/faqs/g++-faq/wp/sep96/lib-strings.html
|
||||||
|
*/
|
||||||
|
template<> struct char_traits<wchar_t>
|
||||||
|
{
|
||||||
|
typedef wchar_t char_type;
|
||||||
|
typedef wchar_t int_type; // it's big enough
|
||||||
|
/* streampos and wstreampos are both required to be typedefs for
|
||||||
|
* fpos<mbstate_t> as per clause 27.2--whatever that is.
|
||||||
|
*/
|
||||||
|
typedef streampos pos_type;
|
||||||
|
typedef streamoff off_type;
|
||||||
|
typedef mbstate_t state_type;
|
||||||
|
|
||||||
|
static void assign(char_type& c1, const char_type c2)
|
||||||
|
{
|
||||||
|
c1 = c2;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void assign(char_type *s, size_t n, char_type c)
|
||||||
|
{
|
||||||
|
wmemset(s, c, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int compare(const char_type *s1, const char_type *s2,
|
||||||
|
size_t n)
|
||||||
|
{
|
||||||
|
return wmemcmp(s1, s2, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
static char_type *copy(char_type *s1, const char_type *s2, size_t n)
|
||||||
|
{
|
||||||
|
return wmemcpy(s1, s2, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char_type *find(const char_type *s, size_t n,
|
||||||
|
const char_type& c)
|
||||||
|
{
|
||||||
|
return wmemchr(s, c, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
static size_t length(const char_type *s)
|
||||||
|
{
|
||||||
|
return wcslen(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
static char_type *move(char_type *s1, const char_type *s2, size_t n)
|
||||||
|
{
|
||||||
|
return wmemmove(s1, s2, n);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef basic_string<wchar_t> wstring;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#define ArchSwap32(n) OSSwapInt32((n))
|
|
||||||
#define ArchSwap24(n) (OSSwapInt32((n)) >> 8)
|
|
||||||
#define ArchSwap16(n) OSSwapInt16((n))
|
|
||||||
#define HAVE_BYTE_SWAPS
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -1,32 +1,20 @@
|
|||||||
#include <AvailabilityMacros.h>
|
#include <bits/c++config.h>
|
||||||
|
|
||||||
/* The Mac OS X 10.2.8 sdk is lacking wchar.h and all that goes with it.
|
|
||||||
* wchar_t is a fundamental type in c++ but is essentially useless with this
|
|
||||||
* sdk. As a result, this file contains all of the code required to actually
|
|
||||||
* use wchar_t, at least in StepMania. If this file is compiled with
|
|
||||||
* MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3 then the included
|
|
||||||
* wchar_t (and friends) is used.
|
|
||||||
*
|
|
||||||
* For maximum usability, this hack must be maintained as long as 10.2.8 is
|
|
||||||
* required to be supported.
|
|
||||||
*/
|
|
||||||
#if (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_3)
|
|
||||||
#include <sys/cdefs.h>
|
|
||||||
#include <cstddef>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
#define WEOF -1
|
extern "C"
|
||||||
__BEGIN_DECLS
|
{
|
||||||
|
#if ! _GLIBCPP_HAVE_WCLEN
|
||||||
size_t wcslen(const wchar_t *ws)
|
size_t wcslen(const wchar_t *ws)
|
||||||
{
|
{
|
||||||
size_t n = 0;
|
size_t n = 0;
|
||||||
|
|
||||||
while (*(ws++) != 0)
|
while (*(ws++) != L'\0')
|
||||||
++n;
|
++n;
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ! _GLIBCPP_HAVE_WMEMCHR
|
||||||
wchar_t *wmemchr(const wchar_t *ws, wchar_t wc, size_t n)
|
wchar_t *wmemchr(const wchar_t *ws, wchar_t wc, size_t n)
|
||||||
{
|
{
|
||||||
for (unsigned i=0; i<n; ++i, ++ws)
|
for (unsigned i=0; i<n; ++i, ++ws)
|
||||||
@@ -34,7 +22,9 @@ wchar_t *wmemchr(const wchar_t *ws, wchar_t wc, size_t n)
|
|||||||
return (wchar_t *)ws;
|
return (wchar_t *)ws;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ! _GLIBCPP_HAVE_WMEMCMP
|
||||||
int wmemcmp(const wchar_t *ws1, const wchar_t *ws2, size_t n)
|
int wmemcmp(const wchar_t *ws1, const wchar_t *ws2, size_t n)
|
||||||
{
|
{
|
||||||
for (unsigned i=0; i<n; ++i, ++ws1, ++ws2)
|
for (unsigned i=0; i<n; ++i, ++ws1, ++ws2)
|
||||||
@@ -42,17 +32,23 @@ int wmemcmp(const wchar_t *ws1, const wchar_t *ws2, size_t n)
|
|||||||
return *ws1 - *ws2;
|
return *ws1 - *ws2;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ! _GLIBCPP_HAVE_WMEMCPY
|
||||||
wchar_t *wmemcpy(wchar_t *ws1, const wchar_t *ws2, size_t n)
|
wchar_t *wmemcpy(wchar_t *ws1, const wchar_t *ws2, size_t n)
|
||||||
{
|
{
|
||||||
return (wchar_t *)memcpy(ws1, ws2, n * sizeof(wchar_t));
|
return (wchar_t *)memcpy(ws1, ws2, n * sizeof(wchar_t));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ! _GLIBCPP_HAVE_WMEMMOVE
|
||||||
wchar_t *wmemmove(wchar_t *ws1, const wchar_t *ws2, size_t n)
|
wchar_t *wmemmove(wchar_t *ws1, const wchar_t *ws2, size_t n)
|
||||||
{
|
{
|
||||||
return (wchar_t *)memmove(ws1, ws2, n * sizeof(wchar_t));
|
return (wchar_t *)memmove(ws1, ws2, n * sizeof(wchar_t));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ! _GLIBCPP_HAVE_WMEMSET
|
||||||
wchar_t *wmemset(wchar_t *ws , wchar_t wc, size_t n)
|
wchar_t *wmemset(wchar_t *ws , wchar_t wc, size_t n)
|
||||||
{
|
{
|
||||||
wchar_t *temp = ws;
|
wchar_t *temp = ws;
|
||||||
@@ -60,113 +56,8 @@ wchar_t *wmemset(wchar_t *ws , wchar_t wc, size_t n)
|
|||||||
*temp = wc;
|
*temp = wc;
|
||||||
return ws;
|
return ws;
|
||||||
}
|
}
|
||||||
__END_DECLS
|
|
||||||
|
|
||||||
// copy and paste for the most part
|
|
||||||
namespace std
|
|
||||||
{
|
|
||||||
typedef wchar_t wint_t;
|
|
||||||
typedef wint_t wstreampos;
|
|
||||||
|
|
||||||
template<>
|
|
||||||
struct char_traits<wchar_t>
|
|
||||||
{
|
|
||||||
typedef wchar_t char_type;
|
|
||||||
typedef wint_t int_type;
|
|
||||||
typedef streamoff off_type;
|
|
||||||
typedef wstreampos pos_type;
|
|
||||||
typedef mbstate_t state_type;
|
|
||||||
|
|
||||||
// gcc is being stupid and not allowing me to define it here
|
|
||||||
static void assign(char_type& __c1, const char_type& __c2);
|
|
||||||
|
|
||||||
static bool eq(const char_type& __c1, const char_type& __c2)
|
|
||||||
{
|
|
||||||
return __c1 == __c2;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool lt(const char_type& __c1, const char_type& __c2)
|
|
||||||
{
|
|
||||||
return __c1 < __c2;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int compare(const char_type* __s1, const char_type* __s2,
|
|
||||||
size_t __n)
|
|
||||||
{
|
|
||||||
return wmemcmp(__s1, __s2, __n);
|
|
||||||
}
|
|
||||||
|
|
||||||
// same here
|
|
||||||
static size_t length(const char_type* __s);
|
|
||||||
|
|
||||||
static const char_type* find(const char_type* __s, size_t __n,
|
|
||||||
const char_type& __a)
|
|
||||||
{
|
|
||||||
return wmemchr(__s, __a, __n);
|
|
||||||
}
|
|
||||||
|
|
||||||
static char_type* move(char_type* __s1, const char_type* __s2,
|
|
||||||
int_type __n)
|
|
||||||
{
|
|
||||||
return wmemmove(__s1, __s2, __n);
|
|
||||||
}
|
|
||||||
|
|
||||||
// and here
|
|
||||||
static char_type* copy(char_type* __s1, const char_type* __s2,
|
|
||||||
size_t __n);
|
|
||||||
|
|
||||||
static char_type* assign(char_type* __s, size_t __n, char_type __a)
|
|
||||||
{
|
|
||||||
return wmemset(__s, __a, __n);
|
|
||||||
}
|
|
||||||
|
|
||||||
static char_type to_char_type(const int_type& __c)
|
|
||||||
{
|
|
||||||
return char_type(__c);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int_type to_int_type(const char_type& __c)
|
|
||||||
{
|
|
||||||
return int_type(__c);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool eq_int_type(const int_type& __c1, const int_type& __c2)
|
|
||||||
{
|
|
||||||
return __c1 == __c2;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int_type eof()
|
|
||||||
{
|
|
||||||
return static_cast<int_type>(WEOF);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int_type not_eof(const int_type& __c)
|
|
||||||
{
|
|
||||||
return eq_int_type(__c, eof()) ? 0 : __c;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
// So, let's just do it here
|
|
||||||
void char_traits<wchar_t>::assign(wchar_t& __c1, wchar_t const& __c2)
|
|
||||||
{
|
|
||||||
__c1 = __c2;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t char_traits<wchar_t>::length(const char_type* __s)
|
|
||||||
{
|
|
||||||
return wcslen(__s);
|
|
||||||
}
|
|
||||||
|
|
||||||
// This return type should be char_traits<wchar_t>::char_type*. wchar_t
|
|
||||||
// is shorter.
|
|
||||||
wchar_t* char_traits<wchar_t>::copy(char_type* __s1, const char_type* __s2,
|
|
||||||
size_t __n)
|
|
||||||
{
|
|
||||||
return wmemcpy(__s1, __s2, __n);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template class std::basic_string<wchar_t>;
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (c) 2003-2005 Steve Checkoway
|
* (c) 2003-2005 Steve Checkoway
|
||||||
|
|||||||
Reference in New Issue
Block a user