Skip to content

Commit b6bc9d7

Browse files
authored
1 parent 7675f54 commit b6bc9d7

File tree

2,032 files changed

+8512
-8336
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,032 files changed

+8512
-8336
lines changed

libc/benchmarks/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ function(add_libc_multi_impl_benchmark name)
162162
get_target_property(entrypoint_object_file ${fq_config_name} "OBJECT_FILE_RAW")
163163
target_link_libraries(${benchmark_name} PUBLIC json ${entrypoint_object_file})
164164
string(TOUPPER ${name} name_upper)
165-
target_compile_definitions(${benchmark_name} PRIVATE "-DLIBC_BENCHMARK_FUNCTION_${name_upper}=__llvm_libc::${name}" "-DLIBC_BENCHMARK_FUNCTION_NAME=\"${fq_config_name}\"")
165+
target_compile_definitions(${benchmark_name} PRIVATE "-DLIBC_BENCHMARK_FUNCTION_${name_upper}=LIBC_NAMESPACE::${name}" "-DLIBC_BENCHMARK_FUNCTION_NAME=\"${fq_config_name}\"")
166166
llvm_update_compile_flags(${benchmark_name})
167167
else()
168168
message(STATUS "Skipping benchmark for '${fq_config_name}' insufficient host cpu features '${required_cpu_features}'")

libc/benchmarks/LibcDefaultImplementations.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include "llvm/ADT/ArrayRef.h"
33
#include <cstddef>
44

5-
namespace __llvm_libc {
5+
namespace LIBC_NAMESPACE {
66

77
extern void *memcpy(void *__restrict, const void *__restrict, size_t);
88
extern void *memmove(void *, const void *, size_t);
@@ -11,7 +11,7 @@ extern void bzero(void *, size_t);
1111
extern int memcmp(const void *, const void *, size_t);
1212
extern int bcmp(const void *, const void *, size_t);
1313

14-
} // namespace __llvm_libc
14+
} // namespace LIBC_NAMESPACE
1515

1616
// List of implementations to test.
1717

@@ -23,31 +23,31 @@ using llvm::libc_benchmarks::MemsetConfiguration;
2323

2424
llvm::ArrayRef<MemcpyConfiguration> getMemcpyConfigurations() {
2525
static constexpr MemcpyConfiguration kMemcpyConfigurations[] = {
26-
{__llvm_libc::memcpy, "__llvm_libc::memcpy"}};
26+
{LIBC_NAMESPACE::memcpy, "LIBC_NAMESPACE::memcpy"}};
2727
return llvm::ArrayRef(kMemcpyConfigurations);
2828
}
2929
llvm::ArrayRef<MemmoveConfiguration> getMemmoveConfigurations() {
3030
static constexpr MemmoveConfiguration kMemmoveConfigurations[] = {
31-
{__llvm_libc::memmove, "__llvm_libc::memmove"}};
31+
{LIBC_NAMESPACE::memmove, "LIBC_NAMESPACE::memmove"}};
3232
return llvm::ArrayRef(kMemmoveConfigurations);
3333
}
3434
llvm::ArrayRef<MemcmpOrBcmpConfiguration> getMemcmpConfigurations() {
3535
static constexpr MemcmpOrBcmpConfiguration kMemcmpConfiguration[] = {
36-
{__llvm_libc::memcmp, "__llvm_libc::memcmp"}};
36+
{LIBC_NAMESPACE::memcmp, "LIBC_NAMESPACE::memcmp"}};
3737
return llvm::ArrayRef(kMemcmpConfiguration);
3838
}
3939
llvm::ArrayRef<MemcmpOrBcmpConfiguration> getBcmpConfigurations() {
4040
static constexpr MemcmpOrBcmpConfiguration kBcmpConfigurations[] = {
41-
{__llvm_libc::bcmp, "__llvm_libc::bcmp"}};
41+
{LIBC_NAMESPACE::bcmp, "LIBC_NAMESPACE::bcmp"}};
4242
return llvm::ArrayRef(kBcmpConfigurations);
4343
}
4444
llvm::ArrayRef<MemsetConfiguration> getMemsetConfigurations() {
4545
static constexpr MemsetConfiguration kMemsetConfigurations[] = {
46-
{__llvm_libc::memset, "__llvm_libc::memset"}};
46+
{LIBC_NAMESPACE::memset, "LIBC_NAMESPACE::memset"}};
4747
return llvm::ArrayRef(kMemsetConfigurations);
4848
}
4949
llvm::ArrayRef<BzeroConfiguration> getBzeroConfigurations() {
5050
static constexpr BzeroConfiguration kBzeroConfigurations[] = {
51-
{__llvm_libc::bzero, "__llvm_libc::bzero"}};
51+
{LIBC_NAMESPACE::bzero, "LIBC_NAMESPACE::bzero"}};
5252
return llvm::ArrayRef(kBzeroConfigurations);
5353
}

libc/benchmarks/LibcMemoryBenchmark.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ namespace libc_benchmarks {
3232
struct StudyConfiguration {
3333
// One of 'memcpy', 'memset', 'memcmp'.
3434
// The underlying implementation is always the llvm libc one.
35-
// e.g. 'memcpy' will test '__llvm_libc::memcpy'
35+
// e.g. 'memcpy' will test 'LIBC_NAMESPACE::memcpy'
3636
std::string Function;
3737

3838
// The number of trials to run for this benchmark.

libc/benchmarks/LibcMemoryBenchmarkMain.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include <cstring>
2222
#include <unistd.h>
2323

24-
namespace __llvm_libc {
24+
namespace LIBC_NAMESPACE {
2525

2626
extern void *memcpy(void *__restrict, const void *__restrict, size_t);
2727
extern void *memmove(void *, const void *, size_t);
@@ -30,7 +30,7 @@ extern void bzero(void *, size_t);
3030
extern int memcmp(const void *, const void *, size_t);
3131
extern int bcmp(const void *, const void *, size_t);
3232

33-
} // namespace __llvm_libc
33+
} // namespace LIBC_NAMESPACE
3434

3535
namespace llvm {
3636
namespace libc_benchmarks {

libc/benchmarks/automemcpy/lib/CodeGen.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ namespace functions {
6262
// static void memcpy_0xB20D4702493C397E(char *__restrict dst,
6363
// const char *__restrict src,
6464
// size_t size) {
65-
// using namespace __llvm_libc::x86;
65+
// using namespace LIBC_NAMESPACE::x86;
6666
// if(size == 0) return;
6767
// if(size == 1) return copy<_1>(dst, src);
6868
// if(size < 4) return copy<HeadTail<_2>>(dst, src, size);
@@ -249,7 +249,7 @@ static raw_ostream &operator<<(raw_ostream &Stream,
249249
const auto &Ctx = FI.Ctx;
250250
Stream << "static " << Ctx.FunctionReturnType << ' ' << FI.Name
251251
<< Ctx.FunctionArgs << " {\n";
252-
Stream << kIndent << "using namespace __llvm_libc::" << FI.ElementClass
252+
Stream << kIndent << "using namespace LIBC_NAMESPACE::" << FI.ElementClass
253253
<< ";\n";
254254
for (const auto &I : FI.Individuals)
255255
if (I.Element.Size == 0)
@@ -428,7 +428,7 @@ namespace configurations {
428428
// ------------------------------------------------------------
429429
// e.g.
430430
// llvm::ArrayRef<MemcpyConfiguration> getMemcpyConfigurations() {
431-
// using namespace __llvm_libc;
431+
// using namespace LIBC_NAMESPACE;
432432
// static constexpr MemcpyConfiguration kConfigurations[] = {
433433
// {Wrap<memcpy_0xE00E29EE73994E2B>, "memcpy_0xE00E29EE73994E2B"},
434434
// {Wrap<memcpy_0x8661D80472487AB5>, "memcpy_0x8661D80472487AB5"},
@@ -504,7 +504,7 @@ static raw_ostream &operator<<(raw_ostream &Stream, const Configuration &C) {
504504
if (C.Descriptors.empty())
505505
Stream << kIndent << "return {};\n";
506506
else {
507-
Stream << kIndent << "using namespace __llvm_libc;\n";
507+
Stream << kIndent << "using namespace LIBC_NAMESPACE;\n";
508508
Stream << kIndent << "static constexpr " << C.Type
509509
<< " kConfigurations[] = {\n";
510510
Stream << C.Descriptors;
@@ -542,11 +542,11 @@ static void Serialize(raw_ostream &Stream,
542542
Stream << "using llvm::libc_benchmarks::MemmoveConfiguration;\n";
543543
Stream << "using llvm::libc_benchmarks::MemsetConfiguration;\n";
544544
Stream << "\n";
545-
Stream << "namespace __llvm_libc {\n";
545+
Stream << "namespace LIBC_NAMESPACE {\n";
546546
Stream << "\n";
547547
codegen::functions::Serialize(Stream, Descriptors);
548548
Stream << "\n";
549-
Stream << "} // namespace __llvm_libc\n";
549+
Stream << "} // namespace LIBC_NAMESPACE\n";
550550
Stream << "\n";
551551
Stream << "namespace llvm {\n";
552552
Stream << "namespace automemcpy {\n";

libc/benchmarks/automemcpy/unittests/CodeGenTest.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ using llvm::libc_benchmarks::MemcpyConfiguration;
6363
using llvm::libc_benchmarks::MemmoveConfiguration;
6464
using llvm::libc_benchmarks::MemsetConfiguration;
6565
66-
namespace __llvm_libc {
66+
namespace LIBC_NAMESPACE {
6767
6868
static void memcpy_0xE00E29EE73994E2B(char *__restrict dst, const char *__restrict src, size_t size) {
69-
using namespace __llvm_libc::x86;
69+
using namespace LIBC_NAMESPACE::x86;
7070
return copy<Accelerator>(dst, src, size);
7171
}
7272
static void memcpy_0x7381B60C7BE75EF9(char *__restrict dst, const char *__restrict src, size_t size) {
73-
using namespace __llvm_libc::x86;
73+
using namespace LIBC_NAMESPACE::x86;
7474
if(size == 0) return;
7575
if(size == 1) return copy<_1>(dst, src);
7676
if(size == 2) return copy<_2>(dst, src);
@@ -84,7 +84,7 @@ static void memcpy_0x7381B60C7BE75EF9(char *__restrict dst, const char *__restri
8484
return copy<Loop<_64>>(dst, src, size);
8585
}
8686
static int memcmp_0x348D7BA6DB0EE033(const char * lhs, const char * rhs, size_t size) {
87-
using namespace __llvm_libc::x86;
87+
using namespace LIBC_NAMESPACE::x86;
8888
if(size == 0) return 0;
8989
if(size == 1) return three_way_compare<_1>(lhs, rhs);
9090
if(size < 4) return three_way_compare<HeadTail<_2>>(lhs, rhs, size);
@@ -95,7 +95,7 @@ static int memcmp_0x348D7BA6DB0EE033(const char * lhs, const char * rhs, size_t
9595
return three_way_compare<Align<_16,Arg::Lhs>::Then<Loop<_16>>>(lhs, rhs, size);
9696
}
9797
static void memset_0x71E761699B999863(char * dst, int value, size_t size) {
98-
using namespace __llvm_libc::x86;
98+
using namespace LIBC_NAMESPACE::x86;
9999
if(size == 0) return;
100100
if(size == 1) return splat_set<_1>(dst, value);
101101
if(size < 4) return splat_set<HeadTail<_2>>(dst, value, size);
@@ -108,7 +108,7 @@ static void memset_0x71E761699B999863(char * dst, int value, size_t size) {
108108
return splat_set<Align<_16,Arg::Dst>::Then<Loop<_32>>>(dst, value, size);
109109
}
110110
static void memset_0x3DF0F44E2ED6A50F(char * dst, int value, size_t size) {
111-
using namespace __llvm_libc::x86;
111+
using namespace LIBC_NAMESPACE::x86;
112112
if(size == 0) return;
113113
if(size == 1) return splat_set<_1>(dst, value);
114114
if(size < 4) return splat_set<HeadTail<_2>>(dst, value, size);
@@ -121,7 +121,7 @@ static void memset_0x3DF0F44E2ED6A50F(char * dst, int value, size_t size) {
121121
return splat_set<Align<_32,Arg::Dst>::Then<Loop<_32>>>(dst, value, size);
122122
}
123123
static void bzero_0x475977492C218AD4(char * dst, size_t size) {
124-
using namespace __llvm_libc::x86;
124+
using namespace LIBC_NAMESPACE::x86;
125125
if(size == 0) return;
126126
if(size == 1) return splat_set<_1>(dst, 0);
127127
if(size == 2) return splat_set<_2>(dst, 0);
@@ -134,7 +134,7 @@ static void bzero_0x475977492C218AD4(char * dst, size_t size) {
134134
return splat_set<Align<_32,Arg::Dst>::Then<Loop<_32>>>(dst, 0, size);
135135
}
136136
137-
} // namespace __llvm_libc
137+
} // namespace LIBC_NAMESPACE
138138
139139
namespace llvm {
140140
namespace automemcpy {
@@ -163,7 +163,7 @@ void *Wrap(void *__restrict dst, const void *__restrict src, size_t size) {
163163
return dst;
164164
}
165165
llvm::ArrayRef<MemcpyConfiguration> getMemcpyConfigurations() {
166-
using namespace __llvm_libc;
166+
using namespace LIBC_NAMESPACE;
167167
static constexpr MemcpyConfiguration kConfigurations[] = {
168168
{Wrap<memcpy_0xE00E29EE73994E2B>, "memcpy_0xE00E29EE73994E2B"},
169169
{Wrap<memcpy_0x7381B60C7BE75EF9>, "memcpy_0x7381B60C7BE75EF9"},
@@ -178,7 +178,7 @@ int Wrap(const void *lhs, const void *rhs, size_t size) {
178178
reinterpret_cast<const char *>(rhs), size);
179179
}
180180
llvm::ArrayRef<MemcmpOrBcmpConfiguration> getMemcmpConfigurations() {
181-
using namespace __llvm_libc;
181+
using namespace LIBC_NAMESPACE;
182182
static constexpr MemcmpOrBcmpConfiguration kConfigurations[] = {
183183
{Wrap<memcmp_0x348D7BA6DB0EE033>, "memcmp_0x348D7BA6DB0EE033"},
184184
};
@@ -194,7 +194,7 @@ template <MemsetStub Foo> void *Wrap(void *dst, int value, size_t size) {
194194
return dst;
195195
}
196196
llvm::ArrayRef<MemsetConfiguration> getMemsetConfigurations() {
197-
using namespace __llvm_libc;
197+
using namespace LIBC_NAMESPACE;
198198
static constexpr MemsetConfiguration kConfigurations[] = {
199199
{Wrap<memset_0x71E761699B999863>, "memset_0x71E761699B999863"},
200200
{Wrap<memset_0x3DF0F44E2ED6A50F>, "memset_0x3DF0F44E2ED6A50F"},
@@ -207,7 +207,7 @@ template <BzeroStub Foo> void Wrap(void *dst, size_t size) {
207207
Foo(reinterpret_cast<char *>(dst), size);
208208
}
209209
llvm::ArrayRef<BzeroConfiguration> getBzeroConfigurations() {
210-
using namespace __llvm_libc;
210+
using namespace LIBC_NAMESPACE;
211211
static constexpr BzeroConfiguration kConfigurations[] = {
212212
{Wrap<bzero_0x475977492C218AD4>, "bzero_0x475977492C218AD4"},
213213
};

libc/config/linux/app.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
#include <stdint.h>
1515

16-
namespace __llvm_libc {
16+
namespace LIBC_NAMESPACE {
1717

1818
// Data structure to capture properties of the linux/ELF TLS image.
1919
struct TLSImage {
@@ -106,6 +106,6 @@ void init_tls(TLSDescriptor &tls);
106106
// Cleanup the TLS area as described in |tls_descriptor|.
107107
void cleanup_tls(uintptr_t tls_addr, uintptr_t tls_size);
108108

109-
} // namespace __llvm_libc
109+
} // namespace LIBC_NAMESPACE
110110

111111
#endif // LLVM_LIBC_CONFIG_LINUX_APP_H

libc/docs/dev/clang_tidy_checks.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,19 @@ implementation-in-namespace
3030
---------------------------
3131

3232
It is part of our implementation standards that all implementation pieces live
33-
under the ``__llvm_libc`` namespace. This prevents pollution of the global
33+
under the ``LIBC_NAMESPACE`` namespace. This prevents pollution of the global
3434
namespace. Without a formal check to ensure this, an implementation might
3535
compile and pass unit tests, but not produce a usable libc function.
3636

3737
This check that ensures any function call resolves to a function within the
38-
``__llvm_libc`` namespace.
38+
``LIBC_NAMESPACE`` namespace.
3939

4040
.. code-block:: c++
4141

4242
// Correct: implementation inside the correct namespace.
43-
namespace __llvm_libc {
43+
namespace LIBC_NAMESPACE {
4444
void LLVM_LIBC_ENTRYPOINT(strcpy)(char *dest, const char *src) {}
45-
// Namespaces within __llvm_libc namespace are allowed.
45+
// Namespaces within LIBC_NAMESPACE namespace are allowed.
4646
namespace inner{
4747
int localVar = 0;
4848
}
@@ -67,7 +67,7 @@ creates some uncertainty about which library a call resolves to especially when
6767
a public header with non-namespaced functions like ``string.h`` is included.
6868

6969
This check ensures any function call resolves to a function within the
70-
__llvm_libc namespace.
70+
LIBC_NAMESPACE namespace.
7171

7272
There are exceptions for the following functions:
7373
``__errno_location`` so that ``errno`` can be set;
@@ -76,10 +76,10 @@ are always external and can be intercepted.
7676

7777
.. code-block:: c++
7878

79-
namespace __llvm_libc {
79+
namespace LIBC_NAMESPACE {
8080

8181
// Allow calls with the fully qualified name.
82-
__llvm_libc::strlen("hello");
82+
LIBC_NAMESPACE::strlen("hello");
8383

8484
// Allow calls to compiler provided functions.
8585
(void)__builtin_abs(-1);
@@ -93,4 +93,4 @@ are always external and can be intercepted.
9393
// Allow calling into specific global functions (explained above)
9494
::malloc(10);
9595

96-
} // namespace __llvm_libc
96+
} // namespace LIBC_NAMESPACE

libc/docs/dev/code_style.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ this:
158158

159159
...
160160

161-
__llvm_libc::AllocChecker ac;
161+
LIBC_NAMESPACE::AllocChecker ac;
162162
auto *obj = new (ac) Type(...);
163163
if (!ac) {
164164
// handle allocator failure.

libc/docs/dev/implementation_standard.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,17 @@ example. The ``round`` function will be declared in an internal header file
3333
#ifndef LLVM_LIBC_SRC_MATH_ROUND_ROUND_H
3434
#define LLVM_LIBC_SRC_MATH_ROUND_ROUND_H
3535

36-
namespace __llvm_libc {
36+
namespace LIBC_NAMESPACE {
3737

3838
double round(double);
3939

40-
} // namespace __llvm_libc
40+
} // namespace LIBC_NAMESPACE
4141

4242
#endif LLVM_LIBC_SRC_MATH_ROUND_ROUND_H
4343

4444
Notice that the ``round`` function declaration is nested inside the namespace
45-
``__llvm_libc``. All implementation constructs in LLVM-libc are declared within
46-
the namespace ``__llvm_libc``.
45+
``LIBC_NAMESPACE``. All implementation constructs in LLVM-libc are declared within
46+
the namespace ``LIBC_NAMESPACE``.
4747

4848
``.cpp`` File Structure
4949
-----------------------
@@ -55,13 +55,13 @@ the entrypoint function should make use of a special macro. For example, the
5555

5656
// --- round.cpp --- //
5757

58-
namespace __llvm_libc {
58+
namespace LIBC_NAMESPACE {
5959

6060
double LLVM_LIBC_ENTRYPOINT(round)(double d) {
6161
// ... implementation goes here.
6262
}
6363

64-
} // namespace __llvm_libc
64+
} // namespace LIBC_NAMESPACE
6565

6666
Notice the use of the macro ``LLVM_LIBC_ENTRYPOINT``. This macro helps us define
6767
an C alias symbol for the C++ implementation. The C alias need not be added by

libc/fuzzing/math/Compare.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313
#include "src/__support/FPUtil/FPBits.h"
1414

1515
template <typename T>
16-
__llvm_libc::cpp::enable_if_t<__llvm_libc::cpp::is_floating_point_v<T>, bool>
16+
LIBC_NAMESPACE::cpp::enable_if_t<LIBC_NAMESPACE::cpp::is_floating_point_v<T>,
17+
bool>
1718
ValuesEqual(T x1, T x2) {
18-
__llvm_libc::fputil::FPBits<T> bits1(x1);
19-
__llvm_libc::fputil::FPBits<T> bits2(x2);
19+
LIBC_NAMESPACE::fputil::FPBits<T> bits1(x1);
20+
LIBC_NAMESPACE::fputil::FPBits<T> bits2(x2);
2021
// If either is NaN, we want both to be NaN.
2122
if (bits1.is_nan() || bits2.is_nan())
2223
return bits2.is_nan() && bits2.is_nan();
@@ -26,7 +27,7 @@ ValuesEqual(T x1, T x2) {
2627
}
2728

2829
template <typename T>
29-
__llvm_libc::cpp::enable_if_t<__llvm_libc::cpp::is_integral_v<T>, bool>
30+
LIBC_NAMESPACE::cpp::enable_if_t<LIBC_NAMESPACE::cpp::is_integral_v<T>, bool>
3031
ValuesEqual(T x1, T x2) {
3132
return x1 == x2;
3233
}

libc/fuzzing/math/RemQuoDiff.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ void RemQuoDiff(RemQuoFunc<T> func1, RemQuoFunc<T> func2, const uint8_t *data,
4444
if ((q1 & 0x7) != (q2 & 0x7))
4545
__builtin_trap();
4646

47-
__llvm_libc::fputil::FPBits<T> bits1(remainder1);
48-
__llvm_libc::fputil::FPBits<T> bits2(remainder2);
47+
LIBC_NAMESPACE::fputil::FPBits<T> bits1(remainder1);
48+
LIBC_NAMESPACE::fputil::FPBits<T> bits2(remainder2);
4949
if (bits1.uintval() != bits2.uintval())
5050
__builtin_trap();
5151
}

0 commit comments

Comments
 (0)