Skip to content

Commit

Permalink
Revert "[libc] Migrate to using LIBC_NAMESPACE_DECL for namespace dec…
Browse files Browse the repository at this point in the history
…laration" (llvm#98593)

Reverts llvm#98075

bots are broken
  • Loading branch information
joker-eph authored and aaryanshukla committed Jul 14, 2024
1 parent 9e8d007 commit 1f0fa99
Show file tree
Hide file tree
Showing 2,327 changed files with 4,678 additions and 7,567 deletions.
5 changes: 2 additions & 3 deletions libc/benchmarks/LibcDefaultImplementations.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#include "LibcFunctionPrototypes.h"
#include "src/__support/macros/config.h"
#include "llvm/ADT/ArrayRef.h"
#include <cstddef>

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

extern void *memcpy(void *__restrict, const void *__restrict, size_t);
extern void *memmove(void *, const void *, size_t);
Expand All @@ -12,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_DECL
} // namespace LIBC_NAMESPACE

// List of implementations to test.

Expand Down
5 changes: 2 additions & 3 deletions libc/benchmarks/LibcMemoryBenchmarkMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "LibcBenchmark.h"
#include "LibcMemoryBenchmark.h"
#include "MemorySizeDistributions.h"
#include "src/__support/macros/config.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FileSystem.h"
Expand All @@ -22,7 +21,7 @@
#include <cstring>
#include <unistd.h>

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

extern void *memcpy(void *__restrict, const void *__restrict, size_t);
extern void *memmove(void *, const void *, size_t);
Expand All @@ -31,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_DECL
} // namespace LIBC_NAMESPACE

namespace llvm {
namespace libc_benchmarks {
Expand Down
5 changes: 2 additions & 3 deletions libc/benchmarks/automemcpy/lib/CodeGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
// function at the end of the file.

#include "automemcpy/CodeGen.h"
#include "src/__support/macros/config.h"
#include <cassert>
#include <llvm/ADT/STLExtras.h>
#include <llvm/ADT/StringSet.h>
Expand Down Expand Up @@ -543,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_DECL {\n";
Stream << "namespace LIBC_NAMESPACE {\n";
Stream << "\n";
codegen::functions::Serialize(Stream, Descriptors);
Stream << "\n";
Stream << "} // namespace LIBC_NAMESPACE_DECL\n";
Stream << "} // namespace LIBC_NAMESPACE\n";
Stream << "\n";
Stream << "namespace llvm {\n";
Stream << "namespace automemcpy {\n";
Expand Down
5 changes: 2 additions & 3 deletions libc/benchmarks/automemcpy/unittests/CodeGenTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#include "automemcpy/CodeGen.h"
#include "automemcpy/RandomFunctionGenerator.h"
#include "src/__support/macros/config.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include <optional>
Expand Down Expand Up @@ -64,7 +63,7 @@ using llvm::libc_benchmarks::MemcpyConfiguration;
using llvm::libc_benchmarks::MemmoveConfiguration;
using llvm::libc_benchmarks::MemsetConfiguration;
namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {
static void memcpy_0xE00E29EE73994E2B(char *__restrict dst, const char *__restrict src, size_t size) {
using namespace LIBC_NAMESPACE::x86;
Expand Down Expand Up @@ -135,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_DECL
} // namespace LIBC_NAMESPACE
namespace llvm {
namespace automemcpy {
Expand Down
5 changes: 2 additions & 3 deletions libc/benchmarks/gpu/BenchmarkLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
#include "src/__support/CPP/string_view.h"
#include "src/__support/OSUtil/io.h" // write_to_stderr
#include "src/__support/big_int.h" // is_big_int
#include "src/__support/macros/config.h"
#include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_INT128
#include "src/__support/uint128.h"

#include <stdint.h>

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {
namespace benchmarks {

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

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

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {
namespace benchmarks {

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

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

#endif /* LLVM_LIBC_BENCHMARKS_GPU_BENCHMARKLOGGER_H */
5 changes: 2 additions & 3 deletions libc/benchmarks/gpu/LibcGpuBenchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
#include "src/__support/FPUtil/sqrt.h"
#include "src/__support/GPU/utils.h"
#include "src/__support/fixedvector.h"
#include "src/__support/macros/config.h"
#include "src/time/gpu/time_utils.h"

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {
namespace benchmarks {

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

} // namespace benchmarks
} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE
5 changes: 2 additions & 3 deletions libc/benchmarks/gpu/LibcGpuBenchmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
#include "src/__support/CPP/functional.h"
#include "src/__support/CPP/limits.h"
#include "src/__support/CPP/string_view.h"
#include "src/__support/macros/config.h"
#include "src/time/clock.h"

#include <stdint.h>

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

namespace benchmarks {

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

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

// 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 @@ -107,6 +107,6 @@ template <typename F, typename T1, typename T2>
return stop - start;
}

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_UTILS_GPU_TIMING_AMDGPU
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_DECL {
namespace LIBC_NAMESPACE {

// 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_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_UTILS_GPU_TIMING_NVPTX
10 changes: 5 additions & 5 deletions libc/cmake/modules/LLVMLibCObjectRules.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ function(create_object_library fq_target_name)
endif()
endif()

list(APPEND fq_deps_list libc.src.__support.macros.config)
list(REMOVE_DUPLICATES fq_deps_list)
add_dependencies(${fq_target_name} ${fq_deps_list})
# Add deps as link libraries to inherit interface compile and link options.
target_link_libraries(${fq_target_name} PUBLIC ${fq_deps_list})
if(fq_deps_list)
add_dependencies(${fq_target_name} ${fq_deps_list})
# Add deps as link libraries to inherit interface compile and link options.
target_link_libraries(${fq_target_name} PUBLIC ${fq_deps_list})
endif()

set_target_properties(
${fq_target_name}
Expand Down
5 changes: 2 additions & 3 deletions libc/config/linux/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
#ifndef LLVM_LIBC_CONFIG_LINUX_APP_H
#define LLVM_LIBC_CONFIG_LINUX_APP_H

#include "src/__support/macros/config.h"
#include "src/__support/macros/properties/architectures.h"

#include <stdint.h>

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

// Data structure to capture properties of the linux/ELF TLS image.
struct TLSImage {
Expand Down Expand Up @@ -105,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_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_CONFIG_LINUX_APP_H
14 changes: 7 additions & 7 deletions libc/docs/dev/clang_tidy_checks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ implementation-in-namespace
---------------------------

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

This check that ensures any function call resolves to a function within the
``LIBC_NAMESPACE_DECL`` namespace.
``LIBC_NAMESPACE`` namespace.

.. code-block:: c++

// Correct: implementation inside the correct namespace.
namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {
void LLVM_LIBC_ENTRYPOINT(strcpy)(char *dest, const char *src) {}
// Namespaces within LIBC_NAMESPACE namespace are allowed.
namespace inner{
Expand Down Expand Up @@ -87,7 +87,7 @@ are always external and can be intercepted.

.. code-block:: c++

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

// Allow calls with the fully qualified name.
LIBC_NAMESPACE::strlen("hello");
Expand All @@ -104,4 +104,4 @@ are always external and can be intercepted.
// Allow calling into specific global functions (explained above)
::malloc(10);

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE
5 changes: 2 additions & 3 deletions libc/fuzzing/__support/hashtable_fuzz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
#include "include/llvm-libc-types/ENTRY.h"
#include "src/__support/CPP/string_view.h"
#include "src/__support/HashTable/table.h"
#include "src/__support/macros/config.h"

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

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

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE
5 changes: 2 additions & 3 deletions libc/src/__support/CPP/algorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@
#define LLVM_LIBC_SRC___SUPPORT_CPP_ALGORITHM_H

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {
namespace cpp {

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

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

#endif // LLVM_LIBC_SRC___SUPPORT_CPP_ALGORITHM_H
5 changes: 2 additions & 3 deletions libc/src/__support/CPP/array.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@

#include "src/__support/CPP/iterator.h" // reverse_iterator
#include "src/__support/macros/attributes.h"
#include "src/__support/macros/config.h"
#include <stddef.h> // For size_t.

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {
namespace cpp {

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

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

#endif // LLVM_LIBC_SRC___SUPPORT_CPP_ARRAY_H
5 changes: 2 additions & 3 deletions libc/src/__support/CPP/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@
#define LLVM_LIBC_SRC___SUPPORT_CPP_ATOMIC_H

#include "src/__support/macros/attributes.h"
#include "src/__support/macros/config.h"
#include "src/__support/macros/properties/architectures.h"

#include "type_traits.h"

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {
namespace cpp {

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

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

#endif // LLVM_LIBC_SRC___SUPPORT_CPP_ATOMIC_H
7 changes: 2 additions & 5 deletions libc/src/__support/CPP/bit.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@
#include "src/__support/CPP/limits.h" // numeric_limits
#include "src/__support/CPP/type_traits.h"
#include "src/__support/macros/attributes.h"
#include "src/__support/macros/config.h"
#include "src/__support/macros/sanitizer.h"

#include <stdint.h>

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

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

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

#endif // LLVM_LIBC_SRC___SUPPORT_CPP_BIT_H
Loading

0 comments on commit 1f0fa99

Please sign in to comment.