namespace __llvm_libc {
namespace cpp {
-template <class T, size_t N> struct array {
- static_assert(N != 0, "Cannot create a __llvm_libc::cpp::array of size 0.");
+template <class T, size_t N> struct Array {
+ static_assert(N != 0, "Cannot create a __llvm_libc::cpp::Array of size 0.");
T Data[N];
#ifndef LLVM_LIBC_SRC_SUPPORT_CPP_ARRAYREF_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_ARRAYREF_H
-#include "array.h"
+#include "Array.h"
#include "type_traits.h" // RemoveCVType
#include <stddef.h> // For size_t.
ArrayRef(const void *Data, size_t Length)
: Impl(reinterpret_cast<const T *>(Data), Length / sizeof(T)) {}
- // From array.
- template <size_t N> ArrayRef(const array<T, N> &Arr) : Impl(Arr.Data, N) {}
+ // From Array.
+ template <size_t N> ArrayRef(const Array<T, N> &Arr) : Impl(Arr.Data, N) {}
};
template <typename T>
MutableArrayRef(void *Data, size_t Length)
: Impl(reinterpret_cast<T *>(Data), Length / sizeof(T)) {}
- // From array.
- template <size_t N> MutableArrayRef(array<T, N> &Arr) : Impl(Arr.Data, N) {}
+ // From Array.
+ template <size_t N> MutableArrayRef(Array<T, N> &Arr) : Impl(Arr.Data, N) {}
operator ArrayRef<T>() const {
return ArrayRef<T>(this->data(), this->size());
add_header_library(
array
HDRS
- array.h
+ Array.h
)
add_header_library(
#ifndef LLVM_LIBC_UTILS_CPP_UINT_H
#define LLVM_LIBC_UTILS_CPP_UINT_H
-#include "array.h"
+#include "Array.h"
#include <stddef.h> // For size_t
#include <stdint.h>
val[i] = 0;
}
}
- constexpr explicit UInt(const cpp::array<uint64_t, WordCount> &words) {
+ constexpr explicit UInt(const cpp::Array<uint64_t, WordCount> &words) {
for (size_t i = 0; i < WordCount; ++i)
val[i] = words[i];
}
uint64_t x_lo = low(x);
uint64_t x_hi = high(x);
- cpp::array<uint64_t, WordCount + 1> row1;
+ cpp::Array<uint64_t, WordCount + 1> row1;
uint64_t carry = 0;
for (size_t i = 0; i < WordCount; ++i) {
uint64_t l = low(val[i]);
}
row1[WordCount] = carry;
- cpp::array<uint64_t, WordCount + 1> row2;
+ cpp::Array<uint64_t, WordCount + 1> row2;
row2[0] = 0;
carry = 0;
for (size_t i = 0; i < WordCount; ++i) {
TYPED_TEST(LlvmLibcArrayRefTest, ConstructFromLibcArray, Types) {
using value_type = typename ParamType::value_type;
using const_pointer = typename ParamType::const_pointer;
- array<value_type, 2> values = {1, 2};
+ Array<value_type, 2> values = {1, 2};
ParamType arrayref(values);
EXPECT_FALSE(arrayref.empty());
EXPECT_EQ(arrayref.size(), size_t(2));
//
//===----------------------------------------------------------------------===//
+#include "src/__support/CPP/Array.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/math/cosf.h"
#include "test/src/math/sdcomp26094.h"
#ifndef LLVM_LIBC_TEST_SRC_MATH_SDCOMP26094_H
#define LLVM_LIBC_TEST_SRC_MATH_SDCOMP26094_H
-#include "src/__support/CPP/array.h"
+#include "src/__support/CPP/Array.h"
#include <stdint.h>
namespace __llvm_libc {
namespace testing {
-static constexpr __llvm_libc::cpp::array<uint32_t, 10> SDCOMP26094_VALUES{
+static constexpr __llvm_libc::cpp::Array<uint32_t, 10> SDCOMP26094_VALUES{
0x46427f1b, 0x4647e568, 0x46428bac, 0x4647f1f9, 0x4647fe8a,
0x45d8d7f1, 0x45d371a4, 0x45ce0b57, 0x45d35882, 0x45cdf235,
};
//
//===----------------------------------------------------------------------===//
+#include "src/__support/CPP/Array.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/math/sincosf.h"
#include "test/src/math/sdcomp26094.h"
//
//===----------------------------------------------------------------------===//
+#include "src/__support/CPP/Array.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/math/sinf.h"
#include "test/src/math/sdcomp26094.h"
//
//===----------------------------------------------------------------------===//
+#include "src/__support/CPP/Array.h"
#include "src/__support/CPP/Utility.h"
-#include "src/__support/CPP/array.h"
#include "src/stdlib/atexit.h"
#include "src/stdlib/exit.h"
#include "utils/UnitTest/Test.h"
}
static int size;
-static __llvm_libc::cpp::array<int, 256> arr;
+static __llvm_libc::cpp::Array<int, 256> arr;
template <int... Ts>
void register_atexit_handlers(__llvm_libc::cpp::IntegerSequence<int, Ts...>) {
#include "src/string/bzero.h"
#include "utils/UnitTest/Test.h"
-using __llvm_libc::cpp::array;
+using __llvm_libc::cpp::Array;
using __llvm_libc::cpp::ArrayRef;
-using Data = array<char, 2048>;
+using Data = Array<char, 2048>;
static const ArrayRef<char> k_deadcode("DEADC0DE", 8);
#include "src/string/memcpy.h"
#include "utils/UnitTest/Test.h"
-using __llvm_libc::cpp::array;
+using __llvm_libc::cpp::Array;
using __llvm_libc::cpp::ArrayRef;
-using Data = array<char, 2048>;
+using Data = Array<char, 2048>;
static const ArrayRef<char> k_numbers("0123456789", 10);
static const ArrayRef<char> k_deadcode("DEADC0DE", 8);
#include "utils/UnitTest/MemoryMatcher.h"
#include "utils/UnitTest/Test.h"
-using __llvm_libc::cpp::array;
+using __llvm_libc::cpp::Array;
using __llvm_libc::cpp::ArrayRef;
using __llvm_libc::cpp::MutableArrayRef;
}
TEST(LlvmLibcMemmoveTest, Thorough) {
- using LargeBuffer = array<char, 3 * kMaxSize>;
+ using LargeBuffer = Array<char, 3 * kMaxSize>;
LargeBuffer GroundTruth;
Randomize(GroundTruth);
for (int Size = 0; Size < kMaxSize; ++Size) {
#define LLVM_LIBC_USE_BUILTIN_MEMSET_INLINE 0
#include "utils/UnitTest/Test.h"
-#include <src/__support/CPP/array.h>
+#include <src/__support/CPP/Array.h>
#include <src/string/memory_utils/algorithm.h>
#include <src/string/memory_utils/backends.h>
namespace __llvm_libc {
-struct alignas(64) Buffer : cpp::array<char, 128> {
+struct alignas(64) Buffer : cpp::Array<char, 128> {
bool contains(const char *ptr) const {
return ptr >= data() && ptr < (data() + size());
}
//
//===----------------------------------------------------------------------===//
+#include "src/__support/CPP/Array.h"
#include "src/__support/CPP/ArrayRef.h"
#include "src/__support/CPP/Bit.h"
-#include "src/__support/CPP/array.h"
#include "src/__support/architectures.h"
#include "src/string/memory_utils/backends.h"
#include "utils/UnitTest/Test.h"
namespace __llvm_libc {
-template <size_t Size> using Buffer = cpp::array<char, Size>;
+template <size_t Size> using Buffer = cpp::Array<char, Size>;
static char GetRandomChar() {
// Implementation of C++ minstd_rand seeded with 123456789.
>;
TYPED_TEST(LlvmLibcMemoryBackend, splat, FunctionTypes) {
- for (auto value : cpp::array<uint8_t, 3>{0u, 1u, 255u}) {
+ for (auto value : cpp::Array<uint8_t, 3>{0u, 1u, 255u}) {
alignas(64) const auto stored = ParamType::splat(bit_cast<ubyte>(value));
for (size_t i = 0; i < ParamType::SIZE; ++i)
EXPECT_EQ(bit_cast<uint8_t>(stored[i]), value);
//
//===----------------------------------------------------------------------===//
+#include "src/__support/CPP/Array.h"
#include "src/__support/CPP/ArrayRef.h"
-#include "src/__support/CPP/array.h"
#include "src/string/memory_utils/elements.h"
#include "utils/UnitTest/Test.h"
current = GetRandomChar();
}
-template <typename Element> using Buffer = cpp::array<char, Element::SIZE>;
+template <typename Element> using Buffer = cpp::Array<char, Element::SIZE>;
template <typename Element> Buffer<Element> GetRandomBuffer() {
Buffer<Element> buffer;
TYPED_TEST(LlvmLibcMemoryElements, Move, FixedSizeTypes) {
constexpr size_t SIZE = ParamType::SIZE;
- using LargeBuffer = cpp::array<char, SIZE * 2>;
+ using LargeBuffer = cpp::Array<char, SIZE * 2>;
LargeBuffer GroundTruth;
Randomize(GroundTruth);
// Forward, we move the SIZE first bytes from offset 0 to SIZE.
TYPED_TEST(LlvmLibcMemoryElements, Splat, FixedSizeTypes) {
Buffer<ParamType> Dst;
- const cpp::array<char, 3> values = {char(0x00), char(0x7F), char(0xFF)};
+ const cpp::Array<char, 3> values = {char(0x00), char(0x7F), char(0xFF)};
for (char value : values) {
splat_set<ParamType>(Dst.data(), value);
for (size_t i = 0; i < ParamType::SIZE; ++i)
#define LLVM_LIBC_UNITTEST_OBSERVE 1
+#include "src/__support/CPP/Array.h"
#include "src/__support/CPP/ArrayRef.h"
-#include "src/__support/CPP/array.h"
#include "src/string/memory_utils/elements.h"
#include "utils/UnitTest/Test.h"
static constexpr const size_t kMaxBuffer = 32;
-struct BufferAccess : cpp::array<char, kMaxBuffer + 1> {
+struct BufferAccess : cpp::Array<char, kMaxBuffer + 1> {
BufferAccess() { Reset(); }
void Reset() {
for (auto &value : *this)
reads.Reset();
writes.Reset();
}
- cpp::array<char, kMaxBuffer> data;
+ cpp::Array<char, kMaxBuffer> data;
BufferAccess __attribute__((aligned(64))) reads;
BufferAccess __attribute__((aligned(64))) writes;
};
//
//===----------------------------------------------------------------------===//
-#include "src/__support/CPP/array.h"
+#include "src/__support/CPP/Array.h"
#include "src/string/memory_utils/utils.h"
#include "utils/UnitTest/Test.h"
namespace __llvm_libc {
TEST(LlvmLibcUtilsTest, IsPowerOfTwoOrZero) {
- static const cpp::array<bool, 65> kExpectedValues{
+ static const cpp::Array<bool, 65> kExpectedValues{
1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, // 0-15
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 16-31
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 32-47
}
TEST(LlvmLibcUtilsTest, IsPowerOfTwo) {
- static const cpp::array<bool, 65> kExpectedValues{
+ static const cpp::Array<bool, 65> kExpectedValues{
0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, // 0-15
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 16-31
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 32-47
}
TEST(LlvmLibcUtilsTest, Log2) {
- static const cpp::array<size_t, 65> kExpectedValues{
+ static const cpp::Array<size_t, 65> kExpectedValues{
0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, // 0-15
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, // 16-31
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, // 32-47
}
TEST(LlvmLibcUtilsTest, LEPowerOf2) {
- static const cpp::array<size_t, 65> kExpectedValues{
+ static const cpp::Array<size_t, 65> kExpectedValues{
0, 1, 2, 2, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8, 8, // 0-15
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, // 16-31
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, // 32-47
}
TEST(LlvmLibcUtilsTest, GEPowerOf2) {
- static const cpp::array<size_t, 66> kExpectedValues{
+ static const cpp::Array<size_t, 66> kExpectedValues{
0, 1, 2, 4, 4, 8, 8, 8, 8, 16, 16, 16, 16, 16, 16, 16, // 0-15
16, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, // 16-31
32, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, // 32-47
#include "src/string/memset.h"
#include "utils/UnitTest/Test.h"
-using __llvm_libc::cpp::array;
+using __llvm_libc::cpp::Array;
using __llvm_libc::cpp::ArrayRef;
-using Data = array<char, 2048>;
+using Data = Array<char, 2048>;
static const ArrayRef<char> k_deadcode("DEADC0DE", 8);
cc_library(
name = "__support_cpp_array",
- hdrs = ["src/__support/CPP/array.h"],
+ hdrs = ["src/__support/CPP/Array.h"],
deps = [":libc_root"],
)