ct-ng bundled patch: 0006-Darwin-Two-fixes-from-Android-NDK-PTHREAD_ONCE_INIT-wcsncasecmp.patch

1. In Drawin PTHREAD_ONCE_INIT is {0x30B1BCBA, {0}} and the GCC < 4.4
   doesn't support ended initializer list
2. wcsncasecmp doesn't exist in MacSDK10.6.x

Change-Id: I69204a72f853f5263dffedc448379d75ed4eca2e
This commit is contained in:
Andrew Hsieh
2015-03-18 10:57:24 +08:00
committed by Alexey Lapshin
parent fb1b314bd6
commit ddc88711fa
2 changed files with 34 additions and 3 deletions

View File

@@ -3688,6 +3688,28 @@ u16_mbtouc (wint_t * puc, const unsigned short * s, unsigned int n)
} }
#endif /* not Cygwin/Mingw */ #endif /* not Cygwin/Mingw */
#if defined __APPLE__ && __DARWIN_C_LEVEL < 200809L
/* wcsncasecmp isn't always defined in Mac SDK */
static int
wcsncasecmp(const wchar_t *s1, const wchar_t *s2, size_t n)
{
wchar_t c1, c2;
if (n == 0)
return (0);
for (; *s1; s1++, s2++)
{
c1 = towlower(*s1);
c2 = towlower(*s2);
if (c1 != c2)
return ((int)c1 - c2);
if (--n == 0)
return (0);
}
return (-*s2);
}
#endif
/* Perform a comparison of two entries. */ /* Perform a comparison of two entries. */
static signed int static signed int
rsrc_cmp (bool is_name, rsrc_entry * a, rsrc_entry * b) rsrc_cmp (bool is_name, rsrc_entry * a, rsrc_entry * b)

View File

@@ -285,8 +285,17 @@ class Once_initialize
{ {
public: public:
Once_initialize() Once_initialize()
#if !defined(__APPLE__)
: once_(PTHREAD_ONCE_INIT) : once_(PTHREAD_ONCE_INIT)
{ } { }
#else
// In Drawin PTHREAD_ONCE_INIT is {0x30B1BCBA, {0}} and the GCC < 4.4 doesn't support
// extended initializer list as above */
{
pthread_once_t once_2 = PTHREAD_ONCE_INIT;
once_ = once_2;
}
#endif
// Return a pointer to the pthread_once_t variable. // Return a pointer to the pthread_once_t variable.
pthread_once_t* pthread_once_t*