From 3ad39e9878310e5317ee73c9b353c1e2c1c5c4ee Mon Sep 17 00:00:00 2001 From: Richard Qin Date: Sat, 11 Jul 2026 22:48:30 +0800 Subject: lib: establish Zircon libc++ and KTL foundation --- third_party/libcxx/include/c++/v1/__cstddef/byte.h | 85 ++++++++++++++++++++++ .../libcxx/include/c++/v1/__cstddef/max_align_t.h | 27 +++++++ .../libcxx/include/c++/v1/__cstddef/nullptr_t.h | 24 ++++++ .../libcxx/include/c++/v1/__cstddef/ptrdiff_t.h | 24 ++++++ .../libcxx/include/c++/v1/__cstddef/size_t.h | 24 ++++++ 5 files changed, 184 insertions(+) create mode 100644 third_party/libcxx/include/c++/v1/__cstddef/byte.h create mode 100644 third_party/libcxx/include/c++/v1/__cstddef/max_align_t.h create mode 100644 third_party/libcxx/include/c++/v1/__cstddef/nullptr_t.h create mode 100644 third_party/libcxx/include/c++/v1/__cstddef/ptrdiff_t.h create mode 100644 third_party/libcxx/include/c++/v1/__cstddef/size_t.h (limited to 'third_party/libcxx/include/c++/v1/__cstddef') diff --git a/third_party/libcxx/include/c++/v1/__cstddef/byte.h b/third_party/libcxx/include/c++/v1/__cstddef/byte.h new file mode 100644 index 0000000..3d97db1 --- /dev/null +++ b/third_party/libcxx/include/c++/v1/__cstddef/byte.h @@ -0,0 +1,85 @@ +//===---------------------------------------------------------------------===// +// +// 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___CSTDDEF_BYTE_H +#define _LIBCPP___CSTDDEF_BYTE_H + +#include <__config> +#include <__fwd/byte.h> +#include <__type_traits/enable_if.h> +#include <__type_traits/is_integral.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +#if _LIBCPP_STD_VER >= 17 +_LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD + +enum class byte : unsigned char {}; + +_LIBCPP_HIDE_FROM_ABI inline constexpr byte operator|(byte __lhs, byte __rhs) noexcept { + return static_cast( + static_cast(static_cast(__lhs) | static_cast(__rhs))); +} + +_LIBCPP_HIDE_FROM_ABI inline constexpr byte& operator|=(byte& __lhs, byte __rhs) noexcept { + return __lhs = __lhs | __rhs; +} + +_LIBCPP_HIDE_FROM_ABI inline constexpr byte operator&(byte __lhs, byte __rhs) noexcept { + return static_cast( + static_cast(static_cast(__lhs) & static_cast(__rhs))); +} + +_LIBCPP_HIDE_FROM_ABI inline constexpr byte& operator&=(byte& __lhs, byte __rhs) noexcept { + return __lhs = __lhs & __rhs; +} + +_LIBCPP_HIDE_FROM_ABI inline constexpr byte operator^(byte __lhs, byte __rhs) noexcept { + return static_cast( + static_cast(static_cast(__lhs) ^ static_cast(__rhs))); +} + +_LIBCPP_HIDE_FROM_ABI inline constexpr byte& operator^=(byte& __lhs, byte __rhs) noexcept { + return __lhs = __lhs ^ __rhs; +} + +_LIBCPP_HIDE_FROM_ABI inline constexpr byte operator~(byte __b) noexcept { + return static_cast(static_cast(~static_cast(__b))); +} + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI constexpr byte& operator<<=(byte& __lhs, _Integer __shift) noexcept { + return __lhs = __lhs << __shift; +} + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI constexpr byte operator<<(byte __lhs, _Integer __shift) noexcept { + return static_cast(static_cast(static_cast(__lhs) << __shift)); +} + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI constexpr byte& operator>>=(byte& __lhs, _Integer __shift) noexcept { + return __lhs = __lhs >> __shift; +} + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI constexpr byte operator>>(byte __lhs, _Integer __shift) noexcept { + return static_cast(static_cast(static_cast(__lhs) >> __shift)); +} + +template ::value, int> = 0> +[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Integer to_integer(byte __b) noexcept { + return static_cast<_Integer>(__b); +} + +_LIBCPP_END_UNVERSIONED_NAMESPACE_STD +#endif // _LIBCPP_STD_VER >= 17 + +#endif // _LIBCPP___CSTDDEF_BYTE_H diff --git a/third_party/libcxx/include/c++/v1/__cstddef/max_align_t.h b/third_party/libcxx/include/c++/v1/__cstddef/max_align_t.h new file mode 100644 index 0000000..7c09c7e --- /dev/null +++ b/third_party/libcxx/include/c++/v1/__cstddef/max_align_t.h @@ -0,0 +1,27 @@ +//===---------------------------------------------------------------------===// +// +// 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___CSTDDEF_MAX_ALIGN_T_H +#define _LIBCPP___CSTDDEF_MAX_ALIGN_T_H + +#include <__config> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if !defined(_LIBCPP_CXX03_LANG) +using ::max_align_t _LIBCPP_USING_IF_EXISTS; +#endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___CSTDDEF_MAX_ALIGN_T_H diff --git a/third_party/libcxx/include/c++/v1/__cstddef/nullptr_t.h b/third_party/libcxx/include/c++/v1/__cstddef/nullptr_t.h new file mode 100644 index 0000000..7eaae01 --- /dev/null +++ b/third_party/libcxx/include/c++/v1/__cstddef/nullptr_t.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___CSTDDEF_NULLPTR_T_H +#define _LIBCPP___CSTDDEF_NULLPTR_T_H + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +using nullptr_t = decltype(nullptr); + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___CSTDDEF_NULLPTR_T_H diff --git a/third_party/libcxx/include/c++/v1/__cstddef/ptrdiff_t.h b/third_party/libcxx/include/c++/v1/__cstddef/ptrdiff_t.h new file mode 100644 index 0000000..146f345 --- /dev/null +++ b/third_party/libcxx/include/c++/v1/__cstddef/ptrdiff_t.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___CSTDDEF_PTRDIFF_T_H +#define _LIBCPP___CSTDDEF_PTRDIFF_T_H + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +using ptrdiff_t = decltype(static_cast(nullptr) - static_cast(nullptr)); + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___CSTDDEF_PTRDIFF_T_H diff --git a/third_party/libcxx/include/c++/v1/__cstddef/size_t.h b/third_party/libcxx/include/c++/v1/__cstddef/size_t.h new file mode 100644 index 0000000..59bad93 --- /dev/null +++ b/third_party/libcxx/include/c++/v1/__cstddef/size_t.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___CSTDDEF_SIZE_T_H +#define _LIBCPP___CSTDDEF_SIZE_T_H + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +using size_t = decltype(sizeof(int)); + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___CSTDDEF_SIZE_T_H -- cgit v1.2.3