5 changes: 2 additions & 3 deletions libc/src/__support/OSUtil/gpu/io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@

#include "src/__support/CPP/string_view.h"
#include "src/__support/RPC/rpc_client.h"
#include "src/__support/macros/config.h"

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

void write_to_stderr(cpp::string_view msg) {
rpc::Client::Port port = rpc::client.open<RPC_WRITE_TO_STDERR>();
Expand All @@ -21,4 +20,4 @@ void write_to_stderr(cpp::string_view msg) {
port.close();
}

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE
5 changes: 2 additions & 3 deletions libc/src/__support/OSUtil/gpu/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

void write_to_stderr(cpp::string_view msg);

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_OSUTIL_GPU_IO_H
5 changes: 2 additions & 3 deletions libc/src/__support/OSUtil/linux/aarch64/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#define LLVM_LIBC_SRC___SUPPORT_OSUTIL_LINUX_AARCH64_SYSCALL_H

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

#define REGISTER_DECL_0 \
register long x8 __asm__("x8") = number; \
Expand Down Expand Up @@ -43,7 +42,7 @@
#define SYSCALL_INSTR(input_constraint) \
LIBC_INLINE_ASM("svc 0" : "=r"(x0) : input_constraint : "memory", "cc")

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

LIBC_INLINE long syscall_impl(long number) {
REGISTER_DECL_0;
Expand Down Expand Up @@ -90,7 +89,7 @@ LIBC_INLINE long syscall_impl(long number, long arg1, long arg2, long arg3,
return x0;
}

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#undef REGISTER_DECL_0
#undef REGISTER_DECL_1
Expand Down
5 changes: 2 additions & 3 deletions libc/src/__support/OSUtil/linux/arm/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#define LLVM_LIBC_SRC___SUPPORT_OSUTIL_LINUX_ARM_SYSCALL_H

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

#ifdef __thumb__
#define R7 long r7 = number
Expand Down Expand Up @@ -61,7 +60,7 @@
#define REGISTER_CONSTRAINT_5 REGISTER_CONSTRAINT_4, "r"(r4)
#define REGISTER_CONSTRAINT_6 REGISTER_CONSTRAINT_5, "r"(r5)

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

LIBC_INLINE long syscall_impl(long number) {
REGISTER_DECL_0;
Expand Down Expand Up @@ -108,7 +107,7 @@ LIBC_INLINE long syscall_impl(long number, long arg1, long arg2, long arg3,
return r0;
}

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#undef REGISTER_DECL_0
#undef REGISTER_DECL_1
Expand Down
7 changes: 2 additions & 5 deletions libc/src/__support/OSUtil/linux/exit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@
//===----------------------------------------------------------------------===//

#include "src/__support/common.h"
#include "src/__support/macros/config.h"
#include "syscall.h" // For internal syscall function.
#include <sys/syscall.h> // For syscall numbers.

namespace LIBC_NAMESPACE_DECL {
namespace internal {
namespace LIBC_NAMESPACE::internal {

// mark as no_stack_protector for x86 since TLS can be torn down before calling
// exit so that the stack protector canary cannot be loaded.
Expand All @@ -27,5 +25,4 @@ exit(int status) {
}
}

} // namespace internal
} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE::internal
7 changes: 2 additions & 5 deletions libc/src/__support/OSUtil/linux/fcntl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@
#include "hdr/types/struct_flock64.h"
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
#include "src/__support/macros/config.h"
#include "src/errno/libc_errno.h"

#include <stdarg.h>
#include <sys/syscall.h> // For syscall numbers.

namespace LIBC_NAMESPACE_DECL {
namespace internal {
namespace LIBC_NAMESPACE::internal {

int fcntl(int fd, int cmd, void *arg) {
#if SYS_fcntl
Expand Down Expand Up @@ -99,5 +97,4 @@ int fcntl(int fd, int cmd, void *arg) {
}
}

} // namespace internal
} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE::internal
5 changes: 2 additions & 3 deletions libc/src/__support/OSUtil/linux/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,17 @@
#define LLVM_LIBC_SRC___SUPPORT_OSUTIL_LINUX_IO_H

#include "src/__support/CPP/string_view.h"
#include "src/__support/macros/config.h"
#include "syscall.h" // For internal syscall function.

#include <sys/syscall.h> // For syscall numbers.

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

LIBC_INLINE void write_to_stderr(cpp::string_view msg) {
LIBC_NAMESPACE::syscall_impl<long>(SYS_write, 2 /* stderr */, msg.data(),
msg.size());
}

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_OSUTIL_LINUX_IO_H
5 changes: 2 additions & 3 deletions libc/src/__support/OSUtil/linux/riscv/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#define LLVM_LIBC_SRC___SUPPORT_OSUTIL_LINUX_RISCV_SYSCALL_H

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

#define REGISTER_DECL_0 \
register long a7 __asm__("a7") = number; \
Expand Down Expand Up @@ -43,7 +42,7 @@
#define SYSCALL_INSTR(input_constraint) \
LIBC_INLINE_ASM("ecall\n\t" : "=r"(a0) : input_constraint : "memory")

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

LIBC_INLINE long syscall_impl(long number) {
REGISTER_DECL_0;
Expand Down Expand Up @@ -90,7 +89,7 @@ LIBC_INLINE long syscall_impl(long number, long arg1, long arg2, long arg3,
return a0;
}

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#undef REGISTER_DECL_0
#undef REGISTER_DECL_1
Expand Down
5 changes: 2 additions & 3 deletions libc/src/__support/OSUtil/linux/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

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

#ifdef LIBC_TARGET_ARCH_IS_X86_64
Expand All @@ -24,14 +23,14 @@
#include "riscv/syscall.h"
#endif

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

template <typename R, typename... Ts>
LIBC_INLINE R syscall_impl(long __number, Ts... ts) {
static_assert(sizeof...(Ts) <= 6, "Too many arguments for syscall");
return cpp::bit_or_static_cast<R>(syscall_impl(__number, (long)ts...));
}

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_OSUTIL_LINUX_SYSCALL_H
5 changes: 2 additions & 3 deletions libc/src/__support/OSUtil/linux/x86_64/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@
#define LLVM_LIBC_SRC___SUPPORT_OSUTIL_LINUX_X86_64_SYSCALL_H

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

#define SYSCALL_CLOBBER_LIST "rcx", "r11", "memory"

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

LIBC_INLINE long syscall_impl(long __number) {
long retcode;
Expand Down Expand Up @@ -94,6 +93,6 @@ LIBC_INLINE long syscall_impl(long __number, long __arg1, long __arg2,
}

#undef SYSCALL_CLOBBER_LIST
} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_OSUTIL_LINUX_X86_64_SYSCALL_H
5 changes: 2 additions & 3 deletions libc/src/__support/RPC/rpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@
#include "src/__support/CPP/functional.h"
#include "src/__support/CPP/optional.h"
#include "src/__support/GPU/utils.h"
#include "src/__support/macros/config.h"

#include <stdint.h>

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {
namespace rpc {

/// A fixed size channel used to communicate between the RPC client and server.
Expand Down Expand Up @@ -598,6 +597,6 @@ LIBC_INLINE Server::Port Server::open(uint32_t lane_size) {
}

} // namespace rpc
} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif
5 changes: 2 additions & 3 deletions libc/src/__support/RPC/rpc_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {
namespace rpc {

/// The libc client instance used to communicate with the server.
Expand All @@ -23,4 +22,4 @@ extern "C" [[gnu::visibility("protected")]] const void *__llvm_libc_rpc_client =
&client;

} // namespace rpc
} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE
5 changes: 2 additions & 3 deletions libc/src/__support/RPC/rpc_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@
#include "rpc.h"

#include "include/llvm-libc-types/rpc_opcodes_t.h"
#include "src/__support/macros/config.h"

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {
namespace rpc {

/// The libc client instance used to communicate with the server.
extern Client client;

} // namespace rpc
} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif
5 changes: 2 additions & 3 deletions libc/src/__support/RPC/rpc_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@
#include "src/__support/CPP/type_traits.h"
#include "src/__support/GPU/utils.h"
#include "src/__support/macros/attributes.h"
#include "src/__support/macros/config.h"
#include "src/__support/macros/properties/architectures.h"
#include "src/__support/threads/sleep.h"
#include "src/string/memory_utils/generic/byte_per_byte.h"
#include "src/string/memory_utils/inline_memcpy.h"

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {
namespace rpc {

/// Conditional to indicate if this process is running on the GPU.
Expand Down Expand Up @@ -68,6 +67,6 @@ LIBC_INLINE void rpc_memcpy(void *dst, const void *src, size_t count) {
}

} // namespace rpc
} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_RPC_RPC_UTIL_H
5 changes: 2 additions & 3 deletions libc/src/__support/StringUtil/error_to_string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
#include "src/__support/StringUtil/message_mapper.h"
#include "src/__support/integer_to_string.h"
#include "src/__support/macros/attributes.h"
#include "src/__support/macros/config.h"

#include <stddef.h>

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {
namespace internal {

constexpr size_t max_buff_size() {
Expand Down Expand Up @@ -75,4 +74,4 @@ cpp::string_view get_error_string(int err_num, cpp::span<char> buffer) {
return internal::build_error_string(err_num, buffer);
}

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE
5 changes: 2 additions & 3 deletions libc/src/__support/StringUtil/error_to_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@

#include "src/__support/CPP/span.h"
#include "src/__support/CPP/string_view.h"
#include "src/__support/macros/config.h"

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

cpp::string_view get_error_string(int err_num);

cpp::string_view get_error_string(int err_num, cpp::span<char> buffer);

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_STRINGUTIL_ERROR_TO_STRING_H
5 changes: 2 additions & 3 deletions libc/src/__support/StringUtil/message_mapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
#include "src/__support/CPP/array.h"
#include "src/__support/CPP/optional.h"
#include "src/__support/CPP/string_view.h"
#include "src/__support/macros/config.h"
#include <stddef.h>

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

struct MsgMapping {
int num;
Expand Down Expand Up @@ -99,6 +98,6 @@ constexpr MsgTable<N1 + N2> operator+(const MsgTable<N1> &t1,
return res;
}

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_STRINGUTIL_MESSAGE_MAPPER_H
5 changes: 2 additions & 3 deletions libc/src/__support/StringUtil/signal_to_string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
#include "src/__support/StringUtil/message_mapper.h"
#include "src/__support/integer_to_string.h"
#include "src/__support/macros/attributes.h"
#include "src/__support/macros/config.h"

#include <signal.h>
#include <stddef.h>

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {
namespace internal {

constexpr size_t max_buff_size() {
Expand Down Expand Up @@ -78,4 +77,4 @@ cpp::string_view get_signal_string(int sig_num, cpp::span<char> buffer) {
return internal::build_signal_string(sig_num, buffer);
}

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE
5 changes: 2 additions & 3 deletions libc/src/__support/StringUtil/signal_to_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@

#include "src/__support/CPP/span.h"
#include "src/__support/CPP/string_view.h"
#include "src/__support/macros/config.h"

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

cpp::string_view get_signal_string(int err_num);

cpp::string_view get_signal_string(int err_num, cpp::span<char> buffer);

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_STRINGUTIL_SIGNAL_TO_STRING_H
5 changes: 2 additions & 3 deletions libc/src/__support/StringUtil/tables/linux_extension_errors.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@
#define LLVM_LIBC_SRC___SUPPORT_STRINGUTIL_TABLES_LINUX_EXTENSION_ERRORS_H

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

#include <errno.h> // For error macros

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

constexpr MsgTable<52> LINUX_ERRORS = {
MsgMapping(ENOTBLK, "Block device required"),
Expand Down Expand Up @@ -71,6 +70,6 @@ constexpr MsgTable<52> LINUX_ERRORS = {
MsgMapping(EHWPOISON, "Memory page has hardware error"),
};

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_STRINGUTIL_TABLES_LINUX_EXTENSION_ERRORS_H
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@
#define LLVM_LIBC_SRC___SUPPORT_STRINGUTIL_TABLES_LINUX_EXTENSION_SIGNALS_H

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

#include <signal.h> // For signal numbers

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

// The array being larger than necessary isn't a problem. The MsgMappings will
// be set to their default state which maps 0 to an empty string. This will get
Expand All @@ -29,6 +28,6 @@ LIBC_INLINE_VAR constexpr const MsgTable<3> LINUX_SIGNALS = {
#endif
};

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_STRINGUTIL_TABLES_LINUX_EXTENSION_SIGNALS_H
5 changes: 2 additions & 3 deletions libc/src/__support/StringUtil/tables/linux_platform_errors.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@

#include "linux_extension_errors.h"
#include "posix_errors.h"
#include "src/__support/macros/config.h"
#include "stdc_errors.h"

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

LIBC_INLINE_VAR constexpr auto PLATFORM_ERRORS =
STDC_ERRORS + POSIX_ERRORS + LINUX_ERRORS;

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_STRINGUTIL_TABLES_LINUX_PLATFORM_ERRORS_H
5 changes: 2 additions & 3 deletions libc/src/__support/StringUtil/tables/linux_platform_signals.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@

#include "linux_extension_signals.h"
#include "posix_signals.h"
#include "src/__support/macros/config.h"
#include "stdc_signals.h"

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

LIBC_INLINE_VAR constexpr auto PLATFORM_SIGNALS =
STDC_SIGNALS + POSIX_SIGNALS + LINUX_SIGNALS;

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_STRINGUTIL_TABLES_LINUX_PLATFORM_SIGNALS_H
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_STRINGUTIL_TABLES_MINIMAL_PLATFORM_ERRORS_H
#define LLVM_LIBC_SRC___SUPPORT_STRINGUTIL_TABLES_MINIMAL_PLATFORM_ERRORS_H

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

LIBC_INLINE_VAR constexpr auto PLATFORM_ERRORS = STDC_ERRORS;

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_STRINGUTIL_TABLES_MINIMAL_PLATFORM_ERRORS_H
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_STRINGUTIL_TABLES_MINIMAL_PLATFORM_SIGNALS_H
#define LLVM_LIBC_SRC___SUPPORT_STRINGUTIL_TABLES_MINIMAL_PLATFORM_SIGNALS_H

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

LIBC_INLINE_VAR constexpr auto PLATFORM_SIGNALS = STDC_SIGNALS;

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_STRINGUTIL_TABLES_MINIMAL_PLATFORM_SIGNALS_H
5 changes: 2 additions & 3 deletions libc/src/__support/StringUtil/tables/posix_errors.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@
#define LLVM_LIBC_SRC___SUPPORT_STRINGUTIL_TABLES_POSIX_ERRORS_H

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

#include <errno.h> // For error macros

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

LIBC_INLINE_VAR constexpr MsgTable<76> POSIX_ERRORS = {
MsgMapping(EPERM, "Operation not permitted"),
Expand Down Expand Up @@ -95,6 +94,6 @@ LIBC_INLINE_VAR constexpr MsgTable<76> POSIX_ERRORS = {
MsgMapping(ENOTRECOVERABLE, "State not recoverable"),
};

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_STRINGUTIL_TABLES_POSIX_ERRORS_H
5 changes: 2 additions & 3 deletions libc/src/__support/StringUtil/tables/posix_signals.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@

#include "src/__support/CPP/array.h"
#include "src/__support/StringUtil/message_mapper.h"
#include "src/__support/macros/config.h"

#include <signal.h> // For signal numbers

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

LIBC_INLINE_VAR constexpr MsgTable<22> POSIX_SIGNALS = {
MsgMapping(SIGHUP, "Hangup"),
Expand All @@ -42,6 +41,6 @@ LIBC_INLINE_VAR constexpr MsgTable<22> POSIX_SIGNALS = {
MsgMapping(SIGSYS, "Bad system call"),
};

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_STRINGUTIL_TABLES_POSIX_SIGNALS_H
7 changes: 2 additions & 5 deletions libc/src/__support/StringUtil/tables/signal_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "src/__support/StringUtil/message_mapper.h"

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

#if defined(__linux__) || defined(__Fuchsia__)
Expand All @@ -25,8 +24,7 @@
#include "linux_extension_signals.h"
#endif

namespace LIBC_NAMESPACE_DECL {
namespace internal {
namespace LIBC_NAMESPACE::internal {

LIBC_INLINE_VAR constexpr auto PLATFORM_SIGNALS = []() {
if constexpr (USE_LINUX_PLATFORM_SIGNALS) {
Expand All @@ -36,7 +34,6 @@ LIBC_INLINE_VAR constexpr auto PLATFORM_SIGNALS = []() {
}
}();

} // namespace internal
} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE::internal

#endif // LLVM_LIBC_SRC___SUPPORT_STRINGUTIL_TABLES_SIGNAL_TABLE_H
5 changes: 2 additions & 3 deletions libc/src/__support/StringUtil/tables/stdc_errors.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,17 @@
#define LLVM_LIBC_SRC___SUPPORT_STRINGUTIL_TABLES_STDC_ERRORS_H

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

#include <errno.h> // For error macros

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

LIBC_INLINE_VAR constexpr const MsgTable<3> STDC_ERRORS = {
MsgMapping(0, "Success"),
MsgMapping(EDOM, "Numerical argument out of domain"),
MsgMapping(ERANGE, "Numerical result out of range"),
};

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_STRINGUTIL_TABLES_STDC_ERRORS_H
5 changes: 2 additions & 3 deletions libc/src/__support/StringUtil/tables/stdc_signals.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
#include <signal.h> // For signal numbers

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

LIBC_INLINE_VAR constexpr const MsgTable<6> STDC_SIGNALS = {
MsgMapping(SIGINT, "Interrupt"),
Expand All @@ -25,6 +24,6 @@ LIBC_INLINE_VAR constexpr const MsgTable<6> STDC_SIGNALS = {
MsgMapping(SIGTERM, "Terminated"),
};

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_STRINGUTIL_TABLES_STDC_SIGNALS_H
5 changes: 2 additions & 3 deletions libc/src/__support/arg_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@
#define LLVM_LIBC_SRC___SUPPORT_ARG_LIST_H

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

#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {
namespace internal {

class ArgList {
Expand Down Expand Up @@ -100,6 +99,6 @@ class StructArgList {
};

} // namespace internal
} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_ARG_LIST_H
5 changes: 2 additions & 3 deletions libc/src/__support/big_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include "src/__support/CPP/optional.h"
#include "src/__support/CPP/type_traits.h"
#include "src/__support/macros/attributes.h" // LIBC_INLINE
#include "src/__support/macros/config.h"
#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
#include "src/__support/macros/properties/compiler.h" // LIBC_COMPILER_IS_CLANG
#include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_INT128, LIBC_TYPES_HAS_INT64
Expand All @@ -25,7 +24,7 @@
#include <stddef.h> // For size_t
#include <stdint.h>

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

namespace multiword {

Expand Down Expand Up @@ -1294,6 +1293,6 @@ first_trailing_one(T value) {
: cpp::countr_zero(value) + 1;
}

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_UINT_H
5 changes: 2 additions & 3 deletions libc/src/__support/block.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@
#include "src/__support/CPP/span.h"
#include "src/__support/CPP/type_traits.h"
#include "src/__support/libc_assert.h"
#include "src/__support/macros/config.h"

#include <stdint.h>

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

namespace internal {
// Types of corrupted blocks, and functions to crash with an error message
Expand Down Expand Up @@ -600,6 +599,6 @@ internal::BlockStatus Block<OffsetType, kAlign>::check_status() const {
return internal::BlockStatus::VALID;
}

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_BLOCK_H
5 changes: 2 additions & 3 deletions libc/src/__support/blockstore.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_BLOCKSTORE_H
#define LLVM_LIBC_SRC___SUPPORT_BLOCKSTORE_H

#include "src/__support/macros/config.h"
#include <src/__support/CPP/new.h>
#include <src/__support/libc_assert.h>

#include <stddef.h>
#include <stdint.h>

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

// The difference between BlockStore a traditional vector types is that,
// when more capacity is desired, a new block is added instead of allocating
Expand Down Expand Up @@ -204,6 +203,6 @@ LIBC_INLINE void BlockStore<T, BLOCK_SIZE, REVERSE_ORDER>::destroy(
template <typename T, size_t BLOCK_SIZE>
using ReverseOrderBlockStore = BlockStore<T, BLOCK_SIZE, true>;

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

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

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

// The CString class is a companion to the cpp::string class. Its use case is as
// a return value for a function that in C would return a char* and a flag for
Expand All @@ -32,6 +31,6 @@ class CString {
LIBC_INLINE operator const char *() const { return str.c_str(); }
};

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

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

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

#include <stddef.h> // size_t
#include <stdlib.h> // malloc, realloc, free

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

// This is very simple alternate of the std::string class. There is no
// bounds check performed in any of the methods. The callers are expected to
Expand Down Expand Up @@ -74,6 +73,6 @@ class CharVector {
LIBC_INLINE size_t length() { return index; }
};

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_CHARVECTOR_H
5 changes: 2 additions & 3 deletions libc/src/__support/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#endif

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

#ifndef LLVM_LIBC_FUNCTION_ATTR
Expand All @@ -36,7 +35,7 @@
#define LLVM_LIBC_FUNCTION(type, name, arglist) \
LLVM_LIBC_FUNCTION_IMPL(type, name, arglist)

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {
namespace internal {
LIBC_INLINE constexpr bool same_string(char const *lhs, char const *rhs) {
for (; *lhs || *rhs; ++lhs, ++rhs)
Expand All @@ -45,7 +44,7 @@ LIBC_INLINE constexpr bool same_string(char const *lhs, char const *rhs) {
return true;
}
} // namespace internal
} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#define __LIBC_MACRO_TO_STRING(str) #str
#define LIBC_MACRO_TO_STRING(str) __LIBC_MACRO_TO_STRING(str)
Expand Down
5 changes: 2 additions & 3 deletions libc/src/__support/ctype_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@
#define LLVM_LIBC_SRC___SUPPORT_CTYPE_UTILS_H

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {
namespace internal {

// ------------------------------------------------------
Expand Down Expand Up @@ -56,6 +55,6 @@ LIBC_INLINE static constexpr int tolower(int ch) {
}

} // namespace internal
} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_CTYPE_UTILS_H
5 changes: 2 additions & 3 deletions libc/src/__support/detailed_powers_of_ten.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@
#define LLVM_LIBC_SRC___SUPPORT_DETAILED_POWERS_OF_TEN_H

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

#include <stdint.h>

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {
namespace internal {

// TODO(michaelrj): write a script that will generate this table.
Expand Down Expand Up @@ -735,6 +734,6 @@ static constexpr uint64_t DETAILED_POWERS_OF_TEN[696][2] = {
};

} // namespace internal
} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_DETAILED_POWERS_OF_TEN_H
5 changes: 2 additions & 3 deletions libc/src/__support/endian.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@
#define LLVM_LIBC_SRC___SUPPORT_ENDIAN_H

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

#include <stdint.h>

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

// We rely on compiler preprocessor defines to allow for cross compilation.
#if !defined(__BYTE_ORDER__) || !defined(__ORDER_LITTLE_ENDIAN__) || \
Expand Down Expand Up @@ -141,6 +140,6 @@ Endian<__ORDER_BIG_ENDIAN__>::to_little_endian<uint64_t>(uint64_t v) {

using Endian = internal::Endian<__BYTE_ORDER__>;

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_ENDIAN_H
5 changes: 2 additions & 3 deletions libc/src/__support/error_or.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@
#define LLVM_LIBC_SRC___SUPPORT_ERROR_OR_H

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

template <class T> using ErrorOr = cpp::expected<T, int>;

Expand All @@ -35,6 +34,6 @@ using Error = cpp::unexpected<int>;
// constexpr operator T() { return value; }
// };

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_ERROR_OR_H
7 changes: 2 additions & 5 deletions libc/src/__support/fixed_point/fx_bits.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,14 @@
#include "src/__support/CPP/bit.h"
#include "src/__support/CPP/type_traits.h"
#include "src/__support/macros/attributes.h" // LIBC_INLINE
#include "src/__support/macros/config.h"
#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
#include "src/__support/math_extras.h"

#include "fx_rep.h"

#ifdef LIBC_COMPILER_HAS_FIXED_POINT

namespace LIBC_NAMESPACE_DECL {
namespace fixed_point {
namespace LIBC_NAMESPACE::fixed_point {

template <typename T> struct FXBits {
private:
Expand Down Expand Up @@ -163,8 +161,7 @@ template <typename T> LIBC_INLINE constexpr T round(T x, int n) {
return bit_and((x + round_bit), rounding_mask);
}

} // namespace fixed_point
} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE::fixed_point

#endif // LIBC_COMPILER_HAS_FIXED_POINT

Expand Down
7 changes: 2 additions & 5 deletions libc/src/__support/fixed_point/fx_rep.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@
#include "include/llvm-libc-macros/stdfix-macros.h"
#include "src/__support/CPP/type_traits.h"
#include "src/__support/macros/attributes.h" // LIBC_INLINE, LIBC_INLINE_VAR
#include "src/__support/macros/config.h"

#include <stdint.h>

#ifdef LIBC_COMPILER_HAS_FIXED_POINT

namespace LIBC_NAMESPACE_DECL {
namespace fixed_point {
namespace LIBC_NAMESPACE::fixed_point {

namespace internal {

Expand Down Expand Up @@ -295,8 +293,7 @@ template <> struct FXRep<unsigned sat accum> : FXRep<unsigned accum> {};
template <>
struct FXRep<unsigned long sat accum> : FXRep<unsigned long accum> {};

} // namespace fixed_point
} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE::fixed_point

#endif // LIBC_COMPILER_HAS_FIXED_POINT

Expand Down
7 changes: 2 additions & 5 deletions libc/src/__support/fixed_point/sqrt.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@
#include "src/__support/CPP/limits.h" // CHAR_BIT
#include "src/__support/CPP/type_traits.h"
#include "src/__support/macros/attributes.h" // LIBC_INLINE
#include "src/__support/macros/config.h"
#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY

#include "fx_rep.h"

#ifdef LIBC_COMPILER_HAS_FIXED_POINT

namespace LIBC_NAMESPACE_DECL {
namespace fixed_point {
namespace LIBC_NAMESPACE::fixed_point {

namespace internal {

Expand Down Expand Up @@ -261,8 +259,7 @@ isqrt_fast(T x) {
return cpp::bit_cast<OutType>(r);
}

} // namespace fixed_point
} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE::fixed_point

#endif // LIBC_COMPILER_HAS_FIXED_POINT

Expand Down
5 changes: 2 additions & 3 deletions libc/src/__support/fixedvector.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
#include "src/__support/CPP/array.h"

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

// A fixed size data store backed by an underlying cpp::array data structure. It
// supports vector like API but is not resizable like a vector.
Expand Down Expand Up @@ -98,6 +97,6 @@ template <typename T, size_t CAPACITY> class FixedVector {
}
};

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_FIXEDVECTOR_H
5 changes: 2 additions & 3 deletions libc/src/__support/float_to_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "src/__support/common.h"
#include "src/__support/libc_assert.h"
#include "src/__support/macros/attributes.h"
#include "src/__support/macros/config.h"

// This file has 5 compile-time flags to allow the user to configure the float
// to string behavior. These were used to explore tradeoffs during the design
Expand Down Expand Up @@ -106,7 +105,7 @@ constexpr size_t MID_INT_SIZE = 192;
// Any block that is all 9s adds one to the max block counter and doesn't clear
// the buffer because they can cause the block above them to be rounded up.

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

using BlockInt = uint32_t;
constexpr uint32_t BLOCK_SIZE = 9;
Expand Down Expand Up @@ -840,6 +839,6 @@ template <> class FloatToString<long double> {
#endif // !LIBC_TYPES_LONG_DOUBLE_IS_FLOAT64 &&
// !LIBC_COPT_FLOAT_TO_STR_NO_SPECIALIZE_LD

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_FLOAT_TO_STRING_H
5 changes: 2 additions & 3 deletions libc/src/__support/freelist.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@
#include "src/__support/CPP/new.h"
#include "src/__support/CPP/span.h"
#include "src/__support/fixedvector.h"
#include "src/__support/macros/config.h"

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

using cpp::span;

Expand Down Expand Up @@ -204,6 +203,6 @@ FreeList<NUM_BUCKETS>::find_chunk_ptr_for_size(size_t size,
return chunk_ptr;
}

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_FREELIST_H
5 changes: 2 additions & 3 deletions libc/src/__support/freelist_heap.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@
#include "src/__support/CPP/optional.h"
#include "src/__support/CPP/span.h"
#include "src/__support/libc_assert.h"
#include "src/__support/macros/config.h"
#include "src/string/memory_utils/inline_memcpy.h"
#include "src/string/memory_utils/inline_memset.h"

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

using cpp::optional;
using cpp::span;
Expand Down Expand Up @@ -259,6 +258,6 @@ void *FreeListHeap<NUM_BUCKETS>::calloc(size_t num, size_t size) {

extern FreeListHeap<> *freelist_heap;

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_FREELIST_HEAP_H
5 changes: 2 additions & 3 deletions libc/src/__support/hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
#include "src/__support/CPP/bit.h" // rotl
#include "src/__support/CPP/limits.h" // numeric_limits
#include "src/__support/macros/attributes.h" // LIBC_INLINE
#include "src/__support/macros/config.h"
#include "src/__support/uint128.h" // UInt128
#include <stdint.h> // For uint64_t

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {
namespace internal {

// Folded multiplication.
Expand Down Expand Up @@ -161,6 +160,6 @@ class HashState {
};

} // namespace internal
} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

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

#include "src/__support/CPP/limits.h"
#include "src/__support/ctype_utils.h"
#include "src/__support/macros/config.h"
#include "src/__support/str_to_integer.h"
#include <stdint.h>

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {
namespace internal {

struct LShiftTableEntry {
Expand Down Expand Up @@ -423,6 +422,6 @@ class HighPrecisionDecimal {
};

} // namespace internal
} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_HIGH_PRECISION_DECIMAL_H
5 changes: 2 additions & 3 deletions libc/src/__support/integer_literals.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@

#include "src/__support/CPP/limits.h" // CHAR_BIT
#include "src/__support/macros/attributes.h" // LIBC_INLINE
#include "src/__support/macros/config.h"
#include "src/__support/uint128.h" // UInt128
#include <stddef.h> // size_t
#include <stdint.h> // uintxx_t

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

LIBC_INLINE constexpr uint8_t operator""_u8(unsigned long long value) {
return static_cast<uint8_t>(value);
Expand Down Expand Up @@ -183,6 +182,6 @@ template <typename T> LIBC_INLINE constexpr T parse_bigint(const char *ptr) {
return internal::parse_with_prefix<T>(ptr);
}

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

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

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

template <typename T>
LIBC_INLINE static constexpr cpp::enable_if_t<cpp::is_integral_v<T>, T>
Expand All @@ -28,6 +27,6 @@ integer_rem_quo(T x, T y, T &quot, T &rem) {
rem = x % y;
}

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_INTEGER_OPERATIONS_H
5 changes: 2 additions & 3 deletions libc/src/__support/integer_to_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,8 @@
#include "src/__support/CPP/type_traits.h"
#include "src/__support/big_int.h" // make_integral_or_big_int_unsigned_t
#include "src/__support/common.h"
#include "src/__support/macros/config.h"

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

namespace details {

Expand Down Expand Up @@ -318,6 +317,6 @@ template <typename T, typename Fmt = radix::Dec> class IntegerToString {
}
};

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_INTEGER_TO_STRING_H
5 changes: 2 additions & 3 deletions libc/src/__support/intrusive_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@
#define LLVM_LIBC_SRC___SUPPORT_INTRUSIVE_LIST_H

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {
namespace internal {

class IntrusiveList {
Expand Down Expand Up @@ -61,6 +60,6 @@ class IntrusiveList {
};

} // namespace internal
} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_INTRUSIVE_LIST_H
5 changes: 2 additions & 3 deletions libc/src/__support/libc_assert.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_LIBC_ASSERT_H
#define LLVM_LIBC_SRC___SUPPORT_LIBC_ASSERT_H

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

// The build is configured to just use the public <assert.h> API
Expand All @@ -26,7 +25,7 @@
#include "src/__support/integer_to_string.h"
#include "src/__support/macros/attributes.h" // For LIBC_INLINE

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

// This is intended to be removed in a future patch to use a similar design to
// below, but it's necessary for the external assert.
Expand All @@ -44,7 +43,7 @@ LIBC_INLINE void report_assertion_failure(const char *assertion,
write_to_stderr("'\n");
}

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#ifdef LIBC_ASSERT
#error "Unexpected: LIBC_ASSERT macro already defined"
Expand Down
1 change: 0 additions & 1 deletion libc/src/__support/macros/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

// Workaround for compilers that do not support builtin detection.
// FIXME: This is only required for the GPU portion which should be moved.
#include "src/__support/macros/config.h"
#ifndef __has_builtin
#define __has_builtin(b) 0
#endif
Expand Down
7 changes: 2 additions & 5 deletions libc/src/__support/macros/optimization.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,16 @@
#define LLVM_LIBC_SRC___SUPPORT_MACROS_OPTIMIZATION_H

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

// We use a template to implement likely/unlikely to make sure that we don't
// accidentally pass an integer.
namespace LIBC_NAMESPACE_DECL {
namespace details {
namespace LIBC_NAMESPACE::details {
template <typename T>
LIBC_INLINE constexpr bool expects_bool_condition(T value, T expected) {
return __builtin_expect(value, expected);
}
} // namespace details
} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE::details
#define LIBC_LIKELY(x) LIBC_NAMESPACE::details::expects_bool_condition(x, true)
#define LIBC_UNLIKELY(x) \
LIBC_NAMESPACE::details::expects_bool_condition(x, false)
Expand Down
5 changes: 2 additions & 3 deletions libc/src/__support/math_extras.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@
#include "src/__support/CPP/limits.h" // CHAR_BIT, numeric_limits
#include "src/__support/CPP/type_traits.h" // is_unsigned_v, is_constant_evaluated
#include "src/__support/macros/attributes.h" // LIBC_INLINE
#include "src/__support/macros/config.h"

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

// Create a bitmask with the count right-most bits set to 1, and all other bits
// set to 0. Only unsigned types are allowed.
Expand Down Expand Up @@ -156,6 +155,6 @@ count_zeros(T value) {
return cpp::popcount<T>(static_cast<T>(~value));
}

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_MATH_EXTRAS_H
5 changes: 2 additions & 3 deletions libc/src/__support/memory_size.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@
#include "src/__support/CPP/limits.h"
#include "src/__support/CPP/type_traits.h"
#include "src/__support/macros/attributes.h"
#include "src/__support/macros/config.h"
#include "src/__support/macros/optimization.h"
#include "src/string/memory_utils/utils.h"

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {
namespace internal {
template <class T> LIBC_INLINE bool mul_overflow(T a, T b, T *res) {
#if __has_builtin(__builtin_mul_overflow)
Expand Down Expand Up @@ -86,6 +85,6 @@ class SafeMemSize {
}
};
} // namespace internal
} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_MEMORY_SIZE_H
5 changes: 2 additions & 3 deletions libc/src/__support/number_pair.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,16 @@
#define LLVM_LIBC_SRC___SUPPORT_NUMBER_PAIR_H

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

#include <stddef.h>

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

template <typename T> struct NumberPair {
T lo = T(0);
T hi = T(0);
};

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_NUMBER_PAIR_H
5 changes: 2 additions & 3 deletions libc/src/__support/str_to_float.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@
#include "src/__support/ctype_utils.h"
#include "src/__support/detailed_powers_of_ten.h"
#include "src/__support/high_precision_decimal.h"
#include "src/__support/macros/config.h"
#include "src/__support/str_to_integer.h"
#include "src/__support/str_to_num_result.h"
#include "src/__support/uint128.h"
#include "src/errno/libc_errno.h" // For ERANGE

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {
namespace internal {

template <class T> struct ExpandedFloat {
Expand Down Expand Up @@ -1227,6 +1226,6 @@ template <class T> LIBC_INLINE StrToNumResult<T> strtonan(const char *arg) {
}

} // namespace internal
} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_STR_TO_FLOAT_H
5 changes: 2 additions & 3 deletions libc/src/__support/str_to_integer.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@
#include "src/__support/CPP/type_traits.h"
#include "src/__support/common.h"
#include "src/__support/ctype_utils.h"
#include "src/__support/macros/config.h"
#include "src/__support/str_to_num_result.h"
#include "src/__support/uint128.h"
#include "src/errno/libc_errno.h" // For ERANGE

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {
namespace internal {

// Returns a pointer to the first character in src that is not a whitespace
Expand Down Expand Up @@ -165,6 +164,6 @@ strtointeger(const char *__restrict src, int base,
}

} // namespace internal
} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_STR_TO_INTEGER_H
5 changes: 2 additions & 3 deletions libc/src/__support/str_to_num_result.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@
#define LLVM_LIBC_SRC___SUPPORT_STR_TO_NUM_RESULT_H

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

#include <stddef.h>

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

template <typename T> struct StrToNumResult {
T value;
Expand All @@ -32,6 +31,6 @@ template <typename T> struct StrToNumResult {

LIBC_INLINE constexpr operator T() { return value; }
};
} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_STR_TO_NUM_RESULT_H
5 changes: 2 additions & 3 deletions libc/src/__support/threads/CndVar.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@
#ifndef LLVM_LIBC___SUPPORT_SRC_THREADS_LINUX_CNDVAR_H
#define LLVM_LIBC___SUPPORT_SRC_THREADS_LINUX_CNDVAR_H

#include "src/__support/macros/config.h"
#include "src/__support/threads/linux/futex_utils.h" // Futex
#include "src/__support/threads/linux/raw_mutex.h" // RawMutex
#include "src/__support/threads/mutex.h" // Mutex

#include <stdint.h> // uint32_t

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

class CndVar {
enum CndWaiterStatus : uint32_t {
Expand Down Expand Up @@ -50,6 +49,6 @@ class CndVar {
void broadcast();
};

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_THREADS_LINUX_CNDVAR_H
5 changes: 2 additions & 3 deletions libc/src/__support/threads/callonce.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_THREADS_CALLONCE_H
#define LLVM_LIBC_SRC___SUPPORT_THREADS_CALLONCE_H

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

// Plaform specific routines, provides:
Expand All @@ -22,7 +21,7 @@
#error "callonce is not supported on this platform"
#endif

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

// Common definitions
using CallOnceCallback = void(void);
Expand All @@ -36,6 +35,6 @@ LIBC_INLINE int callonce(CallOnceFlag *flag, CallOnceCallback *callback) {

return callonce_impl::callonce_slowpath(flag, callback);
}
} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_THREADS_CALLONCE_H
5 changes: 2 additions & 3 deletions libc/src/__support/threads/fork_callbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
#include "fork_callbacks.h"

#include "src/__support/CPP/mutex.h" // lock_guard
#include "src/__support/macros/config.h"
#include "src/__support/threads/mutex.h"

#include <stddef.h> // For size_t

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

namespace {

Expand Down Expand Up @@ -92,4 +91,4 @@ void invoke_prepare_callbacks() { cb_manager.invoke_prepare(); }

void invoke_parent_callbacks() { cb_manager.invoke_parent(); }

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE
6 changes: 2 additions & 4 deletions libc/src/__support/threads/fork_callbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_THREADS_FORK_CALLBACKS_H
#define LLVM_LIBC_SRC___SUPPORT_THREADS_FORK_CALLBACKS_H

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

using ForkCallback = void(void);

Expand All @@ -21,6 +19,6 @@ void invoke_prepare_callbacks();
void invoke_parent_callbacks();
void invoke_child_callbacks();

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_THREADS_FORK_CALLBACKS_H
5 changes: 2 additions & 3 deletions libc/src/__support/threads/gpu/mutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@
#define LLVM_LIBC_SRC___SUPPORT_THREADS_GPU_MUTEX_H

#include "src/__support/macros/attributes.h"
#include "src/__support/macros/config.h"
#include "src/__support/threads/mutex_common.h"

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

/// Implementation of a simple passthrough mutex which guards nothing. A
/// complete Mutex locks in general cannot be implemented on the GPU. We simply
Expand All @@ -27,6 +26,6 @@ struct Mutex {
LIBC_INLINE MutexError reset() { return MutexError::NONE; }
};

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_THREADS_GPU_MUTEX_H
5 changes: 2 additions & 3 deletions libc/src/__support/threads/linux/CndVar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@
#include "src/__support/threads/CndVar.h"
#include "src/__support/CPP/mutex.h"
#include "src/__support/OSUtil/syscall.h" // syscall_impl
#include "src/__support/macros/config.h"
#include "src/__support/threads/linux/futex_word.h" // FutexWordType
#include "src/__support/threads/linux/raw_mutex.h" // RawMutex
#include "src/__support/threads/mutex.h" // Mutex

#include <sys/syscall.h> // For syscall numbers.

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

int CndVar::wait(Mutex *m) {
// The goal is to perform "unlock |m| and wait" in an
Expand Down Expand Up @@ -103,4 +102,4 @@ void CndVar::broadcast() {
}
}

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE
5 changes: 2 additions & 3 deletions libc/src/__support/threads/linux/callonce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
//===----------------------------------------------------------------------===//

#include "src/__support/threads/callonce.h"
#include "src/__support/macros/config.h"
#include "src/__support/threads/linux/callonce.h"
#include "src/__support/threads/linux/futex_utils.h"

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {
namespace callonce_impl {
int callonce_slowpath(CallOnceFlag *flag, CallOnceCallback *func) {
auto *futex_word = reinterpret_cast<Futex *>(flag);
Expand All @@ -37,4 +36,4 @@ int callonce_slowpath(CallOnceFlag *flag, CallOnceCallback *func) {
return 0;
}
} // namespace callonce_impl
} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE
5 changes: 2 additions & 3 deletions libc/src/__support/threads/linux/callonce.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_THREADS_LINUX_CALLONCE_H
#define LLVM_LIBC_SRC___SUPPORT_THREADS_LINUX_CALLONCE_H

#include "src/__support/macros/config.h"
#include "src/__support/threads/linux/futex_utils.h"

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {
using CallOnceFlag = Futex;

namespace callonce_impl {
Expand All @@ -28,5 +27,5 @@ LIBC_INLINE bool callonce_fastpath(CallOnceFlag *flag) {
}
} // namespace callonce_impl

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE
#endif // LLVM_LIBC_SRC___SUPPORT_THREADS_LINUX_CALLONCE_H
5 changes: 2 additions & 3 deletions libc/src/__support/threads/linux/futex_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@
#include "src/__support/CPP/optional.h"
#include "src/__support/OSUtil/syscall.h"
#include "src/__support/macros/attributes.h"
#include "src/__support/macros/config.h"
#include "src/__support/threads/linux/futex_word.h"
#include "src/__support/time/linux/abs_timeout.h"
#include <linux/errno.h>
#include <linux/futex.h>

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {
class Futex : public cpp::Atomic<FutexWordType> {
public:
using Timeout = internal::AbsTimeout;
Expand Down Expand Up @@ -83,6 +82,6 @@ class Futex : public cpp::Atomic<FutexWordType> {

static_assert(__is_standard_layout(Futex),
"Futex must be a standard layout type.");
} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_THREADS_LINUX_FUTEX_UTILS_H
5 changes: 2 additions & 3 deletions libc/src/__support/threads/linux/futex_word.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_THREADS_LINUX_FUTEX_WORD_H
#define LLVM_LIBC_SRC___SUPPORT_THREADS_LINUX_FUTEX_WORD_H

#include "src/__support/macros/config.h"
#include <stdint.h>
#include <sys/syscall.h>
namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

// Futexes are 32 bits in size on all platforms, including 64-bit platforms.
using FutexWordType = uint32_t;
Expand All @@ -25,6 +24,6 @@ constexpr auto FUTEX_SYSCALL_ID = SYS_futex_time64;
#error "futex and futex_time64 syscalls not available."
#endif

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_THREADS_LINUX_FUTEX_WORD_H
5 changes: 2 additions & 3 deletions libc/src/__support/threads/linux/mutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@
#include "hdr/types/pid_t.h"
#include "src/__support/CPP/optional.h"
#include "src/__support/libc_assert.h"
#include "src/__support/macros/config.h"
#include "src/__support/threads/linux/futex_utils.h"
#include "src/__support/threads/linux/raw_mutex.h"
#include "src/__support/threads/mutex_common.h"

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

// TODO: support shared/recursive/robust mutexes.
class Mutex final : private RawMutex {
Expand Down Expand Up @@ -85,6 +84,6 @@ class Mutex final : private RawMutex {
}
};

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_THREADS_LINUX_MUTEX_H
5 changes: 2 additions & 3 deletions libc/src/__support/threads/linux/raw_mutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "src/__support/common.h"
#include "src/__support/libc_assert.h"
#include "src/__support/macros/attributes.h"
#include "src/__support/macros/config.h"
#include "src/__support/threads/linux/futex_utils.h"
#include "src/__support/threads/linux/futex_word.h"
#include "src/__support/threads/sleep.h"
Expand All @@ -33,7 +32,7 @@
"LIBC_COPT_RAW_MUTEX_DEFAULT_SPIN_COUNT is not defined, defaulting to 100"
#endif

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {
// Lock is a simple timable lock for internal usage.
// This is separated from Mutex because this one does not need to consider
// robustness and reentrancy. Also, this one has spin optimization for shorter
Expand Down Expand Up @@ -126,6 +125,6 @@ class RawMutex {
LIBC_INLINE Futex &get_raw_futex() { return futex; }
LIBC_INLINE void reset() { futex = UNLOCKED; }
};
} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_THREADS_LINUX_RAW_MUTEX_H
5 changes: 2 additions & 3 deletions libc/src/__support/threads/linux/rwlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include "src/__support/common.h"
#include "src/__support/libc_assert.h"
#include "src/__support/macros/attributes.h"
#include "src/__support/macros/config.h"
#include "src/__support/macros/optimization.h"
#include "src/__support/threads/linux/futex_utils.h"
#include "src/__support/threads/linux/futex_word.h"
Expand All @@ -37,7 +36,7 @@
#include "src/__support/time/linux/monotonicity.h"
#endif

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {
// Forward declaration of the RwLock class.
class RwLock;
// A namespace to rwlock specific utilities.
Expand Down Expand Up @@ -554,6 +553,6 @@ class RwLock {
return LockResult::Success;
}
};
} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC_SUPPORT_THREADS_LINUX_RWLOCK_H
5 changes: 2 additions & 3 deletions libc/src/__support/threads/linux/thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "src/__support/OSUtil/syscall.h" // For syscall functions.
#include "src/__support/common.h"
#include "src/__support/error_or.h"
#include "src/__support/macros/config.h"
#include "src/__support/threads/linux/futex_utils.h" // For FutexWordType
#include "src/errno/libc_errno.h" // For error macros

Expand All @@ -30,7 +29,7 @@
#include <sys/mman.h> // For PROT_* and MAP_* definitions.
#include <sys/syscall.h> // For syscall numbers.

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

#ifdef SYS_mmap2
static constexpr long MMAP_SYSCALL_NUMBER = SYS_mmap2;
Expand Down Expand Up @@ -518,4 +517,4 @@ void thread_exit(ThreadReturnValue retval, ThreadStyle style) {
__builtin_unreachable();
}

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE
6 changes: 2 additions & 4 deletions libc/src/__support/threads/mutex_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_THREADS_MUTEX_COMMON_H
#define LLVM_LIBC_SRC___SUPPORT_THREADS_MUTEX_COMMON_H

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

enum class MutexError : int {
NONE,
Expand All @@ -21,6 +19,6 @@ enum class MutexError : int {
BAD_LOCK_STATE,
};

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_THREADS_MUTEX_COMMON_H
5 changes: 2 additions & 3 deletions libc/src/__support/threads/sleep.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@
#define LLVM_LIBC_SRC___SUPPORT_THREADS_SLEEP_H

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

/// Suspend the thread briefly to assist the thread scheduler during busy loops.
LIBC_INLINE void sleep_briefly() {
Expand All @@ -32,6 +31,6 @@ LIBC_INLINE void sleep_briefly() {
#endif
}

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_THREADS_SLEEP_H
5 changes: 2 additions & 3 deletions libc/src/__support/threads/thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//

#include "src/__support/threads/thread.h"
#include "src/__support/macros/config.h"
#include "src/__support/threads/mutex.h"

#include "src/__support/CPP/array.h"
Expand All @@ -16,7 +15,7 @@
#include "src/__support/fixedvector.h"
#include "src/__support/macros/attributes.h"

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

LIBC_THREAD_LOCAL Thread self;

Expand Down Expand Up @@ -189,4 +188,4 @@ void *get_tss_value(unsigned int key) {
return u.payload;
}

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE
5 changes: 2 additions & 3 deletions libc/src/__support/threads/thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@
#include "src/__support/CPP/string_view.h"
#include "src/__support/CPP/stringstream.h"
#include "src/__support/macros/attributes.h"
#include "src/__support/macros/config.h"
#include "src/__support/macros/properties/architectures.h"

#include <linux/param.h> // for exec_pagesize.

#include <stddef.h> // For size_t
#include <stdint.h>

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

using ThreadRunnerPosix = void *(void *);
using ThreadRunnerStdc = int(void *);
Expand Down Expand Up @@ -251,6 +250,6 @@ void call_atexit_callbacks(ThreadAttributes *attrib);

} // namespace internal

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_THREADS_THREAD_H
5 changes: 2 additions & 3 deletions libc/src/__support/time/linux/abs_timeout.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
#include "hdr/time_macros.h"
#include "hdr/types/struct_timespec.h"
#include "src/__support/CPP/expected.h"
#include "src/__support/macros/config.h"
#include "src/__support/time/units.h"

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {
namespace internal {
// We use AbsTimeout to remind ourselves that the timeout is an absolute time.
// This is a simple wrapper around the timespec struct that also keeps track of
Expand Down Expand Up @@ -45,6 +44,6 @@ class AbsTimeout {
}
};
} // namespace internal
} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_TIME_LINUX_ABS_TIMEOUT_H
5 changes: 2 additions & 3 deletions libc/src/__support/time/linux/clock_conversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_TIME_LINUX_CLOCK_CONVERSION_H
#define LLVM_LIBC_SRC___SUPPORT_TIME_LINUX_CLOCK_CONVERSION_H

#include "src/__support/macros/config.h"
#include "src/__support/time/linux/clock_gettime.h"
#include "src/__support/time/units.h"

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {
namespace internal {

LIBC_INLINE timespec convert_clock(timespec input, clockid_t from,
Expand All @@ -38,6 +37,6 @@ LIBC_INLINE timespec convert_clock(timespec input, clockid_t from,
}

} // namespace internal
} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_TIME_LINUX_CLOCK_CONVERSION_H
5 changes: 2 additions & 3 deletions libc/src/__support/time/linux/clock_gettime.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@
#include "src/__support/OSUtil/syscall.h"
#include "src/__support/common.h"
#include "src/__support/error_or.h"
#include "src/__support/macros/config.h"
#include <sys/syscall.h>

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {
namespace internal {
LIBC_INLINE ErrorOr<int> clock_gettime(clockid_t clockid, timespec *ts) {
#if SYS_clock_gettime
Expand All @@ -40,6 +39,6 @@ LIBC_INLINE ErrorOr<int> clock_gettime(clockid_t clockid, timespec *ts) {
}

} // namespace internal
} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

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

#include "hdr/time_macros.h"
#include "src/__support/libc_assert.h"
#include "src/__support/macros/config.h"
#include "src/__support/time/linux/abs_timeout.h"
#include "src/__support/time/linux/clock_conversion.h"
namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {
namespace internal {
// This function is separated from abs_timeout.
// This function pulls in the dependency to clock_conversion.h,
Expand All @@ -39,6 +38,6 @@ LIBC_INLINE void ensure_monotonicity(AbsTimeout &timeout) {
}
}
} // namespace internal
} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_TIME_LINUX_MONOTONICITY_H
5 changes: 2 additions & 3 deletions libc/src/__support/time/units.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@

#include "hdr/types/time_t.h"
#include "src/__support/common.h"
#include "src/__support/macros/config.h"

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {
namespace time_units {
LIBC_INLINE constexpr time_t operator""_s_ns(unsigned long long s) {
return static_cast<time_t>(s * 1'000'000'000);
Expand All @@ -34,6 +33,6 @@ LIBC_INLINE constexpr time_t operator""_us_ns(unsigned long long us) {
return static_cast<time_t>(us * 1'000);
}
} // namespace time_units
} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_TIME_UNITS_H
5 changes: 2 additions & 3 deletions libc/src/__support/wctype_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@

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

#define __need_wint_t
#define __need_wchar_t
#include <stddef.h> // needed for wint_t and wchar_t

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {
namespace internal {

// ------------------------------------------------------
Expand Down Expand Up @@ -45,6 +44,6 @@ LIBC_INLINE cpp::optional<wint_t> btowc(int c) {
}

} // namespace internal
} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC___SUPPORT_WCTYPE_UTILS_H
5 changes: 2 additions & 3 deletions libc/src/assert/__assert_fail.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@
#ifndef LLVM_LIBC_SRC_ASSERT___ASSERT_FAIL_H
#define LLVM_LIBC_SRC_ASSERT___ASSERT_FAIL_H

#include "src/__support/macros/config.h"
#include <stddef.h>

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

[[noreturn]] void __assert_fail(const char *assertion, const char *file,
unsigned line, const char *function);

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC_ASSERT___ASSERT_FAIL_H
5 changes: 2 additions & 3 deletions libc/src/assert/generic/__assert_fail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
#include "src/assert/__assert_fail.h"
#include "src/__support/OSUtil/io.h"
#include "src/__support/libc_assert.h"
#include "src/__support/macros/config.h"
#include "src/stdlib/abort.h"

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(void, __assert_fail,
(const char *assertion, const char *file, unsigned line,
Expand All @@ -21,4 +20,4 @@ LLVM_LIBC_FUNCTION(void, __assert_fail,
LIBC_NAMESPACE::abort();
}

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE
5 changes: 2 additions & 3 deletions libc/src/assert/gpu/__assert_fail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
#include "src/__support/CPP/atomic.h"
#include "src/__support/GPU/utils.h"
#include "src/__support/libc_assert.h"
#include "src/__support/macros/config.h"
#include "src/stdlib/abort.h"

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

// A single-use lock to allow only a single thread to print the assertion.
static cpp::Atomic<uint32_t> lock = 0;
Expand All @@ -38,4 +37,4 @@ LLVM_LIBC_FUNCTION(void, __assert_fail,
LIBC_NAMESPACE::abort();
}

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE
5 changes: 2 additions & 3 deletions libc/src/ctype/isalnum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@
#include "src/__support/ctype_utils.h"

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

// TODO: Currently restricted to default locale.
// These should be extended using locale information.
LLVM_LIBC_FUNCTION(int, isalnum, (int c)) {
return static_cast<int>(internal::isalnum(static_cast<unsigned>(c)));
}

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE
6 changes: 2 additions & 4 deletions libc/src/ctype/isalnum.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
#ifndef LLVM_LIBC_SRC_CTYPE_ISALNUM_H
#define LLVM_LIBC_SRC_CTYPE_ISALNUM_H

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

int isalnum(int c);

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC_CTYPE_ISALNUM_H
5 changes: 2 additions & 3 deletions libc/src/ctype/isalpha.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

// TODO: Currently restricted to default locale.
// These should be extended using locale information.
LLVM_LIBC_FUNCTION(int, isalpha, (int c)) {
return static_cast<int>(internal::isalpha(static_cast<unsigned>(c)));
}

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE
6 changes: 2 additions & 4 deletions libc/src/ctype/isalpha.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
#ifndef LLVM_LIBC_SRC_CTYPE_ISALPHA_H
#define LLVM_LIBC_SRC_CTYPE_ISALPHA_H

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

int isalpha(int c);

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC_CTYPE_ISALPHA_H
5 changes: 2 additions & 3 deletions libc/src/ctype/isascii.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
#include "src/ctype/isascii.h"

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(int, isascii, (int c)) {
return static_cast<int>((c & (~0x7f)) == 0);
}

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE
5 changes: 2 additions & 3 deletions libc/src/ctype/isascii.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
#ifndef LLVM_LIBC_SRC_CTYPE_ISASCII_H
#define LLVM_LIBC_SRC_CTYPE_ISASCII_H

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

int isascii(int c);

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC_CTYPE_ISASCII_H
5 changes: 2 additions & 3 deletions libc/src/ctype/isblank.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@
#include "src/ctype/isblank.h"

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

// TODO: Currently restricted to default locale.
// These should be extended using locale information.
LLVM_LIBC_FUNCTION(int, isblank, (int c)) {
return static_cast<int>(c == ' ' || c == '\t');
}

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE
6 changes: 2 additions & 4 deletions libc/src/ctype/isblank.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
#ifndef LLVM_LIBC_SRC_CTYPE_ISBLANK_H
#define LLVM_LIBC_SRC_CTYPE_ISBLANK_H

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

int isblank(int c);

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC_CTYPE_ISBLANK_H
5 changes: 2 additions & 3 deletions libc/src/ctype/iscntrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
#include "src/ctype/iscntrl.h"

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

// TODO: Currently restricted to default locale.
// These should be extended using locale information.
Expand All @@ -20,4 +19,4 @@ LLVM_LIBC_FUNCTION(int, iscntrl, (int c)) {
return static_cast<int>(ch < 0x20 || ch == 0x7f);
}

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE
6 changes: 2 additions & 4 deletions libc/src/ctype/iscntrl.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
#ifndef LLVM_LIBC_SRC_CTYPE_ISCNTRL_H
#define LLVM_LIBC_SRC_CTYPE_ISCNTRL_H

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

int iscntrl(int c);

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC_CTYPE_ISCNTRL_H
5 changes: 2 additions & 3 deletions libc/src/ctype/isdigit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@
#include "src/ctype/isdigit.h"
#include "src/__support/common.h"
#include "src/__support/ctype_utils.h"
#include "src/__support/macros/config.h"

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

// TODO: Currently restricted to default locale.
// These should be extended using locale information.
LLVM_LIBC_FUNCTION(int, isdigit, (int c)) {
return static_cast<int>(internal::isdigit(static_cast<unsigned>(c)));
}

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE
6 changes: 2 additions & 4 deletions libc/src/ctype/isdigit.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
#ifndef LLVM_LIBC_SRC_CTYPE_ISDIGIT_H
#define LLVM_LIBC_SRC_CTYPE_ISDIGIT_H

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

int isdigit(int c);

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC_CTYPE_ISDIGIT_H
5 changes: 2 additions & 3 deletions libc/src/ctype/isgraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

// TODO: Currently restricted to default locale.
// These should be extended using locale information.
LLVM_LIBC_FUNCTION(int, isgraph, (int c)) {
return static_cast<int>(internal::isgraph(static_cast<unsigned>(c)));
}

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE
6 changes: 2 additions & 4 deletions libc/src/ctype/isgraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
#ifndef LLVM_LIBC_SRC_CTYPE_ISGRAPH_H
#define LLVM_LIBC_SRC_CTYPE_ISGRAPH_H

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

int isgraph(int c);

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC_CTYPE_ISGRAPH_H
5 changes: 2 additions & 3 deletions libc/src/ctype/islower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@
#include "src/__support/ctype_utils.h"

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

// TODO: Currently restricted to default locale.
// These should be extended using locale information.
LLVM_LIBC_FUNCTION(int, islower, (int c)) {
return static_cast<int>(internal::islower(static_cast<unsigned>(c)));
}

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE
6 changes: 2 additions & 4 deletions libc/src/ctype/islower.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
#ifndef LLVM_LIBC_SRC_CTYPE_ISLOWER_H
#define LLVM_LIBC_SRC_CTYPE_ISLOWER_H

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

int islower(int c);

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC_CTYPE_ISLOWER_H
5 changes: 2 additions & 3 deletions libc/src/ctype/isprint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
#include "src/ctype/isprint.h"

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

// TODO: Currently restricted to default locale.
// These should be extended using locale information.
Expand All @@ -20,4 +19,4 @@ LLVM_LIBC_FUNCTION(int, isprint, (int c)) {
return static_cast<int>((ch - ' ') < 95);
}

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE
6 changes: 2 additions & 4 deletions libc/src/ctype/isprint.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
#ifndef LLVM_LIBC_SRC_CTYPE_ISPRINT_H
#define LLVM_LIBC_SRC_CTYPE_ISPRINT_H

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

int isprint(int c);

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC_CTYPE_ISPRINT_H
5 changes: 2 additions & 3 deletions libc/src/ctype/ispunct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

// TODO: Currently restricted to default locale.
// These should be extended using locale information.
Expand All @@ -21,4 +20,4 @@ LLVM_LIBC_FUNCTION(int, ispunct, (int c)) {
return static_cast<int>(!internal::isalnum(ch) && internal::isgraph(ch));
}

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE
6 changes: 2 additions & 4 deletions libc/src/ctype/ispunct.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
#ifndef LLVM_LIBC_SRC_CTYPE_ISPUNCT_H
#define LLVM_LIBC_SRC_CTYPE_ISPUNCT_H

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

int ispunct(int c);

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC_CTYPE_ISPUNCT_H
5 changes: 2 additions & 3 deletions libc/src/ctype/isspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@
#include "src/__support/ctype_utils.h"

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

// TODO: Currently restricted to default locale.
// These should be extended using locale information.
LLVM_LIBC_FUNCTION(int, isspace, (int c)) {
return static_cast<int>(internal::isspace(static_cast<unsigned>(c)));
}

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE
6 changes: 2 additions & 4 deletions libc/src/ctype/isspace.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
#ifndef LLVM_LIBC_SRC_CTYPE_ISSPACE_H
#define LLVM_LIBC_SRC_CTYPE_ISSPACE_H

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

int isspace(int c);

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC_CTYPE_ISSPACE_H
5 changes: 2 additions & 3 deletions libc/src/ctype/isupper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@
#include "src/__support/ctype_utils.h"

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

// TODO: Currently restricted to default locale.
// These should be extended using locale information.
LLVM_LIBC_FUNCTION(int, isupper, (int c)) {
return static_cast<int>(internal::isupper(static_cast<unsigned>(c)));
}

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE
6 changes: 2 additions & 4 deletions libc/src/ctype/isupper.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
#ifndef LLVM_LIBC_SRC_CTYPE_ISUPPER_H
#define LLVM_LIBC_SRC_CTYPE_ISUPPER_H

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

int isupper(int c);

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC_CTYPE_ISUPPER_H
5 changes: 2 additions & 3 deletions libc/src/ctype/isxdigit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@
#include "src/__support/ctype_utils.h"

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

// TODO: Currently restricted to default locale.
// These should be extended using locale information.
Expand All @@ -21,4 +20,4 @@ LLVM_LIBC_FUNCTION(int, isxdigit, (int c)) {
return static_cast<int>(internal::isdigit(ch) || (ch | 32) - 'a' < 6);
}

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE
6 changes: 2 additions & 4 deletions libc/src/ctype/isxdigit.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
#ifndef LLVM_LIBC_SRC_CTYPE_ISXDIGIT_H
#define LLVM_LIBC_SRC_CTYPE_ISXDIGIT_H

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

int isxdigit(int c);

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC_CTYPE_ISXDIGIT_H
5 changes: 2 additions & 3 deletions libc/src/ctype/toascii.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
#include "src/ctype/toascii.h"

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(int, toascii, (int c)) { return (c & 0x7f); }

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE
6 changes: 2 additions & 4 deletions libc/src/ctype/toascii.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
#ifndef LLVM_LIBC_SRC_CTYPE_TOASCII_H
#define LLVM_LIBC_SRC_CTYPE_TOASCII_H

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

int toascii(int c);

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC_CTYPE_TOASCII_H
5 changes: 2 additions & 3 deletions libc/src/ctype/tolower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@
#include "src/__support/ctype_utils.h"

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

// TODO: Currently restricted to default locale.
// These should be extended using locale information.
LLVM_LIBC_FUNCTION(int, tolower, (int c)) { return internal::tolower(c); }

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE
6 changes: 2 additions & 4 deletions libc/src/ctype/tolower.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
#ifndef LLVM_LIBC_SRC_CTYPE_TOLOWER_H
#define LLVM_LIBC_SRC_CTYPE_TOLOWER_H

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

int tolower(int c);

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC_CTYPE_TOLOWER_H
5 changes: 2 additions & 3 deletions libc/src/ctype/toupper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@
#include "src/__support/ctype_utils.h"

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

// TODO: Currently restricted to default locale.
// These should be extended using locale information.
Expand All @@ -22,4 +21,4 @@ LLVM_LIBC_FUNCTION(int, toupper, (int c)) {
return c;
}

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE
6 changes: 2 additions & 4 deletions libc/src/ctype/toupper.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
#ifndef LLVM_LIBC_SRC_CTYPE_TOUPPER_H
#define LLVM_LIBC_SRC_CTYPE_TOUPPER_H

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

int toupper(int c);

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC_CTYPE_TOUPPER_H
5 changes: 2 additions & 3 deletions libc/src/dirent/closedir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@

#include "src/__support/File/dir.h"
#include "src/__support/common.h"
#include "src/__support/macros/config.h"
#include "src/errno/libc_errno.h"

#include <dirent.h>

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(int, closedir, (::DIR * dir)) {
auto *d = reinterpret_cast<LIBC_NAMESPACE::Dir *>(dir);
Expand All @@ -27,4 +26,4 @@ LLVM_LIBC_FUNCTION(int, closedir, (::DIR * dir)) {
return 0;
}

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE
5 changes: 2 additions & 3 deletions libc/src/dirent/closedir.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
#ifndef LLVM_LIBC_SRC_DIRENT_CLOSEDIR_H
#define LLVM_LIBC_SRC_DIRENT_CLOSEDIR_H

#include "src/__support/macros/config.h"
#include <dirent.h>

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

int closedir(::DIR *dir);

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC_DIRENT_CLOSEDIR_H
5 changes: 2 additions & 3 deletions libc/src/dirent/dirfd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@

#include "src/__support/File/dir.h"
#include "src/__support/common.h"
#include "src/__support/macros/config.h"

#include <dirent.h>

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(int, dirfd, (::DIR * dir)) {
auto *d = reinterpret_cast<LIBC_NAMESPACE::Dir *>(dir);
return d->getfd();
}

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE
5 changes: 2 additions & 3 deletions libc/src/dirent/dirfd.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
#ifndef LLVM_LIBC_SRC_DIRENT_DIRFD_H
#define LLVM_LIBC_SRC_DIRENT_DIRFD_H

#include "src/__support/macros/config.h"
#include <dirent.h>

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

int dirfd(::DIR *dir);

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC_DIRENT_DIRFD_H
5 changes: 2 additions & 3 deletions libc/src/dirent/opendir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@

#include "src/__support/File/dir.h"
#include "src/__support/common.h"
#include "src/__support/macros/config.h"
#include "src/errno/libc_errno.h"

#include <dirent.h>

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(::DIR *, opendir, (const char *name)) {
auto dir = Dir::open(name);
Expand All @@ -26,4 +25,4 @@ LLVM_LIBC_FUNCTION(::DIR *, opendir, (const char *name)) {
return reinterpret_cast<DIR *>(dir.value());
}

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE
5 changes: 2 additions & 3 deletions libc/src/dirent/opendir.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
#ifndef LLVM_LIBC_SRC_DIRENT_OPENDIR_H
#define LLVM_LIBC_SRC_DIRENT_OPENDIR_H

#include "src/__support/macros/config.h"
#include <dirent.h>

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

::DIR *opendir(const char *name);

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC_DIRENT_OPENDIR_H
5 changes: 2 additions & 3 deletions libc/src/dirent/readdir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@

#include "src/__support/File/dir.h"
#include "src/__support/common.h"
#include "src/__support/macros/config.h"
#include "src/errno/libc_errno.h"

#include <dirent.h>

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(struct ::dirent *, readdir, (::DIR * dir)) {
auto *d = reinterpret_cast<LIBC_NAMESPACE::Dir *>(dir);
Expand All @@ -27,4 +26,4 @@ LLVM_LIBC_FUNCTION(struct ::dirent *, readdir, (::DIR * dir)) {
return dirent_val.value();
}

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE
5 changes: 2 additions & 3 deletions libc/src/dirent/readdir.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
#ifndef LLVM_LIBC_SRC_DIRENT_READDIR_H
#define LLVM_LIBC_SRC_DIRENT_READDIR_H

#include "src/__support/macros/config.h"
#include <dirent.h>

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

struct ::dirent *readdir(DIR *dir);

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC_DIRENT_READDIR_H
5 changes: 2 additions & 3 deletions libc/src/dlfcn/dlclose.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@
#include "dlclose.h"

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

// TODO(@izaakschroeder): https://github.com/llvm/llvm-project/issues/97917
LLVM_LIBC_FUNCTION(int, dlclose, (void *)) { return -1; }

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE
6 changes: 2 additions & 4 deletions libc/src/dlfcn/dlclose.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
#ifndef LLVM_LIBC_SRC_DLFCN_DLCLOSE_H
#define LLVM_LIBC_SRC_DLFCN_DLCLOSE_H

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

int dlclose(void *);

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC_DLFCN_DLCLOSE_H
5 changes: 2 additions & 3 deletions libc/src/dlfcn/dlerror.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
#include "dlerror.h"

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

// TODO(@izaakschroeder): https://github.com/llvm/llvm-project/issues/97918
LLVM_LIBC_FUNCTION(char *, dlerror, ()) {
return const_cast<char *>("unsupported");
}

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE
6 changes: 2 additions & 4 deletions libc/src/dlfcn/dlerror.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
#ifndef LLVM_LIBC_SRC_DLFCN_DLERROR_H
#define LLVM_LIBC_SRC_DLFCN_DLERROR_H

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

char *dlerror();

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC_DLFCN_DLERROR_H
5 changes: 2 additions & 3 deletions libc/src/dlfcn/dlopen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@
#include "dlopen.h"

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

// TODO(@izaakschroeder): https://github.com/llvm/llvm-project/issues/97919
LLVM_LIBC_FUNCTION(void *, dlopen, (const char *, int)) { return nullptr; }

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE
6 changes: 2 additions & 4 deletions libc/src/dlfcn/dlopen.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
#ifndef LLVM_LIBC_SRC_DLFCN_DLOPEN_H
#define LLVM_LIBC_SRC_DLFCN_DLOPEN_H

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

void *dlopen(const char *, int);

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC_DLFCN_DLOPEN_H
5 changes: 2 additions & 3 deletions libc/src/dlfcn/dlsym.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@
#include "dlsym.h"

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

// TODO(@izaakschroeder): https://github.com/llvm/llvm-project/issues/97920
LLVM_LIBC_FUNCTION(void *, dlsym, (void *, const char *)) { return nullptr; }

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE
6 changes: 2 additions & 4 deletions libc/src/dlfcn/dlsym.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
#ifndef LLVM_LIBC_SRC_DLFCN_DLSYM_H
#define LLVM_LIBC_SRC_DLFCN_DLSYM_H

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

void *dlsym(void *, const char *);

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC_DLFCN_DLSYM_H
5 changes: 2 additions & 3 deletions libc/src/errno/libc_errno.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#include "libc_errno.h"
#include "src/__support/CPP/atomic.h"
#include "src/__support/macros/config.h"

#ifdef LIBC_TARGET_ARCH_IS_GPU
// LIBC_THREAD_LOCAL on GPU currently does nothing. So essentially this is just
Expand Down Expand Up @@ -47,7 +46,7 @@ LIBC_NAMESPACE::Errno::operator int() { return errno; }

#endif // LIBC_FULL_BUILD

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {
// Define the global `libc_errno` instance.
Errno libc_errno;
} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE
5 changes: 2 additions & 3 deletions libc/src/errno/libc_errno.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#define LLVM_LIBC_SRC_ERRNO_LIBC_ERRNO_H

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

#include "hdr/errno_macros.h"
Expand All @@ -31,14 +30,14 @@
// - Use regular `errno` in the code
// - Still depend on libc.src.errno.errno

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {
struct Errno {
void operator=(int);
operator int();
};

extern Errno libc_errno;

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC_ERRNO_LIBC_ERRNO_H
5 changes: 2 additions & 3 deletions libc/src/fcntl/creat.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
#ifndef LLVM_LIBC_SRC_FCNTL_CREAT_H
#define LLVM_LIBC_SRC_FCNTL_CREAT_H

#include "src/__support/macros/config.h"
#include <fcntl.h>

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

int creat(const char *path, int mode);

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC_FCNTL_CREAT_H
6 changes: 2 additions & 4 deletions libc/src/fcntl/fcntl.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
#ifndef LLVM_LIBC_SRC_FCNTL_FCNTL_H
#define LLVM_LIBC_SRC_FCNTL_FCNTL_H

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

int fcntl(int fd, int cmd, ...);

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC_FCNTL_FCNTL_H
5 changes: 2 additions & 3 deletions libc/src/fcntl/linux/creat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@

#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
#include "src/__support/macros/config.h"
#include "src/errno/libc_errno.h"

#include <fcntl.h>
#include <sys/syscall.h> // For syscall numbers.

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(int, creat, (const char *path, int mode_flags)) {
#ifdef SYS_open
Expand All @@ -34,4 +33,4 @@ LLVM_LIBC_FUNCTION(int, creat, (const char *path, int mode_flags)) {
return -1;
}

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE
5 changes: 2 additions & 3 deletions libc/src/fcntl/linux/fcntl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@

#include "src/__support/OSUtil/fcntl.h"
#include "src/__support/common.h"
#include "src/__support/macros/config.h"

#include <stdarg.h>

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(int, fcntl, (int fd, int cmd, ...)) {
void *arg;
Expand All @@ -25,4 +24,4 @@ LLVM_LIBC_FUNCTION(int, fcntl, (int fd, int cmd, ...)) {
return LIBC_NAMESPACE::internal::fcntl(fd, cmd, arg);
}

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE
5 changes: 2 additions & 3 deletions libc/src/fcntl/linux/open.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@

#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
#include "src/__support/macros/config.h"
#include "src/errno/libc_errno.h"

#include <fcntl.h>
#include <stdarg.h>
#include <sys/syscall.h> // For syscall numbers.

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(int, open, (const char *path, int flags, ...)) {
mode_t mode_flags = 0;
Expand All @@ -43,4 +42,4 @@ LLVM_LIBC_FUNCTION(int, open, (const char *path, int flags, ...)) {
return -1;
}

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE
5 changes: 2 additions & 3 deletions libc/src/fcntl/linux/openat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@

#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
#include "src/__support/macros/config.h"
#include "src/errno/libc_errno.h"

#include <fcntl.h>
#include <stdarg.h>
#include <sys/syscall.h> // For syscall numbers.

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(int, openat, (int dfd, const char *path, int flags, ...)) {
mode_t mode_flags = 0;
Expand All @@ -39,4 +38,4 @@ LLVM_LIBC_FUNCTION(int, openat, (int dfd, const char *path, int flags, ...)) {
return -1;
}

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE
5 changes: 2 additions & 3 deletions libc/src/fcntl/open.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
#ifndef LLVM_LIBC_SRC_FCNTL_OPEN_H
#define LLVM_LIBC_SRC_FCNTL_OPEN_H

#include "src/__support/macros/config.h"
#include <fcntl.h>

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

int open(const char *path, int flags, ...);

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC_FCNTL_OPEN_H
5 changes: 2 additions & 3 deletions libc/src/fcntl/openat.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
#ifndef LLVM_LIBC_SRC_FCNTL_OPENAT_H
#define LLVM_LIBC_SRC_FCNTL_OPENAT_H

#include "src/__support/macros/config.h"
#include <fcntl.h>

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

int openat(int dfd, const char *path, int flags, ...);

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC_FCNTL_OPENAT_H
5 changes: 2 additions & 3 deletions libc/src/fenv/feclearexcept.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
#include "src/fenv/feclearexcept.h"
#include "src/__support/FPUtil/FEnvImpl.h"
#include "src/__support/common.h"
#include "src/__support/macros/config.h"

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(int, feclearexcept, (int e)) {
return fputil::clear_except(e);
}

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE
6 changes: 2 additions & 4 deletions libc/src/fenv/feclearexcept.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
#ifndef LLVM_LIBC_SRC_FENV_FECLEAREXCEPT_H
#define LLVM_LIBC_SRC_FENV_FECLEAREXCEPT_H

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

int feclearexcept(int);

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC_FENV_FECLEAREXCEPT_H
5 changes: 2 additions & 3 deletions libc/src/fenv/fedisableexcept.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
#include "src/fenv/fedisableexcept.h"
#include "src/__support/FPUtil/FEnvImpl.h"
#include "src/__support/common.h"
#include "src/__support/macros/config.h"

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(int, fedisableexcept, (int e)) {
return fputil::disable_except(e);
}

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE
6 changes: 2 additions & 4 deletions libc/src/fenv/fedisableexcept.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
#ifndef LLVM_LIBC_SRC_FENV_FEDISABLEEXCEPT_H
#define LLVM_LIBC_SRC_FENV_FEDISABLEEXCEPT_H

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

int fedisableexcept(int);

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC_FENV_FEDISABLEEXCEPT_H
5 changes: 2 additions & 3 deletions libc/src/fenv/feenableexcept.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
#include "src/fenv/feenableexcept.h"
#include "src/__support/FPUtil/FEnvImpl.h"
#include "src/__support/common.h"
#include "src/__support/macros/config.h"

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(int, feenableexcept, (int e)) {
return fputil::enable_except(e);
}

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE
6 changes: 2 additions & 4 deletions libc/src/fenv/feenableexcept.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
#ifndef LLVM_LIBC_SRC_FENV_FEENABLEEXCEPT_H
#define LLVM_LIBC_SRC_FENV_FEENABLEEXCEPT_H

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

int feenableexcept(int);

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC_FENV_FEENABLEEXCEPT_H
5 changes: 2 additions & 3 deletions libc/src/fenv/fegetenv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
#include "src/fenv/fegetenv.h"
#include "src/__support/FPUtil/FEnvImpl.h"
#include "src/__support/common.h"
#include "src/__support/macros/config.h"

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(int, fegetenv, (fenv_t * envp)) {
return fputil::get_env(envp);
}

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE
5 changes: 2 additions & 3 deletions libc/src/fenv/fegetenv.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@
#define LLVM_LIBC_SRC_FENV_FEGETENV_H

#include "hdr/types/fenv_t.h"
#include "src/__support/macros/config.h"

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

int fegetenv(fenv_t *);

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC_FENV_FEGETENV_H
5 changes: 2 additions & 3 deletions libc/src/fenv/fegetexcept.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
#include "src/fenv/fegetexcept.h"
#include "src/__support/FPUtil/FEnvImpl.h"
#include "src/__support/common.h"
#include "src/__support/macros/config.h"

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(int, fegetexcept, ()) { return fputil::get_except(); }

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE
6 changes: 2 additions & 4 deletions libc/src/fenv/fegetexcept.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
#ifndef LLVM_LIBC_SRC_FENV_FEGETEXCEPT_H
#define LLVM_LIBC_SRC_FENV_FEGETEXCEPT_H

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

namespace LIBC_NAMESPACE_DECL {
namespace LIBC_NAMESPACE {

int fegetexcept();

} // namespace LIBC_NAMESPACE_DECL
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC_FENV_FEGETEXCEPT_H
Loading