Index: libcxx/include/__threading_support =================================================================== --- libcxx/include/__threading_support +++ libcxx/include/__threading_support @@ -15,6 +15,10 @@ #include #include +#ifdef __MVS__ +#include +#endif + #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER #pragma GCC system_header #endif @@ -532,7 +536,25 @@ void __libcpp_thread_sleep_for(const chrono::nanoseconds& __ns) { __libcpp_timespec_t __ts = __thread_detail::__convert_to_timespec(__ns); +#if defined(__MVS__) + // The nanosleep() is not available on z/OS. Therefore, + // we will call sleep() to sleep for a whole seconds + // and usleep() to sleep for a fraction of a second. + // Any remaining nano seconds will round up to the next micro second. + + useconds_t __micro_sec = (__ts.tv_nsec + 999) / 1000; + if (__micro_sec > 999999) + { + __ts.tv_sec++; + __micro_sec = 0; + } + while (__ts.tv_sec) + __ts.tv_sec = sleep(__ts.tv_sec); + if (__micro_sec) + usleep(__micro_sec); +#else while (nanosleep(&__ts, &__ts) == -1 && errno == EINTR); +#endif } // Thread local storage Index: libcxx/src/filesystem/filesystem_common.h =================================================================== --- libcxx/src/filesystem/filesystem_common.h +++ libcxx/src/filesystem/filesystem_common.h @@ -382,6 +382,15 @@ #if defined(__APPLE__) TimeSpec extract_mtime(StatT const& st) { return st.st_mtimespec; } TimeSpec extract_atime(StatT const& st) { return st.st_atimespec; } +#elif defined(__MVS__) +TimeSpec extract_mtime(StatT const& st) { + TimeSpec TS = {st.st_mtime, 0}; + return TS; +} +TimeSpec extract_atime(StatT const& st) { + TimeSpec TS = {st.st_atime, 0}; + return TS; +} #else TimeSpec extract_mtime(StatT const& st) { return st.st_mtim; } TimeSpec extract_atime(StatT const& st) { return st.st_atim; } @@ -398,8 +407,14 @@ auto dur = duration_cast(nanoseconds(nsec)).count(); return static_cast(dur); }; +#if defined(__MVS__) + struct ::timeval ConvertedTS[2] = { + {TS[0].tv_sec, {}, Convert(TS[0].tv_nsec)}, + {TS[1].tv_sec, {}, Convert(TS[1].tv_nsec)}}; +#else struct ::timeval ConvertedTS[2] = {{TS[0].tv_sec, Convert(TS[0].tv_nsec)}, {TS[1].tv_sec, Convert(TS[1].tv_nsec)}}; +#endif if (::utimes(p.c_str(), ConvertedTS) == -1) { ec = capture_errno(); return true;