[libc][NFC] Make tuning macros start with LIBC_COPT_
Rename preprocessor definitions that control tuning of llvm libc. Differential Revision: https://reviews.llvm.org/D143913
This commit is contained in:
parent
d64d5772b1
commit
c3228714cc
|
@ -108,7 +108,7 @@ function(_build_gpu_entrypoint_objects fq_target_name)
|
|||
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}>)
|
||||
|
@ -521,7 +521,7 @@ function(create_entrypoint_object fq_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})
|
||||
|
||||
|
|
|
@ -9,6 +9,6 @@ if(LIBC_UNSAFE_STRING_WIDE_READ)
|
|||
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()
|
||||
|
|
|
@ -58,7 +58,7 @@ add_libc_fuzzer(
|
|||
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(
|
||||
|
|
|
@ -50,7 +50,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
|||
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];
|
||||
|
|
|
@ -17,13 +17,13 @@
|
|||
#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); \
|
||||
|
|
|
@ -616,15 +616,15 @@ decimal_exp_to_float(typename fputil::FPBits<T>::UIntType mantissa,
|
|||
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) {
|
||||
|
@ -641,11 +641,13 @@ decimal_exp_to_float(typename fputil::FPBits<T>::UIntType mantissa,
|
|||
}
|
||||
}
|
||||
}
|
||||
#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;
|
||||
}
|
||||
|
|
|
@ -13,10 +13,10 @@
|
|||
|
||||
// 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>
|
||||
|
@ -42,7 +42,7 @@ int convert(Writer *writer, const FormatSection &to_conv) {
|
|||
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);
|
||||
|
@ -55,11 +55,11 @@ int convert(Writer *writer, const FormatSection &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:
|
||||
|
|
|
@ -22,18 +22,18 @@
|
|||
// 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"
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// #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"
|
||||
|
||||
|
@ -22,11 +22,11 @@
|
|||
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;
|
||||
|
@ -38,9 +38,9 @@ FormatSection Parser::get_next_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);
|
||||
|
||||
|
@ -120,7 +120,7 @@ FormatSection Parser::get_next_section() {
|
|||
break;
|
||||
}
|
||||
break;
|
||||
#ifndef LLVM_LIBC_PRINTF_DISABLE_FLOAT
|
||||
#ifndef LIBC_COPT_PRINTF_DISABLE_FLOAT
|
||||
case ('f'):
|
||||
case ('F'):
|
||||
case ('e'):
|
||||
|
@ -137,10 +137,10 @@ FormatSection Parser::get_next_section() {
|
|||
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);
|
||||
|
@ -233,7 +233,7 @@ LengthModifier Parser::parse_length_modifier(size_t *local_pos) {
|
|||
// 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])) {
|
||||
|
@ -343,7 +343,7 @@ TypeDesc Parser::get_type_desc(size_t index) {
|
|||
break;
|
||||
}
|
||||
break;
|
||||
#ifndef LLVM_LIBC_PRINTF_DISABLE_FLOAT
|
||||
#ifndef LIBC_COPT_PRINTF_DISABLE_FLOAT
|
||||
case ('f'):
|
||||
case ('F'):
|
||||
case ('e'):
|
||||
|
@ -357,10 +357,10 @@ TypeDesc Parser::get_type_desc(size_t index) {
|
|||
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 *>();
|
||||
|
@ -403,13 +403,13 @@ void Parser::args_to_index(size_t index) {
|
|||
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 *>();
|
||||
|
@ -420,7 +420,7 @@ void Parser::args_to_index(size_t index) {
|
|||
}
|
||||
}
|
||||
|
||||
#endif // LLVM_LIBC_PRINTF_DISABLE_INDEX_MODE
|
||||
#endif // LIBC_COPT_PRINTF_DISABLE_INDEX_MODE
|
||||
|
||||
} // namespace printf_core
|
||||
} // namespace __llvm_libc
|
||||
|
|
|
@ -26,7 +26,7 @@ class Parser {
|
|||
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.
|
||||
|
@ -34,7 +34,7 @@ class Parser {
|
|||
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
|
||||
|
@ -45,16 +45,16 @@ class Parser {
|
|||
|
||||
// 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
|
||||
|
@ -84,7 +84,7 @@ private:
|
|||
// 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
|
||||
|
@ -124,7 +124,7 @@ private:
|
|||
// 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
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
// 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.
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
#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"
|
||||
|
@ -48,7 +48,7 @@ int convert(Reader *reader, const FormatSection &to_conv) {
|
|||
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':
|
||||
|
@ -61,7 +61,7 @@ int convert(Reader *reader, const FormatSection &to_conv) {
|
|||
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':
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// #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"
|
||||
|
||||
|
@ -22,11 +22,11 @@
|
|||
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;
|
||||
|
@ -38,9 +38,9 @@ FormatSection Parser::get_next_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;
|
||||
|
@ -191,7 +191,7 @@ LengthModifier Parser::parse_length_modifier(size_t *local_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])) {
|
||||
|
@ -219,7 +219,7 @@ void Parser::args_to_index(size_t index) {
|
|||
}
|
||||
}
|
||||
|
||||
#endif // LLVM_LIBC_SCANF_DISABLE_INDEX_MODE
|
||||
#endif // LIBC_COPT_SCANF_DISABLE_INDEX_MODE
|
||||
|
||||
} // namespace scanf_core
|
||||
} // namespace __llvm_libc
|
||||
|
|
|
@ -25,22 +25,22 @@ class Parser {
|
|||
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
|
||||
|
@ -64,7 +64,7 @@ private:
|
|||
// 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
|
||||
|
@ -91,7 +91,7 @@ private:
|
|||
// 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
|
||||
|
|
|
@ -14,11 +14,11 @@
|
|||
// 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
|
||||
|
|
|
@ -28,7 +28,7 @@ struct AtExitUnit {
|
|||
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
|
||||
|
@ -40,7 +40,7 @@ using ExitCallbackList = cpp::ReverseOrderBlockStore<AtExitUnit, 32>;
|
|||
// 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;
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ LIBC_INLINE size_t string_length_byte_read(const char *src) {
|
|||
// 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
|
||||
|
@ -143,7 +143,7 @@ LIBC_INLINE void *find_first_character_byte_read(const unsigned char *src,
|
|||
// '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,
|
||||
|
|
|
@ -186,7 +186,7 @@ static GetoptContext ctx{
|
|||
&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) {
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#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"
|
||||
|
||||
|
@ -62,6 +62,6 @@ public:
|
|||
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
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#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"
|
||||
|
|
|
@ -84,10 +84,13 @@ public:
|
|||
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) {
|
||||
|
|
|
@ -279,7 +279,7 @@ TEST(LlvmLibcPrintfParserTest, EvalThreeArgs) {
|
|||
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];
|
||||
|
@ -474,4 +474,4 @@ TEST(LlvmLibcPrintfParserTest, IndexModeComplexParsing) {
|
|||
EXPECT_PFORMAT_EQ(expected9, format_arr[9]);
|
||||
}
|
||||
|
||||
#endif // LLVM_LIBC_PRINTF_DISABLE_INDEX_MODE
|
||||
#endif // LIBC_COPT_PRINTF_DISABLE_INDEX_MODE
|
||||
|
|
|
@ -549,7 +549,7 @@ TEST(LlvmLibcScanfParserTest, EvalThreeArgs) {
|
|||
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];
|
||||
|
@ -756,4 +756,4 @@ TEST(LlvmLibcScanfParserTest, IndexModeComplexParsing) {
|
|||
EXPECT_SFORMAT_EQ(expected10, format_arr[10]);
|
||||
}
|
||||
|
||||
#endif // LLVM_LIBC_SCANF_DISABLE_INDEX_MODE
|
||||
#endif // LIBC_COPT_SCANF_DISABLE_INDEX_MODE
|
||||
|
|
|
@ -502,7 +502,7 @@ TEST(LlvmLibcSPrintfTest, OctConv) {
|
|||
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(
|
||||
|
@ -2662,9 +2662,9 @@ TEST_F(LlvmLibcSPrintfTest, FloatAutoConv) {
|
|||
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;
|
||||
|
@ -2697,9 +2697,9 @@ TEST(LlvmLibcSPrintfTest, WriteIntConv) {
|
|||
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;
|
||||
|
@ -2724,4 +2724,4 @@ TEST(LlvmLibcSPrintfTest, IndexModeParsing) {
|
|||
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
|
||||
|
|
|
@ -88,7 +88,7 @@ def libc_function(
|
|||
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,
|
||||
|
|
Loading…
Reference in New Issue
Block a user