diff --git a/stepmania/src/archutils/Darwin/arch_setup.h b/stepmania/src/archutils/Darwin/arch_setup.h index 8a19d4a9ad..fff1f5bc0d 100644 --- a/stepmania/src/archutils/Darwin/arch_setup.h +++ b/stepmania/src/archutils/Darwin/arch_setup.h @@ -8,15 +8,37 @@ typedef unsigned long long UInt64; #define __TYPES__ #include #undef __TYPES__ -#if 0 -#define DARWIN 1 -#define NEED_POWF -#define NEED_SQRTF -#define NEED_SINF -#define NEED_COSF -#define NEED_TANF -#define NEED_ACOSF -#define NEED_STRTOF +#include +#if (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_3) +# define NEED_POWF +# define NEED_SQRTF +# define NEED_SINF +# define NEED_COSF +# define NEED_TANF +# define NEED_ACOSF +# define NEED_STRTOF +# include +# include +# include +namespace std +{ + typedef basic_string wstring; +} +typedef int socklen_t; +/* 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 +* definition out of math.h. +*/ +# include +# define isnan( x ) ( ( sizeof ( x ) == sizeof(double) ) ? \ + __isnand ( x ) : \ + ( sizeof ( x ) == sizeof( float) ) ? \ + __isnanf ( 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 #define BACKTRACE_LOOKUP_METHOD_DARWIN_DYLD #define BACKTRACE_METHOD_POWERPC_DARWIN @@ -25,7 +47,6 @@ typedef unsigned long long UInt64; #define HAVE_FFMPEG #define HAVE_SDL #define CRASH_HANDLER -#define _BSD_WCHAR_T_DEFINED_ #define ENDIAN_BIG #define CRYPTOPP_UNIX_AVAILABLE #ifndef __MACOSX__ @@ -35,11 +56,10 @@ typedef unsigned long long UInt64; #define ArchSwap24(n) (OSSwapInt32((n)) >> 8) #define ArchSwap16(n) OSSwapInt16((n)) #define HAVE_BYTE_SWAPS -#define NEED_CSTDLIB_WORKAROUND #endif /* - * (c) 2003-2004 Steve Checkoway + * (c) 2003-2005 Steve Checkoway * All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a diff --git a/stepmania/src/archutils/Darwin/wchar.cpp b/stepmania/src/archutils/Darwin/wchar.cpp index 19f90ea147..286e7ef16d 100644 --- a/stepmania/src/archutils/Darwin/wchar.cpp +++ b/stepmania/src/archutils/Darwin/wchar.cpp @@ -1,34 +1,32 @@ -/* - * wchar.cpp - * stepmania - * - * Created by Steve Checkoway on Tue Nov 25 2003. - * Copyright (c) 2003 Steve Checkoway. All rights reserved. - * - */ - #include +/* 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) - -#define _BSD_WCHAR_T_DEFINED_ +#include #include #include #include -extern "C" { -#ifndef wcslen +#define WEOF -1 +__BEGIN_DECLS size_t wcslen(const wchar_t *ws) { size_t n = 0; - while (*(ws++) != NULL) + while (*(ws++) != 0) ++n; return n; } -#endif -#ifndef wmemchr wchar_t *wmemchr(const wchar_t *ws, wchar_t wc, size_t n) { for (unsigned i=0; i + struct char_traits + { + 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(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::assign(wchar_t& __c1, wchar_t const& __c2) + { + __c1 = __c2; + } + + size_t char_traits::length(const char_type* __s) + { + return wcslen(__s); + } + + // This return type should be char_traits::char_type*. wchar_t + // is shorter. + wchar_t* char_traits::copy(char_type* __s1, const char_type* __s2, + size_t __n) + { + return wmemcpy(__s1, __s2, __n); + } } -#ifndef wstring -template class std::basic_string, - std::allocator >; -#endif -/* This has nothing to do with this file, but I might as well put it here - * rather than make a new file just for it. - */ -#include -#include -using namespace std; - -template basic_istream >& - basic_istream >::seekg(fpos<__mbstate_t>); -template streampos - basic_streambuf >::pubseekpos(fpos<__mbstate_t>, - _Ios_Openmode); - +template class std::basic_string; #endif /* - * (c) 2003-2004 Steve Checkoway + * (c) 2003-2005 Steve Checkoway * All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a