summaryrefslogtreecommitdiffstats
path: root/contrib/libs/cxxsupp/libcxx/src
diff options
context:
space:
mode:
authormaxim-yurchuk <[email protected]>2024-10-09 12:29:46 +0300
committermaxim-yurchuk <[email protected]>2024-10-09 13:14:22 +0300
commit9731d8a4bb7ee2cc8554eaf133bb85498a4c7d80 (patch)
treea8fb3181d5947c0d78cf402aa56e686130179049 /contrib/libs/cxxsupp/libcxx/src
parenta44b779cd359f06c3ebbef4ec98c6b38609d9d85 (diff)
publishFullContrib: true for ydb
<HIDDEN_URL> commit_hash:c82a80ac4594723cebf2c7387dec9c60217f603e
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/src')
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/experimental/memory_resource.cpp149
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/experimental/memory_resource_init_helper.h2
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/filesystem/int128_builtins.cpp54
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/pstl/libdispatch.cpp35
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/support/ibm/mbsnrtowcs.cpp95
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/support/ibm/wcsnrtombs.cpp93
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/support/ibm/xlocale_zos.cpp138
7 files changed, 566 insertions, 0 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/src/experimental/memory_resource.cpp b/contrib/libs/cxxsupp/libcxx/src/experimental/memory_resource.cpp
new file mode 100644
index 00000000000..0798d2e72ce
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxx/src/experimental/memory_resource.cpp
@@ -0,0 +1,149 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include <experimental/memory_resource>
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+
+#ifndef _LIBCPP_HAS_NO_ATOMIC_HEADER
+# include <atomic>
+#elif !defined(_LIBCPP_HAS_NO_THREADS)
+# include <mutex>
+# if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)
+# pragma comment(lib, "pthread")
+# endif
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
+
+// memory_resource
+
+//memory_resource::~memory_resource() {}
+
+// new_delete_resource()
+
+class _LIBCPP_EXPORTED_FROM_ABI __new_delete_memory_resource_imp
+ : public memory_resource
+{
+ void *do_allocate(size_t size, size_t align) override {
+#ifdef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
+ if (__is_overaligned_for_new(align))
+ __throw_bad_alloc();
+#endif
+ return _VSTD::__libcpp_allocate(size, align);
+ }
+
+ void do_deallocate(void *p, size_t n, size_t align) override {
+ _VSTD::__libcpp_deallocate(p, n, align);
+ }
+
+ bool do_is_equal(memory_resource const & other) const noexcept override
+ { return &other == this; }
+
+public:
+ ~__new_delete_memory_resource_imp() override = default;
+};
+
+// null_memory_resource()
+
+class _LIBCPP_EXPORTED_FROM_ABI __null_memory_resource_imp
+ : public memory_resource
+{
+public:
+ ~__null_memory_resource_imp() = default;
+
+protected:
+ virtual void* do_allocate(size_t, size_t) {
+ __throw_bad_alloc();
+ }
+ virtual void do_deallocate(void *, size_t, size_t) {}
+ virtual bool do_is_equal(memory_resource const & __other) const noexcept
+ { return &__other == this; }
+};
+
+namespace {
+
+union ResourceInitHelper {
+ struct {
+ __new_delete_memory_resource_imp new_delete_res;
+ __null_memory_resource_imp null_res;
+ } resources;
+ char dummy;
+ constexpr ResourceInitHelper() : resources() {}
+ ~ResourceInitHelper() {}
+};
+
+// Pretend we're inside a system header so the compiler doesn't flag the use of the init_priority
+// attribute with a value that's reserved for the implementation (we're the implementation).
+#include "memory_resource_init_helper.h"
+
+} // end namespace
+
+
+memory_resource * new_delete_resource() noexcept {
+ return &res_init.resources.new_delete_res;
+}
+
+memory_resource * null_memory_resource() noexcept {
+ return &res_init.resources.null_res;
+}
+
+// default_memory_resource()
+
+static memory_resource *
+__default_memory_resource(bool set = false, memory_resource * new_res = nullptr) noexcept
+{
+#ifndef _LIBCPP_HAS_NO_ATOMIC_HEADER
+ static constinit atomic<memory_resource*> __res{&res_init.resources.new_delete_res};
+ if (set) {
+ new_res = new_res ? new_res : new_delete_resource();
+ // TODO: Can a weaker ordering be used?
+ return _VSTD::atomic_exchange_explicit(
+ &__res, new_res, memory_order_acq_rel);
+ }
+ else {
+ return _VSTD::atomic_load_explicit(
+ &__res, memory_order_acquire);
+ }
+#elif !defined(_LIBCPP_HAS_NO_THREADS)
+ static constinit memory_resource *res = &res_init.resources.new_delete_res;
+ static mutex res_lock;
+ if (set) {
+ new_res = new_res ? new_res : new_delete_resource();
+ lock_guard<mutex> guard(res_lock);
+ memory_resource * old_res = res;
+ res = new_res;
+ return old_res;
+ } else {
+ lock_guard<mutex> guard(res_lock);
+ return res;
+ }
+#else
+ static constinit memory_resource *res = &res_init.resources.new_delete_res;
+ if (set) {
+ new_res = new_res ? new_res : new_delete_resource();
+ memory_resource * old_res = res;
+ res = new_res;
+ return old_res;
+ } else {
+ return res;
+ }
+#endif
+}
+
+memory_resource * get_default_resource() noexcept
+{
+ return __default_memory_resource();
+}
+
+memory_resource * set_default_resource(memory_resource * __new_res) noexcept
+{
+ return __default_memory_resource(true, __new_res);
+}
+
+_LIBCPP_END_NAMESPACE_LFTS_PMR
diff --git a/contrib/libs/cxxsupp/libcxx/src/experimental/memory_resource_init_helper.h b/contrib/libs/cxxsupp/libcxx/src/experimental/memory_resource_init_helper.h
new file mode 100644
index 00000000000..032edc12fa2
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxx/src/experimental/memory_resource_init_helper.h
@@ -0,0 +1,2 @@
+#pragma GCC system_header
+static constinit ResourceInitHelper res_init _LIBCPP_INIT_PRIORITY_MAX;
diff --git a/contrib/libs/cxxsupp/libcxx/src/filesystem/int128_builtins.cpp b/contrib/libs/cxxsupp/libcxx/src/filesystem/int128_builtins.cpp
new file mode 100644
index 00000000000..96bcc5fa67e
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxx/src/filesystem/int128_builtins.cpp
@@ -0,0 +1,54 @@
+/*===-- int128_builtins.cpp - Implement __muloti4 --------------------------===
+ *
+ * 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
+ *
+ * ===----------------------------------------------------------------------===
+ *
+ * This file implements __muloti4, and is stolen from the compiler_rt library.
+ *
+ * FIXME: we steal and re-compile it into filesystem, which uses __int128_t,
+ * and requires this builtin when sanitized. See llvm.org/PR30643
+ *
+ * ===----------------------------------------------------------------------===
+ */
+#include <__config>
+#include <climits>
+
+#if !defined(_LIBCPP_HAS_NO_INT128)
+
+extern "C" __attribute__((no_sanitize("undefined"))) _LIBCPP_EXPORTED_FROM_ABI
+__int128_t __muloti4(__int128_t a, __int128_t b, int* overflow) {
+ const int N = (int)(sizeof(__int128_t) * CHAR_BIT);
+ const __int128_t MIN = (__int128_t)1 << (N - 1);
+ const __int128_t MAX = ~MIN;
+ *overflow = 0;
+ __int128_t result = a * b;
+ if (a == MIN) {
+ if (b != 0 && b != 1)
+ *overflow = 1;
+ return result;
+ }
+ if (b == MIN) {
+ if (a != 0 && a != 1)
+ *overflow = 1;
+ return result;
+ }
+ __int128_t sa = a >> (N - 1);
+ __int128_t abs_a = (a ^ sa) - sa;
+ __int128_t sb = b >> (N - 1);
+ __int128_t abs_b = (b ^ sb) - sb;
+ if (abs_a < 2 || abs_b < 2)
+ return result;
+ if (sa == sb) {
+ if (abs_a > MAX / abs_b)
+ *overflow = 1;
+ } else {
+ if (abs_a > MIN / -abs_b)
+ *overflow = 1;
+ }
+ return result;
+}
+
+#endif
diff --git a/contrib/libs/cxxsupp/libcxx/src/pstl/libdispatch.cpp b/contrib/libs/cxxsupp/libcxx/src/pstl/libdispatch.cpp
new file mode 100644
index 00000000000..52d4afbcce6
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxx/src/pstl/libdispatch.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include <__algorithm/min.h>
+#include <__algorithm/pstl_backends/cpu_backends/libdispatch.h>
+#include <__config>
+#include <dispatch/dispatch.h>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace __par_backend::inline __libdispatch {
+
+void __dispatch_apply(size_t chunk_count, void* context, void (*func)(void* context, size_t chunk)) noexcept {
+ ::dispatch_apply_f(chunk_count, DISPATCH_APPLY_AUTO, context, func);
+}
+
+__chunk_partitions __partition_chunks(ptrdiff_t element_count) noexcept {
+ __chunk_partitions partitions;
+ partitions.__chunk_count_ = std::max<ptrdiff_t>(1, element_count / 256);
+ partitions.__chunk_size_ = element_count / partitions.__chunk_count_;
+ partitions.__first_chunk_size_ = element_count - (partitions.__chunk_count_ - 1) * partitions.__chunk_size_;
+ if (partitions.__chunk_count_ == 0 && element_count > 0)
+ partitions.__chunk_count_ = 1;
+ return partitions;
+}
+
+// NOLINTNEXTLINE(llvm-namespace-comment) // This is https://llvm.org/PR56804
+} // namespace __par_backend::inline __libdispatch
+
+_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/libs/cxxsupp/libcxx/src/support/ibm/mbsnrtowcs.cpp b/contrib/libs/cxxsupp/libcxx/src/support/ibm/mbsnrtowcs.cpp
new file mode 100644
index 00000000000..6edc3c254de
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxx/src/support/ibm/mbsnrtowcs.cpp
@@ -0,0 +1,95 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include <cstddef> // size_t
+#include <cwchar> // mbstate_t
+#include <limits.h> // MB_LEN_MAX
+#include <string.h> // wmemcpy
+
+// Returns the number of wide characters found in the multi byte sequence `src`
+// (of `src_size_bytes`), that fit in the buffer `dst` (of `max_dest_chars`
+// elements size). The count returned excludes the null terminator.
+// When `dst` is NULL, no characters are copied to `dst`.
+// Returns (size_t) -1 when an invalid sequence is encountered.
+// Leaves *`src` pointing to the next character to convert or NULL
+// if a null character was converted from *`src`.
+_LIBCPP_EXPORTED_FROM_ABI
+size_t mbsnrtowcs(wchar_t *__restrict dst, const char **__restrict src,
+ size_t src_size_bytes, size_t max_dest_chars,
+ mbstate_t *__restrict ps) {
+ const size_t terminated_sequence = static_cast<size_t>(0);
+ const size_t invalid_sequence = static_cast<size_t>(-1);
+ const size_t incomplete_sequence = static_cast<size_t>(-2);
+
+ size_t source_converted;
+ size_t dest_converted;
+ size_t result = 0;
+
+ // If `dst` is null then `max_dest_chars` should be ignored according to the
+ // standard. Setting `max_dest_chars` to a large value has this effect.
+ if (dst == nullptr)
+ max_dest_chars = static_cast<size_t>(-1);
+
+ for (dest_converted = source_converted = 0;
+ source_converted < src_size_bytes && (!dst || dest_converted < max_dest_chars);
+ ++dest_converted, source_converted += result) {
+ // Converts one multi byte character.
+ // If result (char_size) is greater than 0, it's the size in bytes of that character.
+ // If result (char_size) is zero, it indicates that the null character has been found.
+ // Otherwise, it's an error and errno may be set.
+ size_t source_remaining = src_size_bytes - source_converted;
+ size_t dest_remaining = max_dest_chars - dest_converted;
+
+ if (dst == nullptr) {
+ result = mbrtowc(NULL, *src + source_converted, source_remaining, ps);
+ } else if (dest_remaining >= source_remaining) {
+ // dst has enough space to translate in-place.
+ result = mbrtowc(dst + dest_converted, *src + source_converted, source_remaining, ps);
+ } else {
+ /*
+ * dst may not have enough space, so use a temporary buffer.
+ *
+ * We need to save a copy of the conversion state
+ * here so we can restore it if the multibyte
+ * character is too long for the buffer.
+ */
+ wchar_t buff[MB_LEN_MAX];
+ mbstate_t mbstate_tmp;
+
+ if (ps != nullptr)
+ mbstate_tmp = *ps;
+ result = mbrtowc(buff, *src + source_converted, source_remaining, ps);
+
+ if (result > dest_remaining) {
+ // Multi-byte sequence for character won't fit.
+ if (ps != nullptr)
+ *ps = mbstate_tmp;
+ break;
+ } else {
+ // The buffer was used, so we need copy the translation to dst.
+ wmemcpy(dst, buff, result);
+ }
+ }
+
+ // Don't do anything to change errno from here on.
+ if (result == invalid_sequence || result == terminated_sequence || result == incomplete_sequence) {
+ break;
+ }
+ }
+
+ if (dst) {
+ if (result == terminated_sequence)
+ *src = NULL;
+ else
+ *src += source_converted;
+ }
+ if (result == invalid_sequence)
+ return invalid_sequence;
+
+ return dest_converted;
+}
diff --git a/contrib/libs/cxxsupp/libcxx/src/support/ibm/wcsnrtombs.cpp b/contrib/libs/cxxsupp/libcxx/src/support/ibm/wcsnrtombs.cpp
new file mode 100644
index 00000000000..d6333fe5f1f
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxx/src/support/ibm/wcsnrtombs.cpp
@@ -0,0 +1,93 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include <cwchar> // mbstate_t
+#include <limits.h> // MB_LEN_MAX
+#include <stdlib.h> // MB_CUR_MAX, size_t
+#include <string.h> // memcpy
+
+// Converts `max_source_chars` from the wide character buffer pointer to by *`src`,
+// into the multi byte character sequence buffer stored at `dst`, which must be
+// `dst_size_bytes` bytes in size. Returns the number of bytes in the sequence
+// converted from *src, excluding the null terminator.
+// Returns (size_t) -1 if an error occurs and sets errno.
+// If `dst` is NULL, `dst_size_bytes` is ignored and no bytes are copied to `dst`.
+_LIBCPP_EXPORTED_FROM_ABI
+size_t wcsnrtombs(char *__restrict dst, const wchar_t **__restrict src,
+ size_t max_source_chars, size_t dst_size_bytes,
+ mbstate_t *__restrict ps) {
+
+ const size_t invalid_wchar = static_cast<size_t>(-1);
+
+ size_t source_converted;
+ size_t dest_converted;
+ size_t result = 0;
+
+ // If `dst` is null then `dst_size_bytes` should be ignored according to the
+ // standard. Setting dst_size_bytes to a large value has this effect.
+ if (dst == nullptr)
+ dst_size_bytes = static_cast<size_t>(-1);
+
+ for (dest_converted = source_converted = 0;
+ source_converted < max_source_chars && (!dst || dest_converted < dst_size_bytes);
+ ++source_converted, dest_converted += result) {
+ wchar_t c = (*src)[source_converted];
+ size_t dest_remaining = dst_size_bytes - dest_converted;
+
+ if (dst == nullptr) {
+ result = wcrtomb(NULL, c, ps);
+ } else if (dest_remaining >= static_cast<size_t>(MB_CUR_MAX)) {
+ // dst has enough space to translate in-place.
+ result = wcrtomb(dst + dest_converted, c, ps);
+ } else {
+ /*
+ * dst may not have enough space, so use a temporary buffer.
+ *
+ * We need to save a copy of the conversion state
+ * here so we can restore it if the multibyte
+ * character is too long for the buffer.
+ */
+ char buff[MB_LEN_MAX];
+ mbstate_t mbstate_tmp;
+
+ if (ps != nullptr)
+ mbstate_tmp = *ps;
+ result = wcrtomb(buff, c, ps);
+
+ if (result > dest_remaining) {
+ // Multi-byte sequence for character won't fit.
+ if (ps != nullptr)
+ *ps = mbstate_tmp;
+ if (result != invalid_wchar)
+ break;
+ } else {
+ // The buffer was used, so we need copy the translation to dst.
+ memcpy(dst, buff, result);
+ }
+ }
+
+ // result (char_size) contains the size of the multi-byte-sequence converted.
+ // Otherwise, result (char_size) is (size_t) -1 and wcrtomb() sets the errno.
+ if (result == invalid_wchar) {
+ if (dst)
+ *src = *src + source_converted;
+ return invalid_wchar;
+ }
+
+ if (c == L'\0') {
+ if (dst)
+ *src = NULL;
+ return dest_converted;
+ }
+ }
+
+ if (dst)
+ *src = *src + source_converted;
+
+ return dest_converted;
+}
diff --git a/contrib/libs/cxxsupp/libcxx/src/support/ibm/xlocale_zos.cpp b/contrib/libs/cxxsupp/libcxx/src/support/ibm/xlocale_zos.cpp
new file mode 100644
index 00000000000..034a5b96605
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxx/src/support/ibm/xlocale_zos.cpp
@@ -0,0 +1,138 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include <__assert>
+#include <__support/ibm/xlocale.h>
+#include <sstream>
+#include <vector>
+
+#ifdef __cplusplus
+extern "C" {
+#endif // __cplusplus
+
+locale_t newlocale(int category_mask, const char* locale, locale_t base) {
+ // Maintain current locale name(s) to restore later.
+ std::string current_loc_name(setlocale(LC_ALL, 0));
+
+ // Check for errors.
+ if (category_mask == LC_ALL_MASK && setlocale(LC_ALL, locale) == NULL) {
+ errno = EINVAL;
+ return (locale_t)0;
+ } else {
+ for (int _Cat = 0; _Cat <= _LC_MAX; ++_Cat) {
+ if ((_CATMASK(_Cat) & category_mask) != 0 && setlocale(_Cat, locale) == NULL) {
+ setlocale(LC_ALL, current_loc_name.c_str());
+ errno = EINVAL;
+ return (locale_t)0;
+ }
+ }
+ }
+
+ // Create new locale.
+ locale_t newloc = new locale_struct();
+
+ if (base) {
+ if (category_mask != LC_ALL_MASK) {
+ // Copy base when it will not be overwritten.
+ memcpy(newloc, base, sizeof (locale_struct));
+ newloc->category_mask = category_mask | base->category_mask;
+ }
+ delete base;
+ } else {
+ newloc->category_mask = category_mask;
+ }
+
+ if (category_mask & LC_COLLATE_MASK)
+ newloc->lc_collate = locale;
+ if (category_mask & LC_CTYPE_MASK)
+ newloc->lc_ctype = locale;
+ if (category_mask & LC_MONETARY_MASK)
+ newloc->lc_monetary = locale;
+ if (category_mask & LC_NUMERIC_MASK)
+ newloc->lc_numeric = locale;
+ if (category_mask & LC_TIME_MASK)
+ newloc->lc_time = locale;
+ if (category_mask & LC_MESSAGES_MASK)
+ newloc->lc_messages = locale;
+
+ // Restore current locale.
+ setlocale(LC_ALL, current_loc_name.c_str());
+ return (locale_t)newloc;
+}
+
+void freelocale(locale_t locobj) {
+ delete locobj;
+}
+
+locale_t uselocale(locale_t newloc) {
+ // Maintain current locale name(s).
+ std::string current_loc_name(setlocale(LC_ALL, 0));
+
+ if (newloc) {
+ // Set locales and check for errors.
+ bool is_error =
+ (newloc->category_mask & LC_COLLATE_MASK &&
+ setlocale(LC_COLLATE, newloc->lc_collate.c_str()) == NULL) ||
+ (newloc->category_mask & LC_CTYPE_MASK &&
+ setlocale(LC_CTYPE, newloc->lc_ctype.c_str()) == NULL) ||
+ (newloc->category_mask & LC_MONETARY_MASK &&
+ setlocale(LC_MONETARY, newloc->lc_monetary.c_str()) == NULL) ||
+ (newloc->category_mask & LC_NUMERIC_MASK &&
+ setlocale(LC_NUMERIC, newloc->lc_numeric.c_str()) == NULL) ||
+ (newloc->category_mask & LC_TIME_MASK &&
+ setlocale(LC_TIME, newloc->lc_time.c_str()) == NULL) ||
+ (newloc->category_mask & LC_MESSAGES_MASK &&
+ setlocale(LC_MESSAGES, newloc->lc_messages.c_str()) == NULL);
+
+ if (is_error) {
+ setlocale(LC_ALL, current_loc_name.c_str());
+ errno = EINVAL;
+ return (locale_t)0;
+ }
+ }
+
+ // Construct and return previous locale.
+ locale_t previous_loc = new locale_struct();
+
+ // current_loc_name might be a comma-separated locale name list.
+ if (current_loc_name.find(',') != std::string::npos) {
+ // Tokenize locale name list.
+ const char delimiter = ',';
+ std::vector<std::string> tokenized;
+ std::stringstream ss(current_loc_name);
+ std::string s;
+
+ while (std::getline(ss, s, delimiter)) {
+ tokenized.push_back(s);
+ }
+
+ _LIBCPP_ASSERT_UNCATEGORIZED(tokenized.size() >= _NCAT, "locale-name list is too short");
+
+ previous_loc->lc_collate = tokenized[LC_COLLATE];
+ previous_loc->lc_ctype = tokenized[LC_CTYPE];
+ previous_loc->lc_monetary = tokenized[LC_MONETARY];
+ previous_loc->lc_numeric = tokenized[LC_NUMERIC];
+ previous_loc->lc_time = tokenized[LC_TIME];
+ // Skip LC_TOD.
+ previous_loc->lc_messages = tokenized[LC_MESSAGES];
+ } else {
+ previous_loc->lc_collate = current_loc_name;
+ previous_loc->lc_ctype = current_loc_name;
+ previous_loc->lc_monetary = current_loc_name;
+ previous_loc->lc_numeric = current_loc_name;
+ previous_loc->lc_time = current_loc_name;
+ previous_loc->lc_messages = current_loc_name;
+ }
+
+ previous_loc->category_mask = LC_ALL_MASK;
+ return previous_loc;
+}
+
+#ifdef __cplusplus
+}
+#endif // __cplusplus