aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/cxxsupp/libcxx/include/__support/ibm
diff options
context:
space:
mode:
authorAndrey Khalyavin <halyavin@gmail.com>2022-02-10 16:46:29 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:29 +0300
commitf773626848a7c7456803654292e716b83d69cc12 (patch)
treedb052dfcf9134f492bdbb962cb6c16cea58e1ed3 /contrib/libs/cxxsupp/libcxx/include/__support/ibm
parentf43ab775d197d300eb67bd4497632b909cd7c2a5 (diff)
downloadydb-f773626848a7c7456803654292e716b83d69cc12.tar.gz
Restoring authorship annotation for Andrey Khalyavin <halyavin@gmail.com>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/include/__support/ibm')
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__support/ibm/gettod_zos.h106
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__support/ibm/limits.h190
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__support/ibm/locale_mgmt_zos.h106
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__support/ibm/nanosleep.h112
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__support/ibm/support.h100
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__support/ibm/xlocale.h258
6 files changed, 436 insertions, 436 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/include/__support/ibm/gettod_zos.h b/contrib/libs/cxxsupp/libcxx/include/__support/ibm/gettod_zos.h
index 46e02a6c8b..f4f70d5aae 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__support/ibm/gettod_zos.h
+++ b/contrib/libs/cxxsupp/libcxx/include/__support/ibm/gettod_zos.h
@@ -1,53 +1,53 @@
-// -*- C++ -*-
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef _LIBCPP_SUPPORT_IBM_GETTOD_ZOS_H
-#define _LIBCPP_SUPPORT_IBM_GETTOD_ZOS_H
-
-#include <time.h>
-
-static inline int gettimeofdayMonotonic(struct timespec64* Output) {
-
- // The POSIX gettimeofday() function is not available on z/OS. Therefore,
- // we will call stcke and other hardware instructions in implement equivalent.
- // Note that nanoseconds alone will overflow when reaching new epoch in 2042.
-
- struct _t {
- uint64_t Hi;
- uint64_t Lo;
- };
- struct _t Value = {0, 0};
- uint64_t CC = 0;
- asm(" stcke %0\n"
- " ipm %1\n"
- " srlg %1,%1,28\n"
- : "=m"(Value), "+r"(CC)::);
-
- if (CC != 0) {
- errno = EMVSTODNOTSET;
- return CC;
- }
- uint64_t us = (Value.Hi >> 4);
- uint64_t ns = ((Value.Hi & 0x0F) << 8) + (Value.Lo >> 56);
- ns = (ns * 1000) >> 12;
- us = us - 2208988800000000;
-
- register uint64_t DivPair0 asm("r0"); // dividend (upper half), remainder
- DivPair0 = 0;
- register uint64_t DivPair1 asm("r1"); // dividend (lower half), quotient
- DivPair1 = us;
- uint64_t Divisor = 1000000;
- asm(" dlgr %0,%2" : "+r"(DivPair0), "+r"(DivPair1) : "r"(Divisor) :);
-
- Output->tv_sec = DivPair1;
- Output->tv_nsec = DivPair0 * 1000 + ns;
- return 0;
-}
-
-#endif // _LIBCPP_SUPPORT_IBM_GETTOD_ZOS_H
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_SUPPORT_IBM_GETTOD_ZOS_H
+#define _LIBCPP_SUPPORT_IBM_GETTOD_ZOS_H
+
+#include <time.h>
+
+static inline int gettimeofdayMonotonic(struct timespec64* Output) {
+
+ // The POSIX gettimeofday() function is not available on z/OS. Therefore,
+ // we will call stcke and other hardware instructions in implement equivalent.
+ // Note that nanoseconds alone will overflow when reaching new epoch in 2042.
+
+ struct _t {
+ uint64_t Hi;
+ uint64_t Lo;
+ };
+ struct _t Value = {0, 0};
+ uint64_t CC = 0;
+ asm(" stcke %0\n"
+ " ipm %1\n"
+ " srlg %1,%1,28\n"
+ : "=m"(Value), "+r"(CC)::);
+
+ if (CC != 0) {
+ errno = EMVSTODNOTSET;
+ return CC;
+ }
+ uint64_t us = (Value.Hi >> 4);
+ uint64_t ns = ((Value.Hi & 0x0F) << 8) + (Value.Lo >> 56);
+ ns = (ns * 1000) >> 12;
+ us = us - 2208988800000000;
+
+ register uint64_t DivPair0 asm("r0"); // dividend (upper half), remainder
+ DivPair0 = 0;
+ register uint64_t DivPair1 asm("r1"); // dividend (lower half), quotient
+ DivPair1 = us;
+ uint64_t Divisor = 1000000;
+ asm(" dlgr %0,%2" : "+r"(DivPair0), "+r"(DivPair1) : "r"(Divisor) :);
+
+ Output->tv_sec = DivPair1;
+ Output->tv_nsec = DivPair0 * 1000 + ns;
+ return 0;
+}
+
+#endif // _LIBCPP_SUPPORT_IBM_GETTOD_ZOS_H
diff --git a/contrib/libs/cxxsupp/libcxx/include/__support/ibm/limits.h b/contrib/libs/cxxsupp/libcxx/include/__support/ibm/limits.h
index 45f1f1e368..3ef86e164b 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__support/ibm/limits.h
+++ b/contrib/libs/cxxsupp/libcxx/include/__support/ibm/limits.h
@@ -1,98 +1,98 @@
-// -*- C++ -*-
-//===-----------------------------------------------------------------------===//
-//
+// -*- C++ -*-
+//===-----------------------------------------------------------------------===//
+//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef _LIBCPP_SUPPORT_IBM_LIMITS_H
-#define _LIBCPP_SUPPORT_IBM_LIMITS_H
-
-#if !defined(_AIX) // Linux
-#include <math.h> // for HUGE_VAL, HUGE_VALF, HUGE_VALL, and NAN
-
-static const unsigned int _QNAN_F = 0x7fc00000;
-#define NANF (*((float *)(&_QNAN_F)))
-static const unsigned int _QNAN_LDBL128[4] = {0x7ff80000, 0x0, 0x0, 0x0};
-#define NANL (*((long double *)(&_QNAN_LDBL128)))
-static const unsigned int _SNAN_F= 0x7f855555;
-#define NANSF (*((float *)(&_SNAN_F)))
-static const unsigned int _SNAN_D[2] = {0x7ff55555, 0x55555555};
-#define NANS (*((double *)(&_SNAN_D)))
-static const unsigned int _SNAN_LDBL128[4] = {0x7ff55555, 0x55555555, 0x0, 0x0};
-#define NANSL (*((long double *)(&_SNAN_LDBL128)))
-
-#define __builtin_huge_val() HUGE_VAL
-#define __builtin_huge_valf() HUGE_VALF
-#define __builtin_huge_vall() HUGE_VALL
-#define __builtin_nan(__dummy) NAN
-#define __builtin_nanf(__dummy) NANF
-#define __builtin_nanl(__dummy) NANL
-#define __builtin_nans(__dummy) NANS
-#define __builtin_nansf(__dummy) NANSF
-#define __builtin_nansl(__dummy) NANSL
-
-#else
-
-#include <math.h>
-#include <float.h> // limit constants
-
-#define __builtin_huge_val() HUGE_VAL //0x7ff0000000000000
-#define __builtin_huge_valf() HUGE_VALF //0x7f800000
-#define __builtin_huge_vall() HUGE_VALL //0x7ff0000000000000
-#define __builtin_nan(__dummy) nan(__dummy) //0x7ff8000000000000
-#define __builtin_nanf(__dummy) nanf(__dummy) // 0x7ff80000
-#define __builtin_nanl(__dummy) nanl(__dummy) //0x7ff8000000000000
-#define __builtin_nans(__dummy) DBL_SNAN //0x7ff5555555555555
-#define __builtin_nansf(__dummy) FLT_SNAN //0x7f855555
-#define __builtin_nansl(__dummy) DBL_SNAN //0x7ff5555555555555
-
-#define __FLT_MANT_DIG__ FLT_MANT_DIG
-#define __FLT_DIG__ FLT_DIG
-#define __FLT_RADIX__ FLT_RADIX
-#define __FLT_MIN_EXP__ FLT_MIN_EXP
-#define __FLT_MIN_10_EXP__ FLT_MIN_10_EXP
-#define __FLT_MAX_EXP__ FLT_MAX_EXP
-#define __FLT_MAX_10_EXP__ FLT_MAX_10_EXP
-#define __FLT_MIN__ FLT_MIN
-#define __FLT_MAX__ FLT_MAX
-#define __FLT_EPSILON__ FLT_EPSILON
-// predefined by XLC on LoP
-#define __FLT_DENORM_MIN__ 1.40129846e-45F
-
-#define __DBL_MANT_DIG__ DBL_MANT_DIG
-#define __DBL_DIG__ DBL_DIG
-#define __DBL_MIN_EXP__ DBL_MIN_EXP
-#define __DBL_MIN_10_EXP__ DBL_MIN_10_EXP
-#define __DBL_MAX_EXP__ DBL_MAX_EXP
-#define __DBL_MAX_10_EXP__ DBL_MAX_10_EXP
-#define __DBL_MIN__ DBL_MIN
-#define __DBL_MAX__ DBL_MAX
-#define __DBL_EPSILON__ DBL_EPSILON
-// predefined by XLC on LoP
-#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
-
-#define __LDBL_MANT_DIG__ LDBL_MANT_DIG
-#define __LDBL_DIG__ LDBL_DIG
-#define __LDBL_MIN_EXP__ LDBL_MIN_EXP
-#define __LDBL_MIN_10_EXP__ LDBL_MIN_10_EXP
-#define __LDBL_MAX_EXP__ LDBL_MAX_EXP
-#define __LDBL_MAX_10_EXP__ LDBL_MAX_10_EXP
-#define __LDBL_MIN__ LDBL_MIN
-#define __LDBL_MAX__ LDBL_MAX
-#define __LDBL_EPSILON__ LDBL_EPSILON
-// predefined by XLC on LoP
-#if __LONGDOUBLE128
-#define __LDBL_DENORM_MIN__ 4.94065645841246544176568792868221e-324L
-#else
-#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L
-#endif
-
-// predefined by XLC on LoP
-#define __CHAR_BIT__ 8
-
-#endif // _AIX
-
-#endif // _LIBCPP_SUPPORT_IBM_LIMITS_H
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_SUPPORT_IBM_LIMITS_H
+#define _LIBCPP_SUPPORT_IBM_LIMITS_H
+
+#if !defined(_AIX) // Linux
+#include <math.h> // for HUGE_VAL, HUGE_VALF, HUGE_VALL, and NAN
+
+static const unsigned int _QNAN_F = 0x7fc00000;
+#define NANF (*((float *)(&_QNAN_F)))
+static const unsigned int _QNAN_LDBL128[4] = {0x7ff80000, 0x0, 0x0, 0x0};
+#define NANL (*((long double *)(&_QNAN_LDBL128)))
+static const unsigned int _SNAN_F= 0x7f855555;
+#define NANSF (*((float *)(&_SNAN_F)))
+static const unsigned int _SNAN_D[2] = {0x7ff55555, 0x55555555};
+#define NANS (*((double *)(&_SNAN_D)))
+static const unsigned int _SNAN_LDBL128[4] = {0x7ff55555, 0x55555555, 0x0, 0x0};
+#define NANSL (*((long double *)(&_SNAN_LDBL128)))
+
+#define __builtin_huge_val() HUGE_VAL
+#define __builtin_huge_valf() HUGE_VALF
+#define __builtin_huge_vall() HUGE_VALL
+#define __builtin_nan(__dummy) NAN
+#define __builtin_nanf(__dummy) NANF
+#define __builtin_nanl(__dummy) NANL
+#define __builtin_nans(__dummy) NANS
+#define __builtin_nansf(__dummy) NANSF
+#define __builtin_nansl(__dummy) NANSL
+
+#else
+
+#include <math.h>
+#include <float.h> // limit constants
+
+#define __builtin_huge_val() HUGE_VAL //0x7ff0000000000000
+#define __builtin_huge_valf() HUGE_VALF //0x7f800000
+#define __builtin_huge_vall() HUGE_VALL //0x7ff0000000000000
+#define __builtin_nan(__dummy) nan(__dummy) //0x7ff8000000000000
+#define __builtin_nanf(__dummy) nanf(__dummy) // 0x7ff80000
+#define __builtin_nanl(__dummy) nanl(__dummy) //0x7ff8000000000000
+#define __builtin_nans(__dummy) DBL_SNAN //0x7ff5555555555555
+#define __builtin_nansf(__dummy) FLT_SNAN //0x7f855555
+#define __builtin_nansl(__dummy) DBL_SNAN //0x7ff5555555555555
+
+#define __FLT_MANT_DIG__ FLT_MANT_DIG
+#define __FLT_DIG__ FLT_DIG
+#define __FLT_RADIX__ FLT_RADIX
+#define __FLT_MIN_EXP__ FLT_MIN_EXP
+#define __FLT_MIN_10_EXP__ FLT_MIN_10_EXP
+#define __FLT_MAX_EXP__ FLT_MAX_EXP
+#define __FLT_MAX_10_EXP__ FLT_MAX_10_EXP
+#define __FLT_MIN__ FLT_MIN
+#define __FLT_MAX__ FLT_MAX
+#define __FLT_EPSILON__ FLT_EPSILON
+// predefined by XLC on LoP
+#define __FLT_DENORM_MIN__ 1.40129846e-45F
+
+#define __DBL_MANT_DIG__ DBL_MANT_DIG
+#define __DBL_DIG__ DBL_DIG
+#define __DBL_MIN_EXP__ DBL_MIN_EXP
+#define __DBL_MIN_10_EXP__ DBL_MIN_10_EXP
+#define __DBL_MAX_EXP__ DBL_MAX_EXP
+#define __DBL_MAX_10_EXP__ DBL_MAX_10_EXP
+#define __DBL_MIN__ DBL_MIN
+#define __DBL_MAX__ DBL_MAX
+#define __DBL_EPSILON__ DBL_EPSILON
+// predefined by XLC on LoP
+#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
+
+#define __LDBL_MANT_DIG__ LDBL_MANT_DIG
+#define __LDBL_DIG__ LDBL_DIG
+#define __LDBL_MIN_EXP__ LDBL_MIN_EXP
+#define __LDBL_MIN_10_EXP__ LDBL_MIN_10_EXP
+#define __LDBL_MAX_EXP__ LDBL_MAX_EXP
+#define __LDBL_MAX_10_EXP__ LDBL_MAX_10_EXP
+#define __LDBL_MIN__ LDBL_MIN
+#define __LDBL_MAX__ LDBL_MAX
+#define __LDBL_EPSILON__ LDBL_EPSILON
+// predefined by XLC on LoP
+#if __LONGDOUBLE128
+#define __LDBL_DENORM_MIN__ 4.94065645841246544176568792868221e-324L
+#else
+#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L
+#endif
+
+// predefined by XLC on LoP
+#define __CHAR_BIT__ 8
+
+#endif // _AIX
+
+#endif // _LIBCPP_SUPPORT_IBM_LIMITS_H
diff --git a/contrib/libs/cxxsupp/libcxx/include/__support/ibm/locale_mgmt_zos.h b/contrib/libs/cxxsupp/libcxx/include/__support/ibm/locale_mgmt_zos.h
index 90ad2c2c86..6e13874043 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__support/ibm/locale_mgmt_zos.h
+++ b/contrib/libs/cxxsupp/libcxx/include/__support/ibm/locale_mgmt_zos.h
@@ -1,53 +1,53 @@
-// -*- C++ -*-
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef _LIBCPP_SUPPORT_IBM_LOCALE_MGMT_ZOS_H
-#define _LIBCPP_SUPPORT_IBM_LOCALE_MGMT_ZOS_H
-
-#if defined(__MVS__)
-#include <locale.h>
-#include <string>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define _LC_MAX LC_MESSAGES /* highest real category */
-#define _NCAT (_LC_MAX + 1) /* maximum + 1 */
-
-#define _CATMASK(n) (1 << (n))
-#define LC_COLLATE_MASK _CATMASK(LC_COLLATE)
-#define LC_CTYPE_MASK _CATMASK(LC_CTYPE)
-#define LC_MONETARY_MASK _CATMASK(LC_MONETARY)
-#define LC_NUMERIC_MASK _CATMASK(LC_NUMERIC)
-#define LC_TIME_MASK _CATMASK(LC_TIME)
-#define LC_MESSAGES_MASK _CATMASK(LC_MESSAGES)
-#define LC_ALL_MASK (_CATMASK(_NCAT) - 1)
-
-typedef struct locale_struct {
- int category_mask;
- std::string lc_collate;
- std::string lc_ctype;
- std::string lc_monetary;
- std::string lc_numeric;
- std::string lc_time;
- std::string lc_messages;
-} * locale_t;
-
-// z/OS does not have newlocale, freelocale and uselocale.
-// The functions below are workarounds in single thread mode.
-locale_t newlocale(int category_mask, const char* locale, locale_t base);
-void freelocale(locale_t locobj);
-locale_t uselocale(locale_t newloc);
-
-#ifdef __cplusplus
-}
-#endif
-#endif // defined(__MVS__)
-#endif // _LIBCPP_SUPPORT_IBM_LOCALE_MGMT_ZOS_H
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_SUPPORT_IBM_LOCALE_MGMT_ZOS_H
+#define _LIBCPP_SUPPORT_IBM_LOCALE_MGMT_ZOS_H
+
+#if defined(__MVS__)
+#include <locale.h>
+#include <string>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define _LC_MAX LC_MESSAGES /* highest real category */
+#define _NCAT (_LC_MAX + 1) /* maximum + 1 */
+
+#define _CATMASK(n) (1 << (n))
+#define LC_COLLATE_MASK _CATMASK(LC_COLLATE)
+#define LC_CTYPE_MASK _CATMASK(LC_CTYPE)
+#define LC_MONETARY_MASK _CATMASK(LC_MONETARY)
+#define LC_NUMERIC_MASK _CATMASK(LC_NUMERIC)
+#define LC_TIME_MASK _CATMASK(LC_TIME)
+#define LC_MESSAGES_MASK _CATMASK(LC_MESSAGES)
+#define LC_ALL_MASK (_CATMASK(_NCAT) - 1)
+
+typedef struct locale_struct {
+ int category_mask;
+ std::string lc_collate;
+ std::string lc_ctype;
+ std::string lc_monetary;
+ std::string lc_numeric;
+ std::string lc_time;
+ std::string lc_messages;
+} * locale_t;
+
+// z/OS does not have newlocale, freelocale and uselocale.
+// The functions below are workarounds in single thread mode.
+locale_t newlocale(int category_mask, const char* locale, locale_t base);
+void freelocale(locale_t locobj);
+locale_t uselocale(locale_t newloc);
+
+#ifdef __cplusplus
+}
+#endif
+#endif // defined(__MVS__)
+#endif // _LIBCPP_SUPPORT_IBM_LOCALE_MGMT_ZOS_H
diff --git a/contrib/libs/cxxsupp/libcxx/include/__support/ibm/nanosleep.h b/contrib/libs/cxxsupp/libcxx/include/__support/ibm/nanosleep.h
index 6ebcecc68a..d536290686 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__support/ibm/nanosleep.h
+++ b/contrib/libs/cxxsupp/libcxx/include/__support/ibm/nanosleep.h
@@ -1,56 +1,56 @@
-// -*- C++ -*-
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef _LIBCPP_SUPPORT_IBM_NANOSLEEP_H
-#define _LIBCPP_SUPPORT_IBM_NANOSLEEP_H
-
-#include <unistd.h>
-
-inline int nanosleep(const struct timespec* __req, struct timespec* __rem) {
- // The nanosleep() function is not available on z/OS. Therefore, we will call
- // sleep() to sleep for whole seconds and usleep() to sleep for any remaining
- // fraction of a second. Any remaining nanoseconds will round up to the next
- // microsecond.
- if (__req->tv_sec < 0 || __req->tv_nsec < 0 || __req->tv_nsec > 999999999) {
- errno = EINVAL;
- return -1;
- }
- useconds_t __micro_sec =
- static_cast<useconds_t>((__req->tv_nsec + 999) / 1000);
- time_t __sec = __req->tv_sec;
- if (__micro_sec > 999999) {
- ++__sec;
- __micro_sec -= 1000000;
- }
- __sec = sleep(static_cast<unsigned int>(__sec));
- if (__sec) {
- if (__rem) {
- // Updating the remaining time to sleep in case of unsuccessful call to sleep().
- __rem->tv_sec = __sec;
- __rem->tv_nsec = __micro_sec * 1000;
- }
- errno = EINTR;
- return -1;
- }
- if (__micro_sec) {
- int __rt = usleep(__micro_sec);
- if (__rt != 0 && __rem) {
- // The usleep() does not provide the amount of remaining time upon its failure,
- // so the time slept will be ignored.
- __rem->tv_sec = 0;
- __rem->tv_nsec = __micro_sec * 1000;
- // The errno is already set.
- return -1;
- }
- return __rt;
- }
- return 0;
-}
-
-#endif // _LIBCPP_SUPPORT_IBM_NANOSLEEP_H
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_SUPPORT_IBM_NANOSLEEP_H
+#define _LIBCPP_SUPPORT_IBM_NANOSLEEP_H
+
+#include <unistd.h>
+
+inline int nanosleep(const struct timespec* __req, struct timespec* __rem) {
+ // The nanosleep() function is not available on z/OS. Therefore, we will call
+ // sleep() to sleep for whole seconds and usleep() to sleep for any remaining
+ // fraction of a second. Any remaining nanoseconds will round up to the next
+ // microsecond.
+ if (__req->tv_sec < 0 || __req->tv_nsec < 0 || __req->tv_nsec > 999999999) {
+ errno = EINVAL;
+ return -1;
+ }
+ useconds_t __micro_sec =
+ static_cast<useconds_t>((__req->tv_nsec + 999) / 1000);
+ time_t __sec = __req->tv_sec;
+ if (__micro_sec > 999999) {
+ ++__sec;
+ __micro_sec -= 1000000;
+ }
+ __sec = sleep(static_cast<unsigned int>(__sec));
+ if (__sec) {
+ if (__rem) {
+ // Updating the remaining time to sleep in case of unsuccessful call to sleep().
+ __rem->tv_sec = __sec;
+ __rem->tv_nsec = __micro_sec * 1000;
+ }
+ errno = EINTR;
+ return -1;
+ }
+ if (__micro_sec) {
+ int __rt = usleep(__micro_sec);
+ if (__rt != 0 && __rem) {
+ // The usleep() does not provide the amount of remaining time upon its failure,
+ // so the time slept will be ignored.
+ __rem->tv_sec = 0;
+ __rem->tv_nsec = __micro_sec * 1000;
+ // The errno is already set.
+ return -1;
+ }
+ return __rt;
+ }
+ return 0;
+}
+
+#endif // _LIBCPP_SUPPORT_IBM_NANOSLEEP_H
diff --git a/contrib/libs/cxxsupp/libcxx/include/__support/ibm/support.h b/contrib/libs/cxxsupp/libcxx/include/__support/ibm/support.h
index a7751b0176..cfa8bf91fd 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__support/ibm/support.h
+++ b/contrib/libs/cxxsupp/libcxx/include/__support/ibm/support.h
@@ -1,53 +1,53 @@
-// -*- C++ -*-
-//===-----------------------------------------------------------------------===//
-//
+// -*- C++ -*-
+//===-----------------------------------------------------------------------===//
+//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef _LIBCPP_SUPPORT_IBM_SUPPORT_H
-#define _LIBCPP_SUPPORT_IBM_SUPPORT_H
-
-extern "builtin" int __popcnt4(unsigned int);
-extern "builtin" int __popcnt8(unsigned long long);
-extern "builtin" unsigned int __cnttz4(unsigned int);
-extern "builtin" unsigned int __cnttz8(unsigned long long);
-extern "builtin" unsigned int __cntlz4(unsigned int);
-extern "builtin" unsigned int __cntlz8(unsigned long long);
-
-// Builtin functions for counting population
-#define __builtin_popcount(x) __popcnt4(x)
-#define __builtin_popcountll(x) __popcnt8(x)
-#if defined(__64BIT__)
-#define __builtin_popcountl(x) __builtin_popcountll(x)
-#else
-#define __builtin_popcountl(x) __builtin_popcount(x)
-#endif
-
-// Builtin functions for counting trailing zeros
-#define __builtin_ctz(x) __cnttz4(x)
-#define __builtin_ctzll(x) __cnttz8(x)
-#if defined(__64BIT__)
-#define __builtin_ctzl(x) __builtin_ctzll(x)
-#else
-#define __builtin_ctzl(x) __builtin_ctz(x)
-#endif
-
-// Builtin functions for counting leading zeros
-#define __builtin_clz(x) __cntlz4(x)
-#define __builtin_clzll(x) __cntlz8(x)
-#if defined(__64BIT__)
-#define __builtin_clzl(x) __builtin_clzll(x)
-#else
-#define __builtin_clzl(x) __builtin_clz(x)
-#endif
-
-#if defined(__64BIT__)
-#define __SIZE_WIDTH__ 64
-#else
-#define __SIZE_WIDTH__ 32
-#endif
-
-#endif // _LIBCPP_SUPPORT_IBM_SUPPORT_H
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_SUPPORT_IBM_SUPPORT_H
+#define _LIBCPP_SUPPORT_IBM_SUPPORT_H
+
+extern "builtin" int __popcnt4(unsigned int);
+extern "builtin" int __popcnt8(unsigned long long);
+extern "builtin" unsigned int __cnttz4(unsigned int);
+extern "builtin" unsigned int __cnttz8(unsigned long long);
+extern "builtin" unsigned int __cntlz4(unsigned int);
+extern "builtin" unsigned int __cntlz8(unsigned long long);
+
+// Builtin functions for counting population
+#define __builtin_popcount(x) __popcnt4(x)
+#define __builtin_popcountll(x) __popcnt8(x)
+#if defined(__64BIT__)
+#define __builtin_popcountl(x) __builtin_popcountll(x)
+#else
+#define __builtin_popcountl(x) __builtin_popcount(x)
+#endif
+
+// Builtin functions for counting trailing zeros
+#define __builtin_ctz(x) __cnttz4(x)
+#define __builtin_ctzll(x) __cnttz8(x)
+#if defined(__64BIT__)
+#define __builtin_ctzl(x) __builtin_ctzll(x)
+#else
+#define __builtin_ctzl(x) __builtin_ctz(x)
+#endif
+
+// Builtin functions for counting leading zeros
+#define __builtin_clz(x) __cntlz4(x)
+#define __builtin_clzll(x) __cntlz8(x)
+#if defined(__64BIT__)
+#define __builtin_clzl(x) __builtin_clzll(x)
+#else
+#define __builtin_clzl(x) __builtin_clz(x)
+#endif
+
+#if defined(__64BIT__)
+#define __SIZE_WIDTH__ 64
+#else
+#define __SIZE_WIDTH__ 32
+#endif
+
+#endif // _LIBCPP_SUPPORT_IBM_SUPPORT_H
diff --git a/contrib/libs/cxxsupp/libcxx/include/__support/ibm/xlocale.h b/contrib/libs/cxxsupp/libcxx/include/__support/ibm/xlocale.h
index 15b8386dd3..5377d75cac 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__support/ibm/xlocale.h
+++ b/contrib/libs/cxxsupp/libcxx/include/__support/ibm/xlocale.h
@@ -1,133 +1,133 @@
-// -*- C++ -*-
-//===-----------------------------------------------------------------------===//
-//
+// -*- C++ -*-
+//===-----------------------------------------------------------------------===//
+//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef _LIBCPP_SUPPORT_IBM_XLOCALE_H
-#define _LIBCPP_SUPPORT_IBM_XLOCALE_H
-
-#include <__support/ibm/locale_mgmt_zos.h>
-#include <stdarg.h>
-
-#include "cstdlib"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if defined(__MVS__)
-#include <wctype.h>
-// POSIX routines
-#include <__support/xlocale/__posix_l_fallback.h>
-#endif // defined(__MVS__)
-
-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);
- } else {
- __stored = uselocale(locale);
- }
- }
-
- ~__setAndRestore() {
- uselocale(__stored);
- if (__cloc)
- freelocale(__cloc);
- }
-
-private:
- locale_t __stored = (locale_t)0;
- locale_t __cloc = (locale_t)0;
-};
-
-} // namespace
-
-// 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);
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_SUPPORT_IBM_XLOCALE_H
+#define _LIBCPP_SUPPORT_IBM_XLOCALE_H
+
+#include <__support/ibm/locale_mgmt_zos.h>
+#include <stdarg.h>
+
+#include "cstdlib"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if defined(__MVS__)
+#include <wctype.h>
+// POSIX routines
+#include <__support/xlocale/__posix_l_fallback.h>
+#endif // defined(__MVS__)
+
+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);
+ } else {
+ __stored = uselocale(locale);
+ }
+ }
+
+ ~__setAndRestore() {
+ uselocale(__stored);
+ if (__cloc)
+ freelocale(__cloc);
+ }
+
+private:
+ locale_t __stored = (locale_t)0;
+ locale_t __cloc = (locale_t)0;
+};
+
+} // namespace
+
+// 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
+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
+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
+int vasprintf(char **strp, const char *fmt, va_list ap) {
+ const size_t buff_size = 256;
+ if ((*strp = (char *)malloc(buff_size)) == NULL) {
+ return -1;
+ }
+
+ 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)
+ __builtin_va_copy(ap_copy, ap);
+#else
+ va_copy(ap_copy, ap);
+#endif
+ int str_size = vsnprintf(*strp, buff_size, fmt, ap_copy);
+ va_end(ap_copy);
+
+ if ((size_t) str_size >= buff_size) {
+ if ((*strp = (char *)realloc(*strp, str_size + 1)) == NULL) {
+ return -1;
+ }
+ str_size = vsnprintf(*strp, str_size + 1, fmt, ap);
+ }
+ return str_size;
}
-
-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
-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
-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
-int vasprintf(char **strp, const char *fmt, va_list ap) {
- const size_t buff_size = 256;
- if ((*strp = (char *)malloc(buff_size)) == NULL) {
- return -1;
- }
-
- 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)
- __builtin_va_copy(ap_copy, ap);
-#else
- va_copy(ap_copy, ap);
-#endif
- int str_size = vsnprintf(*strp, buff_size, fmt, ap_copy);
- va_end(ap_copy);
-
- if ((size_t) str_size >= buff_size) {
- if ((*strp = (char *)realloc(*strp, str_size + 1)) == NULL) {
- return -1;
- }
- str_size = vsnprintf(*strp, str_size + 1, fmt, ap);
- }
- return str_size;
-}
-
-#ifdef __cplusplus
-}
-#endif
-#endif // _LIBCPP_SUPPORT_IBM_XLOCALE_H
+
+#ifdef __cplusplus
+}
+#endif
+#endif // _LIBCPP_SUPPORT_IBM_XLOCALE_H