<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">From 80258ba25b9f0a074af6e10bf6bf28d61b69771e Mon Sep 17 00:00:00 2001
From: Jeremy Huddleston Sequoia &lt;jeremyhu@apple.com&gt;
Date: Tue, 20 Dec 2016 12:41:21 -0800
Subject: [PATCH 4/4] Fix build issues pre-Lion due to missing a strnlen
 definition

https://trac.macports.org/ticket/51520
https://llvm.org/bugs/show_bug.cgi?id=27714

Signed-off-by: Jeremy Huddleston Sequoia &lt;jeremyhu@apple.com&gt;
---
 lib/ObjectYAML/MachOYAML.cpp  | 14 ++++++++++++++
 tools/obj2yaml/macho2yaml.cpp | 16 +++++++++++++++-
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git llvm_release_50/lib/ObjectYAML/MachOYAML.cpp macports_release_50/lib/ObjectYAML/MachOYAML.cpp
index ab452a7bf6e..ace3743a73a 100644
--- llvm_release_50/lib/ObjectYAML/MachOYAML.cpp
+++ macports_release_50/lib/ObjectYAML/MachOYAML.cpp
@@ -22,6 +22,20 @@
 #include &lt;cstdint&gt;
 #include &lt;cstring&gt;
 
+#ifdef __APPLE__
+#include &lt;Availability.h&gt;
+#if __MAC_OS_X_VERSION_MIN_REQUIRED &lt; 1070
+static size_t strnlen(const char *s, size_t maxlen) {
+  size_t l = 0;
+  while (l &lt; maxlen &amp;&amp; *s) {
+    l++;
+    s++;
+  }
+  return l;
+}
+#endif
+#endif
+
 namespace llvm {
 
 MachOYAML::LoadCommand::~LoadCommand() = default;
diff --git llvm_release_50/tools/obj2yaml/macho2yaml.cpp macports_release_50/tools/obj2yaml/macho2yaml.cpp
index a1d107dc5af..01934da8078 100644
--- llvm_release_50/tools/obj2yaml/macho2yaml.cpp
+++ macports_release_50/tools/obj2yaml/macho2yaml.cpp
@@ -15,7 +15,21 @@
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/LEB128.h"
 
-#include &lt;string.h&gt; // for memcpy
+#include &lt;string.h&gt; // for memcpy abd strnlen
+
+#ifdef __APPLE__
+#include &lt;Availability.h&gt;
+#if __MAC_OS_X_VERSION_MIN_REQUIRED &lt; 1070
+static size_t strnlen(const char *s, size_t maxlen) {
+  size_t l = 0;
+  while (l &lt; maxlen &amp;&amp; *s) {
+    l++;
+    s++;
+  }
+  return l;
+}
+#endif
+#endif
 
 using namespace llvm;
 
-- 
2.13.3

</pre></body></html>