aboutsummaryrefslogtreecommitdiff
path: root/packages/binutils/2.44/0003-Fix-darwin-build.patch
blob: 5f6cc8d231f56620d6cbbf5580c926d7fbc49477 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
From caeb8d1403fa6ce3334ac8527bc89d3103b3c604 Mon Sep 17 00:00:00 2001
From: Andrew Hsieh <andrewhsieh@google.com>
Date: Wed, 18 Mar 2015 10:57:24 +0800
Subject: [PATCH 5/8] Fix darwin build

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
---
 bfd/peXXigen.c       |   22 ++++++++++++++++++++++
 gold/gold-threads.cc |   15 ++++++++++++---
 2 files changed, 34 insertions(+), 3 deletions(-)

--- a/bfd/peXXigen.c
+++ b/bfd/peXXigen.c
@@ -3681,6 +3681,28 @@ u16_mbtouc (wint_t * puc, const unsigned
 }
 #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.  */
 static signed int
 rsrc_cmp (bool is_name, rsrc_entry * a, rsrc_entry * b)