forked from OSchip/llvm-project
Revert "[libc][NFC] Use STL case for array"
This reverts commit 7add0e5fdc
.
This commit is contained in:
parent
7add0e5fdc
commit
de00bd573e
|
@ -14,8 +14,8 @@
|
|||
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];
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
#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.
|
||||
|
@ -120,8 +120,8 @@ public:
|
|||
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>
|
||||
|
@ -139,8 +139,8 @@ public:
|
|||
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());
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
add_header_library(
|
||||
array
|
||||
HDRS
|
||||
array.h
|
||||
Array.h
|
||||
)
|
||||
|
||||
add_header_library(
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#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>
|
||||
|
@ -44,7 +44,7 @@ public:
|
|||
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];
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ public:
|
|||
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]);
|
||||
|
@ -123,7 +123,7 @@ public:
|
|||
}
|
||||
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) {
|
||||
|
|
|
@ -65,7 +65,7 @@ TYPED_TEST(LlvmLibcArrayRefTest, ConstructFromCArray, Types) {
|
|||
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));
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "src/__support/CPP/Array.h"
|
||||
#include "src/__support/FPUtil/FPBits.h"
|
||||
#include "src/math/cosf.h"
|
||||
#include "test/src/math/sdcomp26094.h"
|
||||
|
|
|
@ -9,14 +9,14 @@
|
|||
#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,
|
||||
};
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "src/__support/CPP/Array.h"
|
||||
#include "src/__support/FPUtil/FPBits.h"
|
||||
#include "src/math/sincosf.h"
|
||||
#include "test/src/math/sdcomp26094.h"
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "src/__support/CPP/Array.h"
|
||||
#include "src/__support/FPUtil/FPBits.h"
|
||||
#include "src/math/sinf.h"
|
||||
#include "test/src/math/sdcomp26094.h"
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#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"
|
||||
|
@ -40,7 +40,7 @@ TEST(LlvmLibcAtExit, AtExitCallsSysExit) {
|
|||
}
|
||||
|
||||
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...>) {
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
#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);
|
||||
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
#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);
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#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;
|
||||
|
||||
|
@ -92,7 +92,7 @@ void Randomize(MutableArrayRef<char> Buffer) {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#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>
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
|||
|
||||
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());
|
||||
}
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#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"
|
||||
|
@ -16,7 +16,7 @@
|
|||
|
||||
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.
|
||||
|
@ -84,7 +84,7 @@ using FunctionTypes = testing::TypeList< //
|
|||
>;
|
||||
|
||||
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);
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#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"
|
||||
|
||||
|
@ -56,7 +56,7 @@ void Randomize(cpp::MutableArrayRef<char> buffer) {
|
|||
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;
|
||||
|
@ -81,7 +81,7 @@ template <typename T> T copy(const T &Input) {
|
|||
|
||||
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.
|
||||
|
@ -126,7 +126,7 @@ TYPED_TEST(LlvmLibcMemoryElements, three_way_compare, FixedSizeTypes) {
|
|||
|
||||
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)
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
#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"
|
||||
|
||||
|
@ -20,7 +20,7 @@ namespace __llvm_libc {
|
|||
|
||||
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)
|
||||
|
@ -45,7 +45,7 @@ struct Buffer {
|
|||
reads.Reset();
|
||||
writes.Reset();
|
||||
}
|
||||
cpp::array<char, kMaxBuffer> data;
|
||||
cpp::Array<char, kMaxBuffer> data;
|
||||
BufferAccess __attribute__((aligned(64))) reads;
|
||||
BufferAccess __attribute__((aligned(64))) writes;
|
||||
};
|
||||
|
|
|
@ -6,14 +6,14 @@
|
|||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#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
|
||||
|
@ -25,7 +25,7 @@ TEST(LlvmLibcUtilsTest, IsPowerOfTwoOrZero) {
|
|||
}
|
||||
|
||||
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
|
||||
|
@ -37,7 +37,7 @@ TEST(LlvmLibcUtilsTest, IsPowerOfTwo) {
|
|||
}
|
||||
|
||||
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
|
||||
|
@ -49,7 +49,7 @@ TEST(LlvmLibcUtilsTest, Log2) {
|
|||
}
|
||||
|
||||
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
|
||||
|
@ -61,7 +61,7 @@ TEST(LlvmLibcUtilsTest, LEPowerOf2) {
|
|||
}
|
||||
|
||||
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
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
#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);
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ cc_library(
|
|||
|
||||
cc_library(
|
||||
name = "__support_cpp_array",
|
||||
hdrs = ["src/__support/CPP/array.h"],
|
||||
hdrs = ["src/__support/CPP/Array.h"],
|
||||
deps = [":libc_root"],
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue