Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 29 additions & 11 deletions libcxx/include/__locale_dir/locale_base_api/ibm.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,37 @@
# include <__support/xlocale/__posix_l_fallback.h>
#endif // defined(__MVS__)

_LIBCPP_BEGIN_NAMESPACE_STD
#ifdef __MVS__
# define _LIBCPP_CLOC std::__c_locale()
# ifndef _LIBCPP_LC_GLOBAL_LOCALE
# define _LIBCPP_LC_GLOBAL_LOCALE ((locale_t) -1)
# endif
#else
extern locale_t __cloc();
# define _LIBCPP_CLOC std::__cloc()
#endif
_LIBCPP_END_NAMESPACE_STD

#ifdef __MVS__
_LIBCPP_BEGIN_NAMESPACE_STD
#endif

namespace {

struct __setAndRestore {
explicit __setAndRestore(locale_t locale) {
if (locale == (locale_t)0) {
__cloc = newlocale(LC_ALL_MASK, "C", /* base */ (locale_t)0);
__stored = uselocale(__cloc);
explicit __setAndRestore(locale_t __l) {
if (__l == (locale_t)0) {
__stored = std::uselocale(_LIBCPP_CLOC);
} else {
__stored = uselocale(locale);
__stored = std::uselocale(__l);
}
}

~__setAndRestore() {
uselocale(__stored);
if (__cloc)
freelocale(__cloc);
}
~__setAndRestore() { std::uselocale(__stored); }

private:
locale_t __stored = (locale_t)0;
locale_t __cloc = (locale_t)0;
};

} // namespace
Expand Down Expand Up @@ -89,7 +99,11 @@ _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 2, 0) int vasprintf(char** strp, const char
va_list ap_copy;
// va_copy may not be provided by the C library in C++03 mode.
#if defined(_LIBCPP_CXX03_LANG) && __has_builtin(__builtin_va_copy)
# if defined(__MVS__) && !defined(_VARARG_EXT_)
__builtin_zos_va_copy(ap_copy, ap);
# else
__builtin_va_copy(ap_copy, ap);
# endif
#else
va_copy(ap_copy, ap);
#endif
Expand All @@ -105,4 +119,8 @@ _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 2, 0) int vasprintf(char** strp, const char
return str_size;
}

#ifdef __MVS__
_LIBCPP_END_NAMESPACE_STD
#endif

#endif // _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_IBM_H
8 changes: 7 additions & 1 deletion libcxx/include/__thread/support/pthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,15 @@ inline _LIBCPP_HIDE_FROM_ABI int __libcpp_thread_detach(__libcpp_thread_t* __t)
inline _LIBCPP_HIDE_FROM_ABI void __libcpp_thread_yield() { sched_yield(); }

inline _LIBCPP_HIDE_FROM_ABI void __libcpp_thread_sleep_for(const chrono::nanoseconds& __ns) {
#ifdef __MVS__
# define __LIBCPP_NS __ibm::
#else
# define __LIBCPP_NS
#endif
__libcpp_timespec_t __ts = std::__convert_to_timespec<__libcpp_timespec_t>(__ns);
while (nanosleep(&__ts, &__ts) == -1 && errno == EINTR)
while (__LIBCPP_NS nanosleep(&__ts, &__ts) == -1 && errno == EINTR)
;
#undef __LIBCPP_NS
}

//
Expand Down
Loading
Loading