Skip to content

Commit

Permalink
Fix darwin build
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Andrew Hsieh authored and antmak committed Dec 23, 2020
1 parent 2d62ac1 commit c603ddd
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
22 changes: 22 additions & 0 deletions bfd/peXXigen.c
Original file line number Diff line number Diff line change
Expand Up @@ -3696,6 +3696,28 @@ u16_mbtouc (wchar_t * puc, const unsigned short * s, unsigned int n)
}
#endif /* HAVE_WCHAR_H and 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. */
static signed int
rsrc_cmp (bfd_boolean is_name, rsrc_entry * a, rsrc_entry * b)
Expand Down
15 changes: 12 additions & 3 deletions gold/gold-threads.cc
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,18 @@ Condvar::~Condvar()
class Once_initialize
{
public:
Once_initialize()
: once_(PTHREAD_ONCE_INIT)
{ }
Once_initialize()
#if !defined(__APPLE__)
: 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.
pthread_once_t*
Expand Down

0 comments on commit c603ddd

Please sign in to comment.