diff options
Diffstat (limited to 'libc/src')
| -rw-r--r-- | libc/src/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | libc/src/string/CMakeLists.txt | 146 | ||||
| -rw-r--r-- | libc/src/strings/CMakeLists.txt | 97 | ||||
| -rw-r--r-- | libc/src/strings/bcmp.cpp (renamed from libc/src/string/bcmp.cpp) | 2 | ||||
| -rw-r--r-- | libc/src/strings/bcmp.h (renamed from libc/src/string/bcmp.h) | 6 | ||||
| -rw-r--r-- | libc/src/strings/bcopy.cpp (renamed from libc/src/string/bcopy.cpp) | 2 | ||||
| -rw-r--r-- | libc/src/strings/bcopy.h (renamed from libc/src/string/bcopy.h) | 6 | ||||
| -rw-r--r-- | libc/src/strings/bzero.cpp (renamed from libc/src/string/bzero.cpp) | 2 | ||||
| -rw-r--r-- | libc/src/strings/bzero.h (renamed from libc/src/string/bzero.h) | 6 | ||||
| -rw-r--r-- | libc/src/strings/index.cpp (renamed from libc/src/string/index.cpp) | 2 | ||||
| -rw-r--r-- | libc/src/strings/index.h (renamed from libc/src/string/index.h) | 6 | ||||
| -rw-r--r-- | libc/src/strings/rindex.cpp (renamed from libc/src/string/rindex.cpp) | 2 | ||||
| -rw-r--r-- | libc/src/strings/rindex.h (renamed from libc/src/string/rindex.h) | 6 | ||||
| -rw-r--r-- | libc/src/strings/strcasecmp.cpp (renamed from libc/src/string/strcasecmp.cpp) | 2 | ||||
| -rw-r--r-- | libc/src/strings/strcasecmp.h (renamed from libc/src/string/strcasecmp.h) | 6 | ||||
| -rw-r--r-- | libc/src/strings/strncasecmp.cpp (renamed from libc/src/string/strncasecmp.cpp) | 2 | ||||
| -rw-r--r-- | libc/src/strings/strncasecmp.h (renamed from libc/src/string/strncasecmp.h) | 6 |
17 files changed, 126 insertions, 174 deletions
diff --git a/libc/src/CMakeLists.txt b/libc/src/CMakeLists.txt index dd3b51886edf..8dad08b9fbfd 100644 --- a/libc/src/CMakeLists.txt +++ b/libc/src/CMakeLists.txt @@ -12,6 +12,7 @@ add_subdirectory(stdfix) add_subdirectory(stdio) add_subdirectory(stdlib) add_subdirectory(string) +add_subdirectory(strings) add_subdirectory(wchar) add_subdirectory(time) diff --git a/libc/src/string/CMakeLists.txt b/libc/src/string/CMakeLists.txt index 8fe1226dd6a7..e3faa543e630 100644 --- a/libc/src/string/CMakeLists.txt +++ b/libc/src/string/CMakeLists.txt @@ -35,24 +35,6 @@ add_header_library( ) add_entrypoint_object( - bcopy - SRCS - bcopy.cpp - HDRS - bcopy.h -) - -add_entrypoint_object( - index - SRCS - index.cpp - HDRS - index.h - DEPENDS - .string_utils -) - -add_entrypoint_object( memccpy SRCS memccpy.cpp @@ -99,16 +81,6 @@ add_entrypoint_object( ) add_entrypoint_object( - rindex - SRCS - rindex.cpp - HDRS - rindex.h - DEPENDS - .string_utils -) - -add_entrypoint_object( stpcpy SRCS stpcpy.cpp @@ -172,17 +144,6 @@ add_entrypoint_object( ) add_entrypoint_object( - strcasecmp - SRCS - strcasecmp.cpp - HDRS - strcasecmp.h - DEPENDS - .memory_utils.inline_strcmp - libc.src.__support.ctype_utils -) - -add_entrypoint_object( strcasestr SRCS strcasestr.cpp @@ -320,17 +281,6 @@ add_entrypoint_object( ) add_entrypoint_object( - strncasecmp - SRCS - strncasecmp.cpp - HDRS - strncasecmp.h - DEPENDS - .memory_utils.inline_strcmp - libc.src.__support.ctype_utils -) - -add_entrypoint_object( strncpy SRCS strncpy.cpp @@ -475,102 +425,6 @@ add_entrypoint_object( .memory_utils.inline_memset ) -# Helper to define a function with multiple implementations -# - Computes flags to satisfy required/rejected features and arch, -# - Declares an entry point, -# - Attach the REQUIRE_CPU_FEATURES property to the target, -# - Add the fully qualified target to `${name}_implementations` global property for tests. -function(add_implementation name impl_name) - cmake_parse_arguments( - "ADD_IMPL" - "" # Optional arguments - "" # Single value arguments - "REQUIRE;SRCS;HDRS;DEPENDS;COMPILE_OPTIONS;MLLVM_COMPILE_OPTIONS" # Multi value arguments - ${ARGN}) - - if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") - # Note that '-mllvm' needs to be prefixed with 'SHELL:' to prevent CMake flag deduplication. - foreach(opt IN LISTS ADD_IMPL_MLLVM_COMPILE_OPTIONS) - list(APPEND ADD_IMPL_COMPILE_OPTIONS "SHELL:-mllvm ${opt}") - endforeach() - endif() - - if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") - # Prevent warning when passing x86 SIMD types as template arguments. - # e.g. "warning: ignoring attributes on template argument ā__m128iā [-Wignored-attributes]" - list(APPEND ADD_IMPL_COMPILE_OPTIONS "-Wno-ignored-attributes") - endif() - - add_entrypoint_object(${impl_name} - NAME ${name} - SRCS ${ADD_IMPL_SRCS} - HDRS ${ADD_IMPL_HDRS} - DEPENDS ${ADD_IMPL_DEPENDS} - COMPILE_OPTIONS ${libc_opt_high_flag} ${ADD_IMPL_COMPILE_OPTIONS} - ) - get_fq_target_name(${impl_name} fq_target_name) - set_target_properties(${fq_target_name} PROPERTIES REQUIRE_CPU_FEATURES "${ADD_IMPL_REQUIRE}") - set_property(GLOBAL APPEND PROPERTY "${name}_implementations" "${fq_target_name}") -endfunction() - -# ------------------------------------------------------------------------------ -# bcmp -# ------------------------------------------------------------------------------ - -function(add_bcmp bcmp_name) - add_implementation(bcmp ${bcmp_name} - SRCS ${LIBC_SOURCE_DIR}/src/string/bcmp.cpp - HDRS ${LIBC_SOURCE_DIR}/src/string/bcmp.h - DEPENDS - .memory_utils.memory_utils - libc.include.string - ${ARGN} - ) -endfunction() - -if(${LIBC_TARGET_ARCHITECTURE_IS_X86}) - add_bcmp(bcmp_x86_64_opt_sse2 COMPILE_OPTIONS -march=k8 REQUIRE SSE2) - add_bcmp(bcmp_x86_64_opt_sse4 COMPILE_OPTIONS -march=nehalem REQUIRE SSE4_2) - add_bcmp(bcmp_x86_64_opt_avx2 COMPILE_OPTIONS -march=haswell REQUIRE AVX2) - add_bcmp(bcmp_x86_64_opt_avx512 COMPILE_OPTIONS -march=skylake-avx512 REQUIRE AVX512BW) - add_bcmp(bcmp_opt_host COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_NATIVE}) - add_bcmp(bcmp) -elseif(LIBC_TARGET_OS_IS_GPU) - add_bcmp(bcmp) -else() - add_bcmp(bcmp_opt_host COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_NATIVE}) - add_bcmp(bcmp) -endif() - -# ------------------------------------------------------------------------------ -# bzero -# ------------------------------------------------------------------------------ - -function(add_bzero bzero_name) - add_implementation(bzero ${bzero_name} - SRCS ${LIBC_SOURCE_DIR}/src/string/bzero.cpp - HDRS ${LIBC_SOURCE_DIR}/src/string/bzero.h - DEPENDS - .memory_utils.inline_memset - libc.include.string - ${ARGN} - ) -endfunction() - -if(${LIBC_TARGET_ARCHITECTURE_IS_X86}) - add_bzero(bzero_x86_64_opt_sse2 COMPILE_OPTIONS -march=k8 REQUIRE SSE2) - add_bzero(bzero_x86_64_opt_sse4 COMPILE_OPTIONS -march=nehalem REQUIRE SSE4_2) - add_bzero(bzero_x86_64_opt_avx2 COMPILE_OPTIONS -march=haswell REQUIRE AVX2) - add_bzero(bzero_x86_64_opt_avx512 COMPILE_OPTIONS -march=skylake-avx512 REQUIRE AVX512F) - add_bzero(bzero_opt_host COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_NATIVE}) - add_bzero(bzero) -elseif(LIBC_TARGET_OS_IS_GPU) - add_bzero(bzero) -else() - add_bzero(bzero_opt_host COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_NATIVE}) - add_bzero(bzero) -endif() - # ------------------------------------------------------------------------------ # memcmp # ------------------------------------------------------------------------------ diff --git a/libc/src/strings/CMakeLists.txt b/libc/src/strings/CMakeLists.txt new file mode 100644 index 000000000000..5e84c7be1f7d --- /dev/null +++ b/libc/src/strings/CMakeLists.txt @@ -0,0 +1,97 @@ +function(add_bcmp bcmp_name) + add_implementation(bcmp ${bcmp_name} + SRCS ${LIBC_SOURCE_DIR}/src/strings/bcmp.cpp + HDRS ${LIBC_SOURCE_DIR}/src/strings/bcmp.h + DEPENDS + libc.src.string.memory_utils.memory_utils + ${ARGN} + ) +endfunction() + +if(${LIBC_TARGET_ARCHITECTURE_IS_X86}) + add_bcmp(bcmp_x86_64_opt_sse2 COMPILE_OPTIONS -march=k8 REQUIRE SSE2) + add_bcmp(bcmp_x86_64_opt_sse4 COMPILE_OPTIONS -march=nehalem REQUIRE SSE4_2) + add_bcmp(bcmp_x86_64_opt_avx2 COMPILE_OPTIONS -march=haswell REQUIRE AVX2) + add_bcmp(bcmp_x86_64_opt_avx512 COMPILE_OPTIONS -march=skylake-avx512 REQUIRE AVX512BW) + add_bcmp(bcmp_opt_host COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_NATIVE}) + add_bcmp(bcmp) +elseif(LIBC_TARGET_OS_IS_GPU) + add_bcmp(bcmp) +else() + add_bcmp(bcmp_opt_host COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_NATIVE}) + add_bcmp(bcmp) +endif() + +function(add_bzero bzero_name) + add_implementation(bzero ${bzero_name} + SRCS ${LIBC_SOURCE_DIR}/src/strings/bzero.cpp + HDRS ${LIBC_SOURCE_DIR}/src/strings/bzero.h + DEPENDS + libc.src.string.memory_utils.inline_memset + ${ARGN} + ) +endfunction() + +if(${LIBC_TARGET_ARCHITECTURE_IS_X86}) + add_bzero(bzero_x86_64_opt_sse2 COMPILE_OPTIONS -march=k8 REQUIRE SSE2) + add_bzero(bzero_x86_64_opt_sse4 COMPILE_OPTIONS -march=nehalem REQUIRE SSE4_2) + add_bzero(bzero_x86_64_opt_avx2 COMPILE_OPTIONS -march=haswell REQUIRE AVX2) + add_bzero(bzero_x86_64_opt_avx512 COMPILE_OPTIONS -march=skylake-avx512 REQUIRE AVX512F) + add_bzero(bzero_opt_host COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_NATIVE}) + add_bzero(bzero) +elseif(LIBC_TARGET_OS_IS_GPU) + add_bzero(bzero) +else() + add_bzero(bzero_opt_host COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_NATIVE}) + add_bzero(bzero) +endif() + +add_entrypoint_object( + bcopy + SRCS + bcopy.cpp + HDRS + bcopy.h +) + +add_entrypoint_object( + index + SRCS + index.cpp + HDRS + index.h + DEPENDS + libc.src.string.string_utils +) + +add_entrypoint_object( + rindex + SRCS + rindex.cpp + HDRS + rindex.h + DEPENDS + libc.src.string.string_utils +) + +add_entrypoint_object( + strcasecmp + SRCS + strcasecmp.cpp + HDRS + strcasecmp.h + DEPENDS + libc.src.__support.ctype_utils + libc.src.string.memory_utils.inline_strcmp +) + +add_entrypoint_object( + strncasecmp + SRCS + strncasecmp.cpp + HDRS + strncasecmp.h + DEPENDS + libc.src.__support.ctype_utils + libc.src.string.memory_utils.inline_strcmp +) diff --git a/libc/src/string/bcmp.cpp b/libc/src/strings/bcmp.cpp index 6e9c9ae3b7a3..083f13d3f95d 100644 --- a/libc/src/string/bcmp.cpp +++ b/libc/src/strings/bcmp.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "src/string/bcmp.h" +#include "src/strings/bcmp.h" #include "src/__support/common.h" #include "src/__support/macros/config.h" #include "src/string/memory_utils/inline_bcmp.h" diff --git a/libc/src/string/bcmp.h b/libc/src/strings/bcmp.h index a82b529164d9..46b4d7163b52 100644 --- a/libc/src/string/bcmp.h +++ b/libc/src/strings/bcmp.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_STRING_BCMP_H -#define LLVM_LIBC_SRC_STRING_BCMP_H +#ifndef LLVM_LIBC_SRC_STRINGS_BCMP_H +#define LLVM_LIBC_SRC_STRINGS_BCMP_H #include "src/__support/macros/config.h" #include <stddef.h> // size_t @@ -18,4 +18,4 @@ int bcmp(const void *lhs, const void *rhs, size_t count); } // namespace LIBC_NAMESPACE_DECL -#endif // LLVM_LIBC_SRC_STRING_BCMP_H +#endif // LLVM_LIBC_SRC_STRINGS_BCMP_H diff --git a/libc/src/string/bcopy.cpp b/libc/src/strings/bcopy.cpp index 89aad71e354c..eb0358c18747 100644 --- a/libc/src/string/bcopy.cpp +++ b/libc/src/strings/bcopy.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "src/string/bcopy.h" +#include "src/strings/bcopy.h" #include "src/__support/common.h" #include "src/__support/macros/config.h" #include "src/string/memory_utils/inline_memmove.h" diff --git a/libc/src/string/bcopy.h b/libc/src/strings/bcopy.h index 4cf0263a7d63..d8ee77e83c6d 100644 --- a/libc/src/string/bcopy.h +++ b/libc/src/strings/bcopy.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_STRING_BCOPY_H -#define LLVM_LIBC_SRC_STRING_BCOPY_H +#ifndef LLVM_LIBC_SRC_STRINGS_BCOPY_H +#define LLVM_LIBC_SRC_STRINGS_BCOPY_H #include "src/__support/macros/config.h" #include <stddef.h> // size_t @@ -18,4 +18,4 @@ void bcopy(const void *src, void *dest, size_t count); } // namespace LIBC_NAMESPACE_DECL -#endif // LLVM_LIBC_SRC_STRING_BCOPY_H +#endif // LLVM_LIBC_SRC_STRINGS_BCOPY_H diff --git a/libc/src/string/bzero.cpp b/libc/src/strings/bzero.cpp index 7bcbee3547b9..9c2e9700442a 100644 --- a/libc/src/string/bzero.cpp +++ b/libc/src/strings/bzero.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "src/string/bzero.h" +#include "src/strings/bzero.h" #include "src/__support/common.h" #include "src/__support/macros/config.h" #include "src/string/memory_utils/inline_bzero.h" diff --git a/libc/src/string/bzero.h b/libc/src/strings/bzero.h index d9722197e8e8..3e270fe41f6c 100644 --- a/libc/src/string/bzero.h +++ b/libc/src/strings/bzero.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_STRING_BZERO_H -#define LLVM_LIBC_SRC_STRING_BZERO_H +#ifndef LLVM_LIBC_SRC_STRINGS_BZERO_H +#define LLVM_LIBC_SRC_STRINGS_BZERO_H #include "src/__support/macros/config.h" #include <stddef.h> // size_t @@ -18,4 +18,4 @@ void bzero(void *ptr, size_t count); } // namespace LIBC_NAMESPACE_DECL -#endif // LLVM_LIBC_SRC_STRING_BZERO_H +#endif // LLVM_LIBC_SRC_STRINGS_BZERO_H diff --git a/libc/src/string/index.cpp b/libc/src/strings/index.cpp index 46cf54825f6c..33b2be9f33e0 100644 --- a/libc/src/string/index.cpp +++ b/libc/src/strings/index.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "src/string/index.h" +#include "src/strings/index.h" #include "src/__support/common.h" #include "src/__support/macros/config.h" diff --git a/libc/src/string/index.h b/libc/src/strings/index.h index 9843bcdf9a57..d382cdd249aa 100644 --- a/libc/src/string/index.h +++ b/libc/src/strings/index.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_STRING_INDEX_H -#define LLVM_LIBC_SRC_STRING_INDEX_H +#ifndef LLVM_LIBC_SRC_STRINGS_INDEX_H +#define LLVM_LIBC_SRC_STRINGS_INDEX_H #include "src/__support/macros/config.h" @@ -17,4 +17,4 @@ char *index(const char *src, int c); } // namespace LIBC_NAMESPACE_DECL -#endif // LLVM_LIBC_SRC_STRING_INDEX_H +#endif // LLVM_LIBC_SRC_STRINGS_INDEX_H diff --git a/libc/src/string/rindex.cpp b/libc/src/strings/rindex.cpp index 25879ddb07f6..1242e0faf85f 100644 --- a/libc/src/string/rindex.cpp +++ b/libc/src/strings/rindex.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "src/string/rindex.h" +#include "src/strings/rindex.h" #include "src/__support/common.h" #include "src/__support/macros/config.h" diff --git a/libc/src/string/rindex.h b/libc/src/strings/rindex.h index cfc35daa1f4d..f8aa7b9be28f 100644 --- a/libc/src/string/rindex.h +++ b/libc/src/strings/rindex.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_STRING_RINDEX_H -#define LLVM_LIBC_SRC_STRING_RINDEX_H +#ifndef LLVM_LIBC_SRC_STRINGS_RINDEX_H +#define LLVM_LIBC_SRC_STRINGS_RINDEX_H #include "src/__support/macros/config.h" @@ -17,4 +17,4 @@ char *rindex(const char *src, int c); } // namespace LIBC_NAMESPACE_DECL -#endif // LLVM_LIBC_SRC_STRING_RINDEX_H +#endif // LLVM_LIBC_SRC_STRINGS_RINDEX_H diff --git a/libc/src/string/strcasecmp.cpp b/libc/src/strings/strcasecmp.cpp index 1274c047fc28..4bbe2909df1e 100644 --- a/libc/src/string/strcasecmp.cpp +++ b/libc/src/strings/strcasecmp.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "src/string/strcasecmp.h" +#include "src/strings/strcasecmp.h" #include "src/__support/common.h" #include "src/__support/ctype_utils.h" diff --git a/libc/src/string/strcasecmp.h b/libc/src/strings/strcasecmp.h index 2916b8d41707..b02fb3161587 100644 --- a/libc/src/string/strcasecmp.h +++ b/libc/src/strings/strcasecmp.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_STRING_STRCASECMP_H -#define LLVM_LIBC_SRC_STRING_STRCASECMP_H +#ifndef LLVM_LIBC_SRC_STRINGS_STRCASECMP_H +#define LLVM_LIBC_SRC_STRINGS_STRCASECMP_H #include "src/__support/macros/config.h" @@ -17,4 +17,4 @@ int strcasecmp(const char *left, const char *right); } // namespace LIBC_NAMESPACE_DECL -#endif // LLVM_LIBC_SRC_STRING_STRCASECMP_H +#endif // LLVM_LIBC_SRC_STRINGS_STRCASECMP_H diff --git a/libc/src/string/strncasecmp.cpp b/libc/src/strings/strncasecmp.cpp index 45f82c98069b..9c2f0ab13126 100644 --- a/libc/src/string/strncasecmp.cpp +++ b/libc/src/strings/strncasecmp.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "src/string/strncasecmp.h" +#include "src/strings/strncasecmp.h" #include "src/__support/common.h" #include "src/__support/ctype_utils.h" diff --git a/libc/src/string/strncasecmp.h b/libc/src/strings/strncasecmp.h index 15f74994ca56..59df51705891 100644 --- a/libc/src/string/strncasecmp.h +++ b/libc/src/strings/strncasecmp.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_STRING_STRNCASECMP_H -#define LLVM_LIBC_SRC_STRING_STRNCASECMP_H +#ifndef LLVM_LIBC_SRC_STRINGS_STRNCASECMP_H +#define LLVM_LIBC_SRC_STRINGS_STRNCASECMP_H #include "src/__support/macros/config.h" #include <stddef.h> @@ -18,4 +18,4 @@ int strncasecmp(const char *left, const char *right, size_t n); } // namespace LIBC_NAMESPACE_DECL -#endif // LLVM_LIBC_SRC_STRING_STRNCASECMP_H +#endif // LLVM_LIBC_SRC_STRINGS_STRNCASECMP_H |
