summaryrefslogtreecommitdiff
path: root/src/posix.h
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2014-01-03 11:37:23 -0800
committerRussell Belfer <rb@github.com>2014-01-03 11:37:23 -0800
commitb49985212a395b54dbaa50c7d39faaaf6f4c4f4b (patch)
tree9563f0f96b6c40a0cb92176532af26772135e6a8 /src/posix.h
parent9152417290e7e375552638c2b340e9163c80dd8d (diff)
downloadlibgit2-b49985212a395b54dbaa50c7d39faaaf6f4c4f4b.tar.gz
Use our strnlen on MacOS for backward compat
Apparently MacOS didn't have strnlen on 10.6 and earlier. To avoid having linking problems on older versions, we'll just use our internal version.
Diffstat (limited to 'src/posix.h')
-rw-r--r--src/posix.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/posix.h b/src/posix.h
index f529914fe..0d9be49a9 100644
--- a/src/posix.h
+++ b/src/posix.h
@@ -89,13 +89,17 @@ extern struct tm * p_gmtime_r (const time_t *timer, struct tm *result);
# include "unix/posix.h"
#endif
-#if defined(__MINGW32__) || defined(__sun)
+#if defined(__MINGW32__) || defined(__sun) || defined(__APPLE__)
+# define NO_STRNLEN
+#endif
+
+#ifdef NO_STRNLEN
GIT_INLINE(size_t) p_strnlen(const char *s, size_t maxlen) {
const char *end = memchr(s, 0, maxlen);
return end ? (size_t)(end - s) : maxlen;
}
#else
-# define p_strnlen strnlen
+# define p_strnlen strnlen
#endif
#ifdef NO_READDIR_R