Skip to content

Commit

Permalink
[libc] Migrate to using LIBC_NAMESPACE_DECL for namespace declaration
Browse files Browse the repository at this point in the history
This is a part of #97655.
  • Loading branch information
petrhosek committed Jul 8, 2024
1 parent 73447a3 commit 7ce5682
Show file tree
Hide file tree
Showing 2,300 changed files with 4,820 additions and 4,610 deletions.
4 changes: 2 additions & 2 deletions libc/benchmarks/LibcDefaultImplementations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "llvm/ADT/ArrayRef.h"
#include <cstddef>

namespace LIBC_NAMESPACE {
namespace LIBC_NAMESPACE_DECL {

extern void *memcpy(void *__restrict, const void *__restrict, size_t);
extern void *memmove(void *, const void *, size_t);
Expand All @@ -11,7 +11,7 @@ extern void bzero(void *, size_t);
extern int memcmp(const void *, const void *, size_t);
extern int bcmp(const void *, const void *, size_t);

} // namespace LIBC_NAMESPACE
} // namespace LIBC_NAMESPACE_DECL

// List of implementations to test.

Expand Down
4 changes: 2 additions & 2 deletions libc/benchmarks/LibcMemoryBenchmarkMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <cstring>
#include <unistd.h>

namespace LIBC_NAMESPACE {
namespace LIBC_NAMESPACE_DECL {

extern void *memcpy(void *__restrict, const void *__restrict, size_t);
extern void *memmove(void *, const void *, size_t);
Expand All @@ -30,7 +30,7 @@ extern void bzero(void *, size_t);
extern int memcmp(const void *, const void *, size_t);
extern int bcmp(const void *, const void *, size_t);

} // namespace LIBC_NAMESPACE
} // namespace LIBC_NAMESPACE_DECL

namespace llvm {
namespace libc_benchmarks {
Expand Down
4 changes: 2 additions & 2 deletions libc/benchmarks/automemcpy/lib/CodeGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -542,11 +542,11 @@ static void Serialize(raw_ostream &Stream,
Stream << "using llvm::libc_benchmarks::MemmoveConfiguration;\n";
Stream << "using llvm::libc_benchmarks::MemsetConfiguration;\n";
Stream << "\n";
Stream << "namespace LIBC_NAMESPACE {\n";
Stream << "namespace LIBC_NAMESPACE_DECL {\n";
Stream << "\n";
codegen::functions::Serialize(Stream, Descriptors);
Stream << "\n";
Stream << "} // namespace LIBC_NAMESPACE\n";
Stream << "} // namespace LIBC_NAMESPACE_DECL\n";
Stream << "\n";
Stream << "namespace llvm {\n";
Stream << "namespace automemcpy {\n";
Expand Down
4 changes: 2 additions & 2 deletions libc/benchmarks/automemcpy/unittests/CodeGenTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ using llvm::libc_benchmarks::MemcpyConfiguration;
using llvm::libc_benchmarks::MemmoveConfiguration;
using llvm::libc_benchmarks::MemsetConfiguration;
namespace LIBC_NAMESPACE {
namespace LIBC_NAMESPACE_DECL {
static void memcpy_0xE00E29EE73994E2B(char *__restrict dst, const char *__restrict src, size_t size) {
using namespace LIBC_NAMESPACE::x86;
Expand Down Expand Up @@ -134,7 +134,7 @@ static void bzero_0x475977492C218AD4(char * dst, size_t size) {
return splat_set<Align<_32,Arg::Dst>::Then<Loop<_32>>>(dst, 0, size);
}
} // namespace LIBC_NAMESPACE
} // namespace LIBC_NAMESPACE_DECL
namespace llvm {
namespace automemcpy {
Expand Down
4 changes: 2 additions & 2 deletions libc/benchmarks/gpu/BenchmarkLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <stdint.h>

namespace LIBC_NAMESPACE {
namespace LIBC_NAMESPACE_DECL {
namespace benchmarks {

// cpp::string_view specialization
Expand Down Expand Up @@ -94,4 +94,4 @@ template BenchmarkLogger &BenchmarkLogger::operator<< <UInt<320>>(UInt<320>);
BenchmarkLogger log;

} // namespace benchmarks
} // namespace LIBC_NAMESPACE
} // namespace LIBC_NAMESPACE_DECL
4 changes: 2 additions & 2 deletions libc/benchmarks/gpu/BenchmarkLogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#ifndef LLVM_LIBC_BENCHMARKS_GPU_BENCHMARKLOGGER_H
#define LLVM_LIBC_BENCHMARKS_GPU_BENCHMARKLOGGER_H

namespace LIBC_NAMESPACE {
namespace LIBC_NAMESPACE_DECL {
namespace benchmarks {

// A class to log to standard output in the context of hermetic tests.
Expand All @@ -22,6 +22,6 @@ struct BenchmarkLogger {
extern BenchmarkLogger log;

} // namespace benchmarks
} // namespace LIBC_NAMESPACE
} // namespace LIBC_NAMESPACE_DECL

#endif /* LLVM_LIBC_BENCHMARKS_GPU_BENCHMARKLOGGER_H */
4 changes: 2 additions & 2 deletions libc/benchmarks/gpu/LibcGpuBenchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "src/__support/fixedvector.h"
#include "src/time/gpu/time_utils.h"

namespace LIBC_NAMESPACE {
namespace LIBC_NAMESPACE_DECL {
namespace benchmarks {

FixedVector<Benchmark *, 64> benchmarks;
Expand Down Expand Up @@ -136,4 +136,4 @@ BenchmarkResult benchmark(const BenchmarkOptions &options,
};

} // namespace benchmarks
} // namespace LIBC_NAMESPACE
} // namespace LIBC_NAMESPACE_DECL
4 changes: 2 additions & 2 deletions libc/benchmarks/gpu/LibcGpuBenchmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include <stdint.h>

namespace LIBC_NAMESPACE {
namespace LIBC_NAMESPACE_DECL {

namespace benchmarks {

Expand Down Expand Up @@ -99,7 +99,7 @@ class Benchmark {
const cpp::string_view get_name() const { return name; }
};
} // namespace benchmarks
} // namespace LIBC_NAMESPACE
} // namespace LIBC_NAMESPACE_DECL

#define BENCHMARK(SuiteName, TestName, Func) \
LIBC_NAMESPACE::benchmarks::Benchmark SuiteName##_##TestName##_Instance( \
Expand Down
4 changes: 2 additions & 2 deletions libc/benchmarks/gpu/timing/nvptx/timing.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include <stdint.h>

namespace LIBC_NAMESPACE {
namespace LIBC_NAMESPACE_DECL {

// Returns the overhead associated with calling the profiling region. This
// allows us to substract the constant-time overhead from the latency to
Expand Down Expand Up @@ -94,6 +94,6 @@ static LIBC_INLINE uint64_t latency(F f, T1 t1, T2 t2) {

return stop - start;
}
} // namespace LIBC_NAMESPACE
} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_UTILS_GPU_TIMING_NVPTX
4 changes: 2 additions & 2 deletions libc/config/linux/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

#include <stdint.h>

namespace LIBC_NAMESPACE {
namespace LIBC_NAMESPACE_DECL {

// Data structure to capture properties of the linux/ELF TLS image.
struct TLSImage {
Expand Down Expand Up @@ -104,6 +104,6 @@ void cleanup_tls(uintptr_t tls_addr, uintptr_t tls_size);
// Set the thread pointer for the current thread.
bool set_thread_ptr(uintptr_t val);

} // namespace LIBC_NAMESPACE
} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_CONFIG_LINUX_APP_H
4 changes: 2 additions & 2 deletions libc/fuzzing/__support/hashtable_fuzz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "src/__support/CPP/string_view.h"
#include "src/__support/HashTable/table.h"

namespace LIBC_NAMESPACE {
namespace LIBC_NAMESPACE_DECL {

// A fuzzing payload starts with
// - uint16_t: initial capacity for table A
Expand Down Expand Up @@ -179,4 +179,4 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
return 0;
}

} // namespace LIBC_NAMESPACE
} // namespace LIBC_NAMESPACE_DECL
4 changes: 2 additions & 2 deletions libc/src/__support/CPP/algorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#include "src/__support/macros/attributes.h" // LIBC_INLINE

namespace LIBC_NAMESPACE {
namespace LIBC_NAMESPACE_DECL {
namespace cpp {

template <class T> LIBC_INLINE constexpr const T &max(const T &a, const T &b) {
Expand All @@ -41,6 +41,6 @@ LIBC_INLINE constexpr bool all_of(InputIt first, InputIt last, UnaryPred p) {
}

} // namespace cpp
} // namespace LIBC_NAMESPACE
} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC___SUPPORT_CPP_ALGORITHM_H
4 changes: 2 additions & 2 deletions libc/src/__support/CPP/array.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "src/__support/macros/attributes.h"
#include <stddef.h> // For size_t.

namespace LIBC_NAMESPACE {
namespace LIBC_NAMESPACE_DECL {
namespace cpp {

template <class T, size_t N> struct array {
Expand Down Expand Up @@ -74,6 +74,6 @@ template <class T, size_t N> struct array {
};

} // namespace cpp
} // namespace LIBC_NAMESPACE
} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC___SUPPORT_CPP_ARRAY_H
4 changes: 2 additions & 2 deletions libc/src/__support/CPP/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#include "type_traits.h"

namespace LIBC_NAMESPACE {
namespace LIBC_NAMESPACE_DECL {
namespace cpp {

enum class MemoryOrder : int {
Expand Down Expand Up @@ -211,6 +211,6 @@ LIBC_INLINE void atomic_signal_fence([[maybe_unused]] MemoryOrder mem_ord) {
}

} // namespace cpp
} // namespace LIBC_NAMESPACE
} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC___SUPPORT_CPP_ATOMIC_H
6 changes: 4 additions & 2 deletions libc/src/__support/CPP/bit.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@

#include <stdint.h>

namespace LIBC_NAMESPACE::cpp {
namespace LIBC_NAMESPACE_DECL {
namespace cpp {

#if __has_builtin(__builtin_memcpy_inline)
#define LLVM_LIBC_HAS_BUILTIN_MEMCPY_INLINE
Expand Down Expand Up @@ -290,6 +291,7 @@ ADD_SPECIALIZATION(unsigned long long, __builtin_popcountll)
#endif // __builtin_popcountg
#undef ADD_SPECIALIZATION

} // namespace LIBC_NAMESPACE::cpp
} // namespace cpp
} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC___SUPPORT_CPP_BIT_H
6 changes: 4 additions & 2 deletions libc/src/__support/CPP/bitset.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
#include "src/__support/macros/attributes.h"
#include <stddef.h> // For size_t.

namespace LIBC_NAMESPACE::cpp {
namespace LIBC_NAMESPACE_DECL {
namespace cpp {

template <size_t NumberOfBits> struct bitset {
static_assert(NumberOfBits != 0,
Expand Down Expand Up @@ -86,6 +87,7 @@ template <size_t NumberOfBits> struct bitset {
size_t Data[NUMBER_OF_UNITS] = {0};
};

} // namespace LIBC_NAMESPACE::cpp
} // namespace cpp
} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC___SUPPORT_CPP_BITSET_H
6 changes: 4 additions & 2 deletions libc/src/__support/CPP/cstddef.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
#include "src/__support/macros/attributes.h"
#include "type_traits.h" // For enable_if_t, is_integral_v.

namespace LIBC_NAMESPACE::cpp {
namespace LIBC_NAMESPACE_DECL {
namespace cpp {

enum class byte : unsigned char {};

Expand Down Expand Up @@ -66,6 +67,7 @@ to_integer(byte b) noexcept {
return static_cast<IntegerType>(b);
}

} // namespace LIBC_NAMESPACE::cpp
} // namespace cpp
} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC___SUPPORT_CPP_CSTDDEF_H
6 changes: 4 additions & 2 deletions libc/src/__support/CPP/expected.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

#include "src/__support/macros/attributes.h"

namespace LIBC_NAMESPACE::cpp {
namespace LIBC_NAMESPACE_DECL {
namespace cpp {

// This is used to hold an unexpected value so that a different constructor is
// selected.
Expand Down Expand Up @@ -52,6 +53,7 @@ template <class T, class E> class expected {
LIBC_INLINE constexpr const T *operator->() const { return &exp; }
};

} // namespace LIBC_NAMESPACE::cpp
} // namespace cpp
} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC___SUPPORT_CPP_EXPECTED_H
4 changes: 2 additions & 2 deletions libc/src/__support/CPP/functional.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include <stdint.h>

namespace LIBC_NAMESPACE {
namespace LIBC_NAMESPACE_DECL {
namespace cpp {

/// A function type adapted from LLVM's function_ref.
Expand Down Expand Up @@ -65,6 +65,6 @@ template <typename Ret, typename... Params> class function<Ret(Params...)> {
};

} // namespace cpp
} // namespace LIBC_NAMESPACE
} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC___SUPPORT_CPP_FUNCTIONAL_H
4 changes: 2 additions & 2 deletions libc/src/__support/CPP/iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "src/__support/CPP/type_traits/is_same.h"
#include "src/__support/macros/attributes.h"

namespace LIBC_NAMESPACE {
namespace LIBC_NAMESPACE_DECL {
namespace cpp {

template <typename T> struct iterator_traits;
Expand Down Expand Up @@ -93,6 +93,6 @@ template <typename Iter> class reverse_iterator {
};

} // namespace cpp
} // namespace LIBC_NAMESPACE
} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC___SUPPORT_CPP_ITERATOR_H
4 changes: 2 additions & 2 deletions libc/src/__support/CPP/limits.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "src/__support/macros/attributes.h" // LIBC_INLINE
#include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_INT128

namespace LIBC_NAMESPACE {
namespace LIBC_NAMESPACE_DECL {
namespace cpp {

namespace internal {
Expand Down Expand Up @@ -86,6 +86,6 @@ struct numeric_limits<__uint128_t>
#endif

} // namespace cpp
} // namespace LIBC_NAMESPACE
} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC___SUPPORT_CPP_LIMITS_H
4 changes: 2 additions & 2 deletions libc/src/__support/CPP/mutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_MUTEX_H
#define LLVM_LIBC_SRC___SUPPORT_CPP_MUTEX_H

namespace LIBC_NAMESPACE {
namespace LIBC_NAMESPACE_DECL {
namespace cpp {

// Assume the calling thread has already obtained mutex ownership.
Expand Down Expand Up @@ -44,6 +44,6 @@ template <typename MutexType> class lock_guard {
template <typename T> lock_guard(T &) -> lock_guard<T>;

} // namespace cpp
} // namespace LIBC_NAMESPACE
} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC___SUPPORT_CPP_MUTEX_H
4 changes: 2 additions & 2 deletions libc/src/__support/CPP/new.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ enum class align_val_t : size_t {};

} // namespace std

namespace LIBC_NAMESPACE {
namespace LIBC_NAMESPACE_DECL {

class AllocChecker {
bool success = false;
Expand Down Expand Up @@ -52,7 +52,7 @@ class AllocChecker {
}
};

} // namespace LIBC_NAMESPACE
} // namespace LIBC_NAMESPACE_DECL

LIBC_INLINE void *operator new(size_t size,
LIBC_NAMESPACE::AllocChecker &ac) noexcept {
Expand Down
Loading

0 comments on commit 7ce5682

Please sign in to comment.