Get libc++ building for Android
This adds an Android makefile, aliases locale aware cctype and cwctype
functions, fixes broken configuration in libcxx, and stubs functions missing
from bionic.
Change-Id: I247372d87caabe0310bedc4540b68ab2ed1986c1
diff --git a/include/support/android/langinfo.h b/include/support/android/langinfo.h
new file mode 100644
index 0000000..c706c5d
--- /dev/null
+++ b/include/support/android/langinfo.h
@@ -0,0 +1,104 @@
+// -*- C++ -*-
+//===--------------------- support/android/langinfo.h ---------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+#ifndef _LIBCPP_SUPPORT_ANDROID_LANGINFO_H_
+#define _LIBCPP_SUPPORT_ANDROID_LANGINFO_H_
+
+#ifdef __ANDROID__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <support/android/nl_types.h>
+
+#define _NL_ITEM(category,index) (((category) << 10) | (index))
+
+#define _NL_ITEM_CATEGORY(nl) ((nl) >> 10)
+#define _NL_ITEM_INDEX(nl) ((nl) & 0x3ff)
+
+#define CODESET _NL_ITEM(LC_CTYPE, 0)
+
+/* Abbreviated days of the week */
+#define ABDAY_1 _NL_ITEM(LC_TIME,1)
+#define ABDAY_2 _NL_ITEM(LC_TIME,2)
+#define ABDAY_3 _NL_ITEM(LC_TIME,3)
+#define ABDAY_4 _NL_ITEM(LC_TIME,4)
+#define ABDAY_5 _NL_ITEM(LC_TIME,5)
+#define ABDAY_6 _NL_ITEM(LC_TIME,6)
+#define ABDAY_7 _NL_ITEM(LC_TIME,7)
+
+/* Long names of the week */
+#define DAY_1 _NL_ITEM(LC_TIME,11)
+#define DAY_2 _NL_ITEM(LC_TIME,12)
+#define DAY_3 _NL_ITEM(LC_TIME,13)
+#define DAY_4 _NL_ITEM(LC_TIME,14)
+#define DAY_5 _NL_ITEM(LC_TIME,15)
+#define DAY_6 _NL_ITEM(LC_TIME,16)
+#define DAY_7 _NL_ITEM(LC_TIME,17)
+
+/* Abbreviated month names */
+#define ABMON_1 _NL_ITEM(LC_TIME,21)
+#define ABMON_2 _NL_ITEM(LC_TIME,22)
+#define ABMON_3 _NL_ITEM(LC_TIME,23)
+#define ABMON_4 _NL_ITEM(LC_TIME,24)
+#define ABMON_5 _NL_ITEM(LC_TIME,25)
+#define ABMON_6 _NL_ITEM(LC_TIME,26)
+#define ABMON_7 _NL_ITEM(LC_TIME,27)
+#define ABMON_8 _NL_ITEM(LC_TIME,28)
+#define ABMON_9 _NL_ITEM(LC_TIME,29)
+#define ABMON_10 _NL_ITEM(LC_TIME,30)
+#define ABMON_11 _NL_ITEM(LC_TIME,31)
+#define ABMON_12 _NL_ITEM(LC_TIME,32)
+
+/* Long month names */
+#define MON_1 _NL_ITEM(LC_TIME,41)
+#define MON_2 _NL_ITEM(LC_TIME,42)
+#define MON_3 _NL_ITEM(LC_TIME,43)
+#define MON_4 _NL_ITEM(LC_TIME,44)
+#define MON_5 _NL_ITEM(LC_TIME,45)
+#define MON_6 _NL_ITEM(LC_TIME,46)
+#define MON_7 _NL_ITEM(LC_TIME,47)
+#define MON_8 _NL_ITEM(LC_TIME,48)
+#define MON_9 _NL_ITEM(LC_TIME,49)
+#define MON_10 _NL_ITEM(LC_TIME,50)
+#define MON_11 _NL_ITEM(LC_TIME,51)
+#define MON_12 _NL_ITEM(LC_TIME,52)
+
+#define AM_STR _NL_ITEM(LC_TIME,53)
+#define PM_STR _NL_ITEM(LC_TIME,54)
+#define D_T_FMT _NL_ITEM(LC_TIME,55)
+#define D_FMT _NL_ITEM(LC_TIME,56)
+#define T_FMT _NL_ITEM(LC_TIME,57)
+#define T_FMT_AMPM _NL_ITEM(LC_TIME,58)
+#define ERA _NL_ITEM(LC_TIME,59)
+#define ERA_D_FMT _NL_ITEM(LC_TIME,60)
+#define ERA_D_T_FMT _NL_ITEM(LC_TIME,61)
+#define ERA_T_FMT _NL_ITEM(LC_TIME,62)
+#define ALT_DIGITS _NL_ITEM(LC_TIME,70)
+
+#define INT_CURRENCY_SYMBOL _NL_ITEM(LC_MONETARY,0)
+#define CURRENCY_SYMBOL _NL_ITEM(LC_MONETARY,1)
+#define MON_DECIMAL_POINT _NL_ITEM(LC_MONETARY,2)
+#define MON_THOUSANDS_SEP _NL_ITEM(LC_MONETARY,3)
+#define MON_GROUPING _NL_ITEM(LC_MONETARY,4)
+#define POSITIVE_SIGN _NL_ITEM(LC_MONETARY,5)
+#define NEGATIVE_SIGN _NL_ITEM(LC_MONETARY,6)
+#define INT_FRAC_DIGITS _NL_ITEM(LC_MONETARY,7)
+#define FRAC_DIGITS _NL_ITEM(LC_MONETARY,8)
+
+char *nl_langinfo(nl_item);
+char *nl_langinfo_l(nl_item, locale_t);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // __ANDROID__
+#endif /* _LIBCPP_SUPPORT_ANDROID_LANGINFO_H_ */
diff --git a/include/support/android/locale_bionic.h b/include/support/android/locale_bionic.h
new file mode 100644
index 0000000..fa15b16
--- /dev/null
+++ b/include/support/android/locale_bionic.h
@@ -0,0 +1,68 @@
+// -*- C++ -*-
+//===------------------- support/android/locale_bionic.h ------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_SUPPORT_ANDROID_LOCALE_BIONIC_H
+#define _LIBCPP_SUPPORT_ANDROID_LOCALE_BIONIC_H
+
+#if defined(__ANDROID__)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <xlocale.h>
+
+#define isalnum_l(c, locale) isalnum(c)
+#define isalpha_l(c, locale) isalpha(c)
+#define isascii_l(c, locale) isascii(c)
+#define isblank_l(c, locale) isblank(c)
+#define iscntrl_l(c, locale) iscntrl(c)
+#define isdigit_l(c, locale) isdigit(c)
+#define isgraph_l(c, locale) isgraph(c)
+#define islower_l(c, locale) islower(c)
+#define isprint_l(c, locale) isprint(c)
+#define ispunct_l(c, locale) ispunct(c)
+#define isspace_l(c, locale) isspace(c)
+#define isupper_l(c, locale) isupper(c)
+#define isxdigit_l(c, locale) isxdigit(c)
+#define iswalnum_l(c, locale) iswalnum(c)
+#define iswalpha_l(c, locale) iswalpha(c)
+#define iswascii_l(c, locale) iswascii(c)
+#define iswblank_l(c, locale) iswblank(c)
+#define iswcntrl_l(c, locale) iswcntrl(c)
+#define iswdigit_l(c, locale) iswdigit(c)
+#define iswgraph_l(c, locale) iswgraph(c)
+#define iswlower_l(c, locale) iswlower(c)
+#define iswprint_l(c, locale) iswprint(c)
+#define iswpunct_l(c, locale) iswpunct(c)
+#define iswspace_l(c, locale) iswspace(c)
+#define iswupper_l(c, locale) iswupper(c)
+#define iswxdigit_l(c, locale) iswxdigit(c)
+#define toupper_l(c, locale) toupper(c)
+#define tolower_l(c, locale) tolower(c)
+#define towupper_l(c, locale) towupper(c)
+#define towlower_l(c, locale) towlower(c)
+#define strcoll_l(s1, s2, locale) strcoll(s1, s2)
+#define strxfrm_l(dest, src, n, locale) strxfrm(dest, src, n)
+#define strftime_l(s, max, format, tm, locale) strftime(s, max, format, tm)
+#define wcscoll_l(s1, s2, locale) wcscoll(s1, s2)
+#define wcsxfrm_l(dest, src, n, locale) wcsxfrm(dest, src, n)
+#define strtold_l(nptr, endptr, locale) strtold(nptr, endptr)
+#define strtoll_l(nptr, endptr, base, locale) strtoll(nptr, endptr, base)
+#define strtoull_l(nptr, endptr, base, locale) strtoull(nptr, endptr, base)
+#define wcstoll_l(nptr, endptr, locale) wcstoll(nptr, endptr)
+#define wcstoull_l(nptr, endptr, locale) wcstoull(nptr, endptr)
+#define wcstold_l(nptr, endptr, locale) wcstold(nptr, endptr)
+
+#ifdef __cplusplus
+}
+#endif
+#endif // defined(__ANDROID__)
+#endif // _LIBCPP_SUPPORT_ANDROID_LOCALE_BIONIC_H
diff --git a/include/support/android/nl_types.h b/include/support/android/nl_types.h
new file mode 100644
index 0000000..e1eb63f
--- /dev/null
+++ b/include/support/android/nl_types.h
@@ -0,0 +1,34 @@
+// -*- C++ -*-
+//===--------------------- support/android/nl_types.h ---------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+#ifndef _LIBCPP_SUPPORT_ANDROID_NL_TYPES_H
+#define _LIBCPP_SUPPORT_ANDROID_NL_TYPES_H
+
+#ifdef __ANDROID__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define NL_SETD 1
+#define NL_CAT_LOCALE 1
+
+typedef void *nl_catd;
+typedef int nl_item;
+
+nl_catd catopen(const char *, int);
+int catclose(nl_catd);
+char *catgets(nl_catd, int, int, const char *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // __ANDROID__
+#endif // _LIBCPP_SUPPORT_ANDROID_NL_TYPES_H
diff --git a/include/support/android/wchar_bionic.h b/include/support/android/wchar_bionic.h
new file mode 100644
index 0000000..91985e4
--- /dev/null
+++ b/include/support/android/wchar_bionic.h
@@ -0,0 +1,36 @@
+// -*- C++ -*-
+//===------------------- support/android/wchar_bionic.h -------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_SUPPORT_ANDROID_WCHAR_BIONIC_H
+#define _LIBCPP_SUPPORT_ANDROID_WCHAR_BIONIC_H
+
+#ifdef __ANDROID__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int vfwscanf(FILE *, const wchar_t *, va_list);
+int vswscanf(const wchar_t *, const wchar_t *, va_list);
+int vwscanf(const wchar_t *, va_list);
+float wcstof(const wchar_t *, wchar_t **);
+double wcstod(const wchar_t *, wchar_t **);
+long double wcstold(const wchar_t *, wchar_t **);
+long long wcstoll(const wchar_t *, wchar_t **, int);
+unsigned long long wcstoull(const wchar_t *, wchar_t **, int);
+size_t wcsnrtombs(char *, const wchar_t **, size_t, size_t, mbstate_t *);
+size_t mbsnrtowcs(wchar_t *, const char **, size_t, size_t, mbstate_t *);
+int mbtowc(wchar_t *, const char *, size_t);
+
+#ifdef __cplusplus
+}
+#endif
+#endif // __ANDROID__
+#endif // _LIBCPP_SUPPORT_ANDROID_WCHAR_BIONIC_H