Merge "libc++: Make string.cpp compile on Android."
diff --git a/sources/cxx-stl/llvm-libc++/include/support/android/wchar.h b/sources/cxx-stl/llvm-libc++/include/support/android/wchar.h
index 8030876..a438d05 100644
--- a/sources/cxx-stl/llvm-libc++/include/support/android/wchar.h
+++ b/sources/cxx-stl/llvm-libc++/include/support/android/wchar.h
@@ -8,9 +8,10 @@
 
 // Add missing declarations that are not in the NDK.
 float               wcstof(const wchar_t*, wchar_t**);
+long                wcstol(const wchar_t* nptr, wchar_t**, int);
 long double         wcstold(const wchar_t*, wchar_t**);
-long long           wcstoll(const wchar_t*, wchar_t**);
-unsigned long long  wcstoull(const wchar_t*, wchar_t**);
+long long           wcstoll(const wchar_t*, wchar_t**, int);
+unsigned long long  wcstoull(const wchar_t*, wchar_t**, int);
 
 extern size_t wcsnrtombs (char *dst,
                           const wchar_t **src,
diff --git a/sources/cxx-stl/llvm-libc++/src/string.cpp b/sources/cxx-stl/llvm-libc++/src/string.cpp
index a21a155..b4449eb 100644
--- a/sources/cxx-stl/llvm-libc++/src/string.cpp
+++ b/sources/cxx-stl/llvm-libc++/src/string.cpp
@@ -26,6 +26,24 @@
     string
     operator+<char, char_traits<char>, allocator<char> >(char const*, string const&);
 
+#ifdef __ANDROID__
+
+namespace {
+
+// Private helper function used in place of std::swap() to handle the case
+// where errno is declared as a volatile int (making std::swap inappropriate
+// since its two parameters have different types, volatile int vs int).
+template <typename A, typename B>
+inline _LIBCPP_INLINE_VISIBILITY void swap(A& a, B& b) {
+  A a_copy = a;
+  a = b;
+  b = a_copy;
+}
+
+}  // namespace
+
+#endif  // __ANDROID__
+
 int
 stoi(const string& str, size_t* idx, int base)
 {