Rename preprocessor definitions that control tuning of llvm libc.
Differential Revision: https://reviews.llvm.org/D143913
target_compile_options(${gpu_target_name} PRIVATE ${compile_options})
target_include_directories(${gpu_target_name} PRIVATE ${include_dirs})
add_dependencies(${gpu_target_name} ${ADD_GPU_ENTRYPOINT_OBJ_DEPENDS})
- target_compile_definitions(${gpu_target_name} PRIVATE LLVM_LIBC_PUBLIC_PACKAGING)
+ target_compile_definitions(${gpu_target_name} PRIVATE LIBC_COPT_PUBLIC_PACKAGING)
# Append this target to a list of images to package into a single binary.
set(input_file $<TARGET_OBJECTS:${gpu_target_name}>)
${ADD_ENTRYPOINT_OBJ_SRCS}
${ADD_ENTRYPOINT_OBJ_HDRS}
)
- target_compile_options(${fq_target_name} BEFORE PRIVATE ${common_compile_options} -DLLVM_LIBC_PUBLIC_PACKAGING)
+ target_compile_options(${fq_target_name} BEFORE PRIVATE ${common_compile_options} -DLIBC_COPT_PUBLIC_PACKAGING)
target_include_directories(${fq_target_name} PRIVATE ${include_dirs})
add_dependencies(${fq_target_name} ${full_deps_list})
if(LLVM_USE_SANITIZER)
message(FATAL_ERROR "LIBC_UNSAFE_STRING_WIDE_READ is set at the same time as a sanitizer. LIBC_UNSAFE_STRING_WIDE_READ causes strlen and memchr to read beyond the end of their target strings, which is undefined behavior caught by sanitizers.")
else()
- list(APPEND LIBC_COMMON_TUNE_OPTIONS "-DLIBC_UNSAFE_STRING_WIDE_READ")
+ list(APPEND LIBC_COMMON_TUNE_OPTIONS "-DLIBC_COPT_UNSAFE_STRING_WIDE_READ")
endif()
endif()
libc.src.stdlib.strtoul
libc.src.stdlib.strtoull
COMPILE_OPTIONS
- -DLLVM_LIBC_FUZZ_ATOI_CLEANER_INPUT
+ -DLIBC_COPT_FUZZ_ATOI_CLEANER_INPUT
)
add_libc_fuzzer(
size_t i;
for (i = 0; i < size; ++i) {
-#ifdef LLVM_LIBC_FUZZ_ATOI_CLEANER_INPUT
+#ifdef LIBC_COPT_FUZZ_ATOI_CLEANER_INPUT
container[i] = VALID_CHARS[data[i] % sizeof(VALID_CHARS)];
#else
container[i] = data[i];
#endif
// GPU targets do not support aliasing.
-#if defined(LLVM_LIBC_PUBLIC_PACKAGING) && defined(LIBC_TARGET_ARCH_IS_GPU)
+#if defined(LIBC_COPT_PUBLIC_PACKAGING) && defined(LIBC_TARGET_ARCH_IS_GPU)
#define LLVM_LIBC_FUNCTION(type, name, arglist) \
LLVM_LIBC_FUNCTION_ATTR decltype(__llvm_libc::name) \
__##name##_impl__ __asm__(#name); \
type __##name##_impl__ arglist
// MacOS needs to be excluded because it does not support aliasing.
-#elif defined(LLVM_LIBC_PUBLIC_PACKAGING) && (!defined(__APPLE__))
+#elif defined(LIBC_COPT_PUBLIC_PACKAGING) && (!defined(__APPLE__))
#define LLVM_LIBC_FUNCTION(type, name, arglist) \
LLVM_LIBC_FUNCTION_ATTR decltype(__llvm_libc::name) \
__##name##_impl__ __asm__(#name); \
return;
}
-#ifndef LLVM_LIBC_DISABLE_CLINGER_FAST_PATH
+#ifndef LIBC_COPT_STRTOFLOAT_DISABLE_CLINGER_FAST_PATH
if (!truncated) {
if (clinger_fast_path<T>(mantissa, exp10, outputMantissa, outputExp2)) {
return;
}
}
-#endif // LLVM_LIBC_DISABLE_CLINGER_FAST_PATH
+#endif // LIBC_COPT_STRTOFLOAT_DISABLE_CLINGER_FAST_PATH
-#ifndef LLVM_LIBC_DISABLE_EISEL_LEMIRE
+#ifndef LIBC_COPT_STRTOFLOAT_DISABLE_EISEL_LEMIRE
// Try Eisel-Lemire
if (eisel_lemire<T>(mantissa, exp10, outputMantissa, outputExp2)) {
if (!truncated) {
}
}
}
-#endif // LLVM_LIBC_DISABLE_EISEL_LEMIRE
+#endif // LIBC_COPT_STRTOFLOAT_DISABLE_EISEL_LEMIRE
-#ifndef LLVM_LIBC_DISABLE_SIMPLE_DECIMAL_CONVERSION
+#ifndef LIBC_COPT_STRTOFLOAT_DISABLE_SIMPLE_DECIMAL_CONVERSION
simple_decimal_conversion<T>(numStart, outputMantissa, outputExp2);
-#endif // LLVM_LIBC_DISABLE_SIMPLE_DECIMAL_CONVERSION
+#else
+#warning "Simple decimal conversion is disabled, result may not be correct."
+#endif // LIBC_COPT_STRTOFLOAT_DISABLE_SIMPLE_DECIMAL_CONVERSION
return;
}
// This option allows for replacing all of the conversion functions with custom
// replacements. This allows conversions to be replaced at compile time.
-#ifndef LLVM_LIBC_PRINTF_CONV_ATLAS
+#ifndef LIBC_COPT_PRINTF_CONV_ATLAS
#include "src/stdio/printf_core/converter_atlas.h"
#else
-#include LLVM_LIBC_PRINTF_CONV_ATLAS
+#include LIBC_COPT_PRINTF_CONV_ATLAS
#endif
#include <stddef.h>
case 'x':
case 'X':
return convert_int(writer, to_conv);
-#ifndef LLVM_LIBC_PRINTF_DISABLE_FLOAT
+#ifndef LIBC_COPT_PRINTF_DISABLE_FLOAT
case 'f':
case 'F':
return convert_float_decimal(writer, to_conv);
case 'g':
case 'G':
return convert_float_dec_auto(writer, to_conv);
-#endif // LLVM_LIBC_PRINTF_DISABLE_FLOAT
-#ifndef LLVM_LIBC_PRINTF_DISABLE_WRITE_INT
+#endif // LIBC_COPT_PRINTF_DISABLE_FLOAT
+#ifndef LIBC_COPT_PRINTF_DISABLE_WRITE_INT
case 'n':
return convert_write_int(writer, to_conv);
-#endif // LLVM_LIBC_PRINTF_DISABLE_WRITE_INT
+#endif // LIBC_COPT_PRINTF_DISABLE_WRITE_INT
case 'p':
return convert_pointer(writer, to_conv);
default:
// defines convert_int
#include "src/stdio/printf_core/int_converter.h"
-#ifndef LLVM_LIBC_PRINTF_DISABLE_FLOAT
+#ifndef LIBC_COPT_PRINTF_DISABLE_FLOAT
// defines convert_float_decimal
// defines convert_float_dec_exp
// defines convert_float_dec_auto
#include "src/stdio/printf_core/float_dec_converter.h"
// defines convert_float_hex_exp
#include "src/stdio/printf_core/float_hex_converter.h"
-#endif // LLVM_LIBC_PRINTF_DISABLE_FLOAT
+#endif // LIBC_COPT_PRINTF_DISABLE_FLOAT
-#ifndef LLVM_LIBC_PRINTF_DISABLE_WRITE_INT
+#ifndef LIBC_COPT_PRINTF_DISABLE_WRITE_INT
#include "src/stdio/printf_core/write_int_converter.h"
-#endif // LLVM_LIBC_PRINTF_DISABLE_WRITE_INT
+#endif // LIBC_COPT_PRINTF_DISABLE_WRITE_INT
// defines convert_pointer
#include "src/stdio/printf_core/ptr_converter.h"
//
//===----------------------------------------------------------------------===//
-// #define LLVM_LIBC_PRINTF_DISABLE_INDEX_MODE 1 // This will be a compile flag.
+// #define LIBC_COPT_PRINTF_DISABLE_INDEX_MODE 1 // This will be a compile flag.
#include "parser.h"
namespace __llvm_libc {
namespace printf_core {
-#ifndef LLVM_LIBC_PRINTF_DISABLE_INDEX_MODE
+#ifndef LIBC_COPT_PRINTF_DISABLE_INDEX_MODE
#define GET_ARG_VAL_SIMPLEST(arg_type, index) get_arg_value<arg_type>(index)
#else
#define GET_ARG_VAL_SIMPLEST(arg_type, _) get_next_arg_value<arg_type>()
-#endif // LLVM_LIBC_PRINTF_DISABLE_INDEX_MODE
+#endif // LIBC_COPT_PRINTF_DISABLE_INDEX_MODE
FormatSection Parser::get_next_section() {
FormatSection section;
++cur_pos;
[[maybe_unused]] size_t conv_index = 0;
-#ifndef LLVM_LIBC_PRINTF_DISABLE_INDEX_MODE
+#ifndef LIBC_COPT_PRINTF_DISABLE_INDEX_MODE
conv_index = parse_index(&cur_pos);
-#endif // LLVM_LIBC_PRINTF_DISABLE_INDEX_MODE
+#endif // LIBC_COPT_PRINTF_DISABLE_INDEX_MODE
section.flags = parse_flags(&cur_pos);
break;
}
break;
-#ifndef LLVM_LIBC_PRINTF_DISABLE_FLOAT
+#ifndef LIBC_COPT_PRINTF_DISABLE_FLOAT
case ('f'):
case ('F'):
case ('e'):
cpp::bit_cast<fputil::FPBits<long double>::UIntType>(
GET_ARG_VAL_SIMPLEST(long double, conv_index));
break;
-#endif // LLVM_LIBC_PRINTF_DISABLE_FLOAT
-#ifndef LLVM_LIBC_PRINTF_DISABLE_WRITE_INT
+#endif // LIBC_COPT_PRINTF_DISABLE_FLOAT
+#ifndef LIBC_COPT_PRINTF_DISABLE_WRITE_INT
case ('n'):
-#endif // LLVM_LIBC_PRINTF_DISABLE_WRITE_INT
+#endif // LIBC_COPT_PRINTF_DISABLE_WRITE_INT
case ('p'):
case ('s'):
section.conv_val_ptr = GET_ARG_VAL_SIMPLEST(void *, conv_index);
// INDEX MODE ONLY FUNCTIONS AFTER HERE:
//----------------------------------------------------
-#ifndef LLVM_LIBC_PRINTF_DISABLE_INDEX_MODE
+#ifndef LIBC_COPT_PRINTF_DISABLE_INDEX_MODE
size_t Parser::parse_index(size_t *local_pos) {
if (internal::isdigit(str[*local_pos])) {
break;
}
break;
-#ifndef LLVM_LIBC_PRINTF_DISABLE_FLOAT
+#ifndef LIBC_COPT_PRINTF_DISABLE_FLOAT
case ('f'):
case ('F'):
case ('e'):
else
conv_size = type_desc_from_type<long double>();
break;
-#endif // LLVM_LIBC_PRINTF_DISABLE_FLOAT
-#ifndef LLVM_LIBC_PRINTF_DISABLE_WRITE_INT
+#endif // LIBC_COPT_PRINTF_DISABLE_FLOAT
+#ifndef LIBC_COPT_PRINTF_DISABLE_WRITE_INT
case ('n'):
-#endif // LLVM_LIBC_PRINTF_DISABLE_WRITE_INT
+#endif // LIBC_COPT_PRINTF_DISABLE_WRITE_INT
case ('p'):
case ('s'):
conv_size = type_desc_from_type<void *>();
args_cur.next_var<uint32_t>();
else if (cur_type_desc == type_desc_from_type<uint64_t>())
args_cur.next_var<uint64_t>();
-#ifndef LLVM_LIBC_PRINTF_DISABLE_FLOAT
+#ifndef LIBC_COPT_PRINTF_DISABLE_FLOAT
// Floating point numbers are stored separately from the other arguments.
else if (cur_type_desc == type_desc_from_type<double>())
args_cur.next_var<double>();
else if (cur_type_desc == type_desc_from_type<long double>())
args_cur.next_var<long double>();
-#endif // LLVM_LIBC_PRINTF_DISABLE_FLOAT
+#endif // LIBC_COPT_PRINTF_DISABLE_FLOAT
// pointers may be stored separately from normal values.
else if (cur_type_desc == type_desc_from_type<void *>())
args_cur.next_var<void *>();
}
}
-#endif // LLVM_LIBC_PRINTF_DISABLE_INDEX_MODE
+#endif // LIBC_COPT_PRINTF_DISABLE_INDEX_MODE
} // namespace printf_core
} // namespace __llvm_libc
size_t cur_pos = 0;
internal::ArgList args_cur;
-#ifndef LLVM_LIBC_PRINTF_DISABLE_INDEX_MODE
+#ifndef LIBC_COPT_PRINTF_DISABLE_INDEX_MODE
// args_start stores the start of the va_args, which is allows getting the
// value of arguments that have already been passed. args_index is tracked so
// that we know which argument args_cur is on.
size_t args_index = 1;
// Defined in printf_config.h
- static constexpr size_t DESC_ARR_LEN = LLVM_LIBC_PRINTF_INDEX_ARR_LEN;
+ static constexpr size_t DESC_ARR_LEN = LIBC_COPT_PRINTF_INDEX_ARR_LEN;
// desc_arr stores the sizes of the variables in the ArgList. This is used in
// index mode to reduce repeated string parsing. The sizes are stored as
// TODO: Look into object stores for optimization.
-#endif // LLVM_LIBC_PRINTF_DISABLE_INDEX_MODE
+#endif // LIBC_COPT_PRINTF_DISABLE_INDEX_MODE
public:
-#ifndef LLVM_LIBC_PRINTF_DISABLE_INDEX_MODE
+#ifndef LIBC_COPT_PRINTF_DISABLE_INDEX_MODE
LIBC_INLINE Parser(const char *__restrict new_str, internal::ArgList &args)
: str(new_str), args_cur(args), args_start(args) {}
#else
LIBC_INLINE Parser(const char *__restrict new_str, internal::ArgList &args)
: str(new_str), args_cur(args) {}
-#endif // LLVM_LIBC_PRINTF_DISABLE_INDEX_MODE
+#endif // LIBC_COPT_PRINTF_DISABLE_INDEX_MODE
// get_next_section will parse the format string until it has a fully
// specified format section. This can either be a raw format section with no
// INDEX MODE ONLY FUNCTIONS AFTER HERE:
//----------------------------------------------------
-#ifndef LLVM_LIBC_PRINTF_DISABLE_INDEX_MODE
+#ifndef LIBC_COPT_PRINTF_DISABLE_INDEX_MODE
// parse_index parses the index of a value inside a format string. It
// assumes that str[*local_pos] points to character after a '%' or '*', and
// modify cur_pos.
TypeDesc get_type_desc(size_t index);
-#endif // LLVM_LIBC_PRINTF_DISABLE_INDEX_MODE
+#endif // LIBC_COPT_PRINTF_DISABLE_INDEX_MODE
};
} // namespace printf_core
// the index array is 10, then when the 20th index is requested the first 10
// types can be found immediately, and then the format string must be parsed 10
// times to find the types of the next 10 arguments.
-#ifndef LLVM_LIBC_PRINTF_INDEX_ARR_LEN
-#define LLVM_LIBC_PRINTF_INDEX_ARR_LEN 128
+#ifndef LIBC_COPT_PRINTF_INDEX_ARR_LEN
+#define LIBC_COPT_PRINTF_INDEX_ARR_LEN 128
#endif
// TODO(michaelrj): Move the other printf configuration options into this file.
#include "src/stdio/scanf_core/core_structs.h"
#include "src/stdio/scanf_core/reader.h"
-#ifndef LLVM_LIBC_SCANF_DISABLE_FLOAT
+#ifndef LIBC_COPT_SCANF_DISABLE_FLOAT
#include "src/stdio/scanf_core/float_converter.h"
-#endif // LLVM_LIBC_SCANF_DISABLE_FLOAT
+#endif // LIBC_COPT_SCANF_DISABLE_FLOAT
#include "src/stdio/scanf_core/current_pos_converter.h"
#include "src/stdio/scanf_core/int_converter.h"
#include "src/stdio/scanf_core/ptr_converter.h"
if (ret_val != READ_OK)
return ret_val;
return convert_int(reader, to_conv);
-#ifndef LLVM_LIBC_SCANF_DISABLE_FLOAT
+#ifndef LIBC_COPT_SCANF_DISABLE_FLOAT
case 'f':
case 'F':
case 'e':
if (ret_val != READ_OK)
return ret_val;
return convert_float(reader, to_conv);
-#endif // LLVM_LIBC_SCANF_DISABLE_FLOAT
+#endif // LIBC_COPT_SCANF_DISABLE_FLOAT
case 'n':
return convert_current_pos(reader, to_conv);
case 'p':
//
//===----------------------------------------------------------------------===//
-// #define LLVM_LIBC_SCANF_DISABLE_INDEX_MODE 1 // This will be a compile flag.
+// #define LIBC_COPT_SCANF_DISABLE_INDEX_MODE 1 // This will be a compile flag.
#include "src/stdio/scanf_core/parser.h"
namespace __llvm_libc {
namespace scanf_core {
-#ifndef LLVM_LIBC_SCANF_DISABLE_INDEX_MODE
+#ifndef LIBC_COPT_SCANF_DISABLE_INDEX_MODE
#define GET_ARG_VAL_SIMPLEST(arg_type, index) get_arg_value<arg_type>(index)
#else
#define GET_ARG_VAL_SIMPLEST(arg_type, _) get_next_arg_value<arg_type>()
-#endif // LLVM_LIBC_SCANF_DISABLE_INDEX_MODE
+#endif // LIBC_COPT_SCANF_DISABLE_INDEX_MODE
FormatSection Parser::get_next_section() {
FormatSection section;
++cur_pos;
[[maybe_unused]] size_t conv_index = 0;
-#ifndef LLVM_LIBC_SCANF_DISABLE_INDEX_MODE
+#ifndef LIBC_COPT_SCANF_DISABLE_INDEX_MODE
conv_index = parse_index(&cur_pos);
-#endif // LLVM_LIBC_SCANF_DISABLE_INDEX_MODE
+#endif // LIBC_COPT_SCANF_DISABLE_INDEX_MODE
if (str[cur_pos] == '*') {
++cur_pos;
// INDEX MODE ONLY FUNCTIONS AFTER HERE:
//----------------------------------------------------
-#ifndef LLVM_LIBC_SCANF_DISABLE_INDEX_MODE
+#ifndef LIBC_COPT_SCANF_DISABLE_INDEX_MODE
size_t Parser::parse_index(size_t *local_pos) {
if (internal::isdigit(str[*local_pos])) {
}
}
-#endif // LLVM_LIBC_SCANF_DISABLE_INDEX_MODE
+#endif // LIBC_COPT_SCANF_DISABLE_INDEX_MODE
} // namespace scanf_core
} // namespace __llvm_libc
size_t cur_pos = 0;
internal::ArgList args_cur;
-#ifndef LLVM_LIBC_SCANF_DISABLE_INDEX_MODE
+#ifndef LIBC_COPT_SCANF_DISABLE_INDEX_MODE
// args_start stores the start of the va_args, which is used when a previous
// argument is needed. In that case, we have to read the arguments from the
// beginning since they don't support reading backwards.
internal::ArgList args_start;
size_t args_index = 1;
-#endif // LLVM_LIBC_SCANF_DISABLE_INDEX_MODE
+#endif // LIBC_COPT_SCANF_DISABLE_INDEX_MODE
public:
-#ifndef LLVM_LIBC_SCANF_DISABLE_INDEX_MODE
+#ifndef LIBC_COPT_SCANF_DISABLE_INDEX_MODE
LIBC_INLINE Parser(const char *__restrict new_str, internal::ArgList &args)
: str(new_str), args_cur(args), args_start(args) {}
#else
LIBC_INLINE Parser(const char *__restrict new_str, internal::ArgList &args)
: str(new_str), args_cur(args) {}
-#endif // LLVM_LIBC_SCANF_DISABLE_INDEX_MODE
+#endif // LIBC_COPT_SCANF_DISABLE_INDEX_MODE
// get_next_section will parse the format string until it has a fully
// specified format section. This can either be a raw format section with no
// INDEX MODE ONLY FUNCTIONS AFTER HERE:
//----------------------------------------------------
-#ifndef LLVM_LIBC_SCANF_DISABLE_INDEX_MODE
+#ifndef LIBC_COPT_SCANF_DISABLE_INDEX_MODE
// parse_index parses the index of a value inside a format string. It
// assumes that str[*local_pos] points to character after a '%' or '*', and
// case an O(n^2) operation.
void args_to_index(size_t index);
-#endif // LLVM_LIBC_SCANF_DISABLE_INDEX_MODE
+#endif // LIBC_COPT_SCANF_DISABLE_INDEX_MODE
};
} // namespace scanf_core
// This flag disables all functionality relating to floating point numbers. This
// can be useful for embedded systems or other situations where binary size is
// important.
-// #define LLVM_LIBC_SCANF_DISABLE_FLOAT
+// #define LIBC_COPT_SCANF_DISABLE_FLOAT
// This flag disables index mode, a posix extension often used for
// internationalization of format strings. Supporting it takes up additional
// memory and parsing time, so it can be disabled if it's not used.
-// #define LLVM_LIBC_SCANF_DISABLE_INDEX_MODE
+// #define LIBC_COPT_SCANF_DISABLE_INDEX_MODE
#endif // LLVM_LIBC_SRC_STDIO_SCANF_CORE_SCANF_CONFIG_H
constexpr AtExitUnit(AtExitCallback *c, void *p) : callback(c), payload(p) {}
};
-#ifdef LLVM_LIBC_PUBLIC_PACKAGING
+#ifdef LIBC_COPT_PUBLIC_PACKAGING
using ExitCallbackList = cpp::ReverseOrderBlockStore<AtExitUnit, 32>;
#else
// BlockStore uses dynamic memory allocation. To avoid dynamic memory
// deps also (some of which are not yet available in LLVM libc) into the
// integration tests.
using ExitCallbackList = FixedVector<AtExitUnit, CALLBACK_LIST_SIZE_FOR_TESTS>;
-#endif // LLVM_LIBC_PUBLIC_PACKAGING
+#endif // LIBC_COPT_PUBLIC_PACKAGING
constinit ExitCallbackList exit_callbacks;
// Returns the length of a string, denoted by the first occurrence
// of a null terminator.
LIBC_INLINE size_t string_length(const char *src) {
-#ifdef LIBC_UNSAFE_STRING_WIDE_READ
+#ifdef LIBC_COPT_UNSAFE_STRING_WIDE_READ
// Unsigned int is the default size for most processors, and on x86-64 it
// performs better than larger sizes when the src pointer can't be assumed to
// be aligned to a word boundary, so it's the size we use for reading the
// 'src'. If 'ch' is not found, returns nullptr.
LIBC_INLINE void *find_first_character(const unsigned char *src,
unsigned char ch, size_t max_strlen) {
-#ifdef LIBC_UNSAFE_STRING_WIDE_READ
+#ifdef LIBC_COPT_UNSAFE_STRING_WIDE_READ
// If the maximum size of the string is small, the overhead of aligning to a
// word boundary and generating a bitmask of the appropriate size may be
// greater than the gains from reading larger chunks. Based on some testing,
&impl::optopt, &optpos,
impl::opterr, reinterpret_cast<FILE *>(__llvm_libc::stderr)};
-#ifndef LLVM_LIBC_PUBLIC_PACKAGING
+#ifndef LIBC_COPT_PUBLIC_PACKAGING
// This is used exclusively in tests.
void set_getopt_state(char **optarg, int *optind, int *optopt, unsigned *optpos,
int opterr, FILE *errstream) {
#ifndef LLVM_LIBC_UTILS_UNITTEST_FPEXCEPTMATCHER_H
#define LLVM_LIBC_UTILS_UNITTEST_FPEXCEPTMATCHER_H
-#ifndef LLVM_LIBC_TEST_USE_FUCHSIA
+#ifndef LIBC_COPT_TEST_USE_FUCHSIA
#include "test/UnitTest/Test.h"
func)))
#else
#define ASSERT_RAISES_FP_EXCEPT(func) ASSERT_DEATH(func, WITH_SIGNAL(SIGFPE))
-#endif // LLVM_LIBC_TEST_USE_FUCHSIA
+#endif // LIBC_COPT_TEST_USE_FUCHSIA
#endif // LLVM_LIBC_UTILS_UNITTEST_FPEXCEPTMATCHER_H
#ifndef LLVM_LIBC_UTILS_UNITTEST_TEST_H
#define LLVM_LIBC_UTILS_UNITTEST_TEST_H
-#ifdef LLVM_LIBC_TEST_USE_FUCHSIA
+#ifdef LIBC_COPT_TEST_USE_FUCHSIA
#include "FuchsiaTest.h"
#else
#include "LibcTest.h"
void do_infinity_and_na_n_test(RoundToIntegerFunc func) {
test_one_input(func, inf, INTEGER_MAX, true);
test_one_input(func, neg_inf, INTEGER_MIN, true);
-#if LLVM_LIBC_IMPLEMENTATION_DEFINED_TEST_BEHAVIOR
+ // This is currently never enabled, the
+ // LLVM_LIBC_IMPLEMENTATION_DEFINED_TEST_BEHAVIOR CMake option in
+ // libc/CMakeLists.txt is not forwarded to C++.
+#if LIBC_COPT_IMPLEMENTATION_DEFINED_TEST_BEHAVIOR
// Result is not well-defined, we always returns INTEGER_MAX
test_one_input(func, nan, INTEGER_MAX, true);
-#endif
+#endif // LIBC_COPT_IMPLEMENTATION_DEFINED_TEST_BEHAVIOR
}
void testInfinityAndNaN(RoundToIntegerFunc func) {
ASSERT_PFORMAT_EQ(expected2, format_arr[2]);
}
-#ifndef LLVM_LIBC_PRINTF_DISABLE_INDEX_MODE
+#ifndef LIBC_COPT_PRINTF_DISABLE_INDEX_MODE
TEST(LlvmLibcPrintfParserTest, IndexModeOneArg) {
__llvm_libc::printf_core::FormatSection format_arr[10];
EXPECT_PFORMAT_EQ(expected9, format_arr[9]);
}
-#endif // LLVM_LIBC_PRINTF_DISABLE_INDEX_MODE
+#endif // LIBC_COPT_PRINTF_DISABLE_INDEX_MODE
ASSERT_SFORMAT_EQ(expected2, format_arr[2]);
}
-#ifndef LLVM_LIBC_SCANF_DISABLE_INDEX_MODE
+#ifndef LIBC_COPT_SCANF_DISABLE_INDEX_MODE
TEST(LlvmLibcScanfParserTest, IndexModeOneArg) {
__llvm_libc::scanf_core::FormatSection format_arr[10];
EXPECT_SFORMAT_EQ(expected10, format_arr[10]);
}
-#endif // LLVM_LIBC_SCANF_DISABLE_INDEX_MODE
+#endif // LIBC_COPT_SCANF_DISABLE_INDEX_MODE
ASSERT_STREQ(buff, "0077 01000000000000 002 ");
}
-#ifndef LLVM_LIBC_PRINTF_DISABLE_FLOAT
+#ifndef LIBC_COPT_PRINTF_DISABLE_FLOAT
TEST_F(LlvmLibcSPrintfTest, FloatHexExpConv) {
__llvm_libc::testutils::ForceRoundingMode r(
ASSERT_STREQ_LEN(written, buff, "+0.126 0001.26e+03");
}
-#endif // LLVM_LIBC_PRINTF_DISABLE_FLOAT
+#endif // LIBC_COPT_PRINTF_DISABLE_FLOAT
-#ifndef LLVM_LIBC_PRINTF_DISABLE_WRITE_INT
+#ifndef LIBC_COPT_PRINTF_DISABLE_WRITE_INT
TEST(LlvmLibcSPrintfTest, WriteIntConv) {
char buff[64];
int written;
written = __llvm_libc::sprintf(buff, "abc123%n", nullptr);
EXPECT_LT(written, 0);
}
-#endif // LLVM_LIBC_PRINTF_DISABLE_WRITE_INT
+#endif // LIBC_COPT_PRINTF_DISABLE_WRITE_INT
-#ifndef LLVM_LIBC_PRINTF_DISABLE_INDEX_MODE
+#ifndef LIBC_COPT_PRINTF_DISABLE_INDEX_MODE
TEST(LlvmLibcSPrintfTest, IndexModeParsing) {
char buff[64];
int written;
EXPECT_EQ(written, 45);
ASSERT_STREQ(buff, "why would u do this, this is such a pain. %");
}
-#endif // LLVM_LIBC_PRINTF_DISABLE_INDEX_MODE
+#endif // LIBC_COPT_PRINTF_DISABLE_INDEX_MODE
func_attrs = ["__attribute__((visibility(\"default\")))"]
if weak:
func_attrs.append("__attribute__((weak))")
- local_defines = local_defines or ["LLVM_LIBC_PUBLIC_PACKAGING"]
+ local_defines = local_defines or ["LIBC_COPT_PUBLIC_PACKAGING"]
local_defines.append("LLVM_LIBC_FUNCTION_ATTR='%s'" % " ".join(func_attrs))
_libc_library(
name = name,