mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-08 20:32:56 +03:00
122 lines
5.5 KiB
Diff
122 lines
5.5 KiB
Diff
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||
|
From: sin-ack <sin-ack@protonmail.com>
|
||
|
Date: Tue, 27 Sep 2022 00:08:46 +0000
|
||
|
Subject: [PATCH] Add support for SerenityOS
|
||
|
|
||
|
This commit teaches libc++ about what features are available in our
|
||
|
LibC, namely:
|
||
|
* We do not have locale support, so no-op shims should be used in place
|
||
|
of the C locale API.
|
||
|
* The number of errno constants defined by us is given by the value of
|
||
|
the `ELAST` macro.
|
||
|
* Multithreading is implemented though the pthread library.
|
||
|
* Use libc++'s builtin character type table instead of the one provided
|
||
|
by LibC as there's a lot of extra porting work to convince the rest of
|
||
|
locale.cpp to use our character type table properly.
|
||
|
|
||
|
This commit is an adaptation of the LLVM patch by Daniel Bertalan to fit
|
||
|
the layout of the zig-bootstrap project.
|
||
|
|
||
|
Co-Authored-By: Daniel Bertalan <dani@danielbertalan.dev>
|
||
|
---
|
||
|
zig/lib/libcxx/include/__config | 5 ++--
|
||
|
zig/lib/libcxx/include/__locale | 2 ++
|
||
|
.../include/__support/serenity/xlocale.h | 24 +++++++++++++++++++
|
||
|
zig/lib/libcxx/include/locale | 2 +-
|
||
|
zig/lib/libcxx/src/include/config_elast.h | 2 ++
|
||
|
5 files changed, 32 insertions(+), 3 deletions(-)
|
||
|
create mode 100644 zig/lib/libcxx/include/__support/serenity/xlocale.h
|
||
|
|
||
|
diff --git a/zig/lib/libcxx/include/__config b/zig/lib/libcxx/include/__config
|
||
|
index d9a47343dad1faf52826abbcd6da7578cec9932a..74a8970eddfaec23f421c3edbe974f77ad055e27 100644
|
||
|
--- a/zig/lib/libcxx/include/__config
|
||
|
+++ b/zig/lib/libcxx/include/__config
|
||
|
@@ -910,7 +910,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
|
||
|
defined(__sun__) || \
|
||
|
defined(__MVS__) || \
|
||
|
defined(_AIX) || \
|
||
|
- defined(__EMSCRIPTEN__)
|
||
|
+ defined(__EMSCRIPTEN__) || \
|
||
|
+ defined(__serenity__)
|
||
|
// clang-format on
|
||
|
# define _LIBCPP_HAS_THREAD_API_PTHREAD
|
||
|
# elif defined(__Fuchsia__)
|
||
|
@@ -988,7 +989,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
|
||
|
# endif
|
||
|
|
||
|
# if defined(__BIONIC__) || defined(__NuttX__) || defined(__Fuchsia__) || defined(__wasi__) || \
|
||
|
- defined(_LIBCPP_HAS_MUSL_LIBC) || defined(__OpenBSD__)
|
||
|
+ defined(_LIBCPP_HAS_MUSL_LIBC) || defined(__OpenBSD__) || defined(__serenity__)
|
||
|
# define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
|
||
|
# endif
|
||
|
|
||
|
diff --git a/zig/lib/libcxx/include/__locale b/zig/lib/libcxx/include/__locale
|
||
|
index 40f9a3ff57c22635254be654227333b2a10eca6a..1c499c078b44a49abead17ce566801b4c34733f3 100644
|
||
|
--- a/zig/lib/libcxx/include/__locale
|
||
|
+++ b/zig/lib/libcxx/include/__locale
|
||
|
@@ -42,6 +42,8 @@
|
||
|
# include <__support/musl/xlocale.h>
|
||
|
#elif defined(_LIBCPP_HAS_MUSL_LIBC)
|
||
|
# include <__support/musl/xlocale.h>
|
||
|
+#elif defined(__serenity__)
|
||
|
+# include <__support/serenity/xlocale.h>
|
||
|
#endif
|
||
|
|
||
|
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||
|
diff --git a/zig/lib/libcxx/include/__support/serenity/xlocale.h b/zig/lib/libcxx/include/__support/serenity/xlocale.h
|
||
|
new file mode 100644
|
||
|
index 0000000000000000000000000000000000000000..0f939d2f6989e2ad617145308d079776fe87b6ce
|
||
|
--- /dev/null
|
||
|
+++ b/zig/lib/libcxx/include/__support/serenity/xlocale.h
|
||
|
@@ -0,0 +1,24 @@
|
||
|
+//===----------------------------------------------------------------------===//
|
||
|
+//
|
||
|
+// 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_SERENITY_XLOCALE_H
|
||
|
+#define _LIBCPP_SUPPORT_SERENITY_XLOCALE_H
|
||
|
+
|
||
|
+#if defined(__serenity__)
|
||
|
+
|
||
|
+#include <cstdlib>
|
||
|
+#include <clocale>
|
||
|
+#include <cwctype>
|
||
|
+#include <ctype.h>
|
||
|
+#include <__support/xlocale/__nop_locale_mgmt.h>
|
||
|
+#include <__support/xlocale/__posix_l_fallback.h>
|
||
|
+#include <__support/xlocale/__strtonum_fallback.h>
|
||
|
+
|
||
|
+#endif // __serenity__
|
||
|
+
|
||
|
+#endif
|
||
|
diff --git a/zig/lib/libcxx/include/locale b/zig/lib/libcxx/include/locale
|
||
|
index b01c66d0430f66ee74118e73296780bb864e920b..da29b7d00c709788facb049f417b6d5ccb5b70e1 100644
|
||
|
--- a/zig/lib/libcxx/include/locale
|
||
|
+++ b/zig/lib/libcxx/include/locale
|
||
|
@@ -217,7 +217,7 @@ template <class charT> class messages_byname;
|
||
|
|
||
|
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
|
||
|
// Most unix variants have catopen. These are the specific ones that don't.
|
||
|
-# if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION) && !defined(__EMSCRIPTEN__)
|
||
|
+# if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION) && !defined(__EMSCRIPTEN__) && !defined(__serenity__)
|
||
|
# define _LIBCPP_HAS_CATOPEN 1
|
||
|
# include <nl_types.h>
|
||
|
# endif
|
||
|
diff --git a/zig/lib/libcxx/src/include/config_elast.h b/zig/lib/libcxx/src/include/config_elast.h
|
||
|
index bef26ec5019eccab758733eb85a1f8a6fc404968..fbb2899b1939a2f9ce7a39337c99e48c7749f7f2 100644
|
||
|
--- a/zig/lib/libcxx/src/include/config_elast.h
|
||
|
+++ b/zig/lib/libcxx/src/include/config_elast.h
|
||
|
@@ -35,6 +35,8 @@
|
||
|
#define _LIBCPP_ELAST 4095
|
||
|
#elif defined(__APPLE__)
|
||
|
// No _LIBCPP_ELAST needed on Apple
|
||
|
+#elif defined(__serenity__)
|
||
|
+// No _LIBCPP_ELAST needed on SerenityOS
|
||
|
#elif defined(__sun__)
|
||
|
#define _LIBCPP_ELAST ESTALE
|
||
|
#elif defined(__MVS__)
|