From 175e835fb2403a9fe6a620c9a663b3045547dfe6 Mon Sep 17 00:00:00 2001
From: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
Date: Tue, 20 Dec 2016 15:53:39 -0800
Subject: [PATCH 1006/1007] 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 <jeremyhu@apple.com>
---
 lib/Lex/HeaderMap.cpp | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git llvm_master/tools/clang/lib/Lex/HeaderMap.cpp macports_master/tools/clang/lib/Lex/HeaderMap.cpp
index e0bf58b675..1db3380602 100644
--- llvm_master/tools/clang/lib/Lex/HeaderMap.cpp
+++ macports_master/tools/clang/lib/Lex/HeaderMap.cpp
@@ -25,6 +25,20 @@
 #include <memory>
 using namespace clang;
 
+#ifdef __APPLE__
+#include <Availability.h>
+#if __MAC_OS_X_VERSION_MIN_REQUIRED < 1070
+static size_t strnlen(const char *s, size_t maxlen) {
+  size_t l = 0;
+  while (l < maxlen && *s) {
+    l++;
+    s++;
+  }
+  return l;
+}
+#endif
+#endif
+
 /// HashHMapKey - This is the 'well known' hash function required by the file
 /// format, used to look up keys in the hash table.  The hash table uses simple
 /// linear probing based on this function.
-- 
2.21.0 (Apple Git-120)

