[libc-commits] [libc] [libc] Initial support for 'locale.h' in the LLVM libc (PR #102689)
Petr Hosek via libc-commits
libc-commits at lists.llvm.org
Wed Aug 21 10:52:24 PDT 2024
================
@@ -0,0 +1,36 @@
+//===-- Implementation header for the locale --------------------*- 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 LLVM_LIBC_SRC_LOCALE_LOCALECONV_H
+#define LLVM_LIBC_SRC_LOCALE_LOCALECONV_H
+
+#include "src/__support/macros/attributes.h"
+#include "src/__support/macros/config.h"
+
+#include "include/llvm-libc-types/locale_t.h"
+
+#include <stddef.h>
+
+namespace LIBC_NAMESPACE_DECL {
+
+// We only support the "C" locale right now.
+static constexpr size_t MAX_LOCALE_NAME_SIZE = 2;
+
+struct __locale_data {
+ char name[MAX_LOCALE_NAME_SIZE];
+};
+
+// The pointer to the default "C" locale.
+extern __locale_t c_locale;
+
+// The global locale instance.
+LIBC_THREAD_LOCAL extern locale_t locale;
----------------
petrhosek wrote:
We currently don't have any define for the baremetal target to conditionalize the build on although I suspect we'll need one sooner or later.
https://github.com/llvm/llvm-project/pull/102689
More information about the libc-commits
mailing list