Index: libcxx/include/__config =================================================================== --- libcxx/include/__config +++ libcxx/include/__config @@ -1136,6 +1136,7 @@ defined(__CloudABI__) || \ defined(__sun__) || \ defined(__MVS__) || \ + defined(_AIX) || \ (defined(__MINGW32__) && __has_include()) # define _LIBCPP_HAS_THREAD_API_PTHREAD # elif defined(__Fuchsia__) Index: libcxx/include/__support/ibm/xlocale.h =================================================================== --- libcxx/include/__support/ibm/xlocale.h +++ libcxx/include/__support/ibm/xlocale.h @@ -210,11 +210,13 @@ // strftime_l() is defined by POSIX. However, AIX 7.1 and z/OS do not have it // implemented yet. z/OS retrieves it from the POSIX fallbacks. +#if !defined(_AIX72) static inline size_t strftime_l(char *__s, size_t __size, const char *__fmt, const struct tm *__tm, locale_t locale) { return __xstrftime(locale, __s, __size, __fmt, __tm); } +#endif #elif defined(__MVS__) #include @@ -222,34 +224,72 @@ #include <__support/xlocale/__posix_l_fallback.h> #endif // defined(__MVS__) +namespace { + +struct SetAndRestore { + SetAndRestore(locale_t locale) { + stored = uselocale(locale); + } + ~SetAndRestore() { + uselocale(stored); + } +private: + locale_t stored; +}; + +} + // The following are not POSIX routines. These are quick-and-dirty hacks // to make things pretend to work static inline long long strtoll_l(const char *__nptr, char **__endptr, int __base, locale_t locale) { + SetAndRestore newloc(locale); return strtoll(__nptr, __endptr, __base); } + static inline long strtol_l(const char *__nptr, char **__endptr, int __base, locale_t locale) { + SetAndRestore newloc(locale); return strtol(__nptr, __endptr, __base); } + static inline long double strtold_l(const char *__nptr, char **__endptr, locale_t locale) { + SetAndRestore newloc(locale); return strtold(__nptr, __endptr); } + static inline unsigned long long strtoull_l(const char *__nptr, char **__endptr, int __base, locale_t locale) { + SetAndRestore newloc(locale); return strtoull(__nptr, __endptr, __base); } + static inline unsigned long strtoul_l(const char *__nptr, char **__endptr, int __base, locale_t locale) { + SetAndRestore newloc(locale); return strtoul(__nptr, __endptr, __base); } +static inline +double strtod_l(const char *__nptr, char **__endptr, + locale_t locale) { + SetAndRestore newloc(locale); + return strtod(__nptr, __endptr); +} + +static inline +float strtof_l(const char *__nptr, char **__endptr, + locale_t locale) { + SetAndRestore newloc(locale); + return strtof(__nptr, __endptr); +} + static inline int vasprintf(char **strp, const char *fmt, va_list ap) { Index: libcxx/src/filesystem/filesystem_common.h =================================================================== --- libcxx/src/filesystem/filesystem_common.h +++ libcxx/src/filesystem/filesystem_common.h @@ -453,6 +453,15 @@ TimeSpec TS = {st.st_atime, 0}; return TS; } +#elif defined(_AIX) +inline TimeSpec extract_mtime(StatT const& st) { + TimeSpec TS = {st.st_mtime, st.st_mtime_n}; + return TS; +} +inline TimeSpec extract_atime(StatT const& st) { + TimeSpec TS = {st.st_atime, st.st_atime_n}; + return TS; +} #else inline TimeSpec extract_mtime(StatT const& st) { return st.st_mtim; } inline TimeSpec extract_atime(StatT const& st) { return st.st_atim; }