[libc][Obvious] Reorder CMakelists alphabetically.
GitOrigin-RevId: 9b015383f1f1ccf2d69bfff223adce84be72a686
diff --git a/src/string/CMakeLists.txt b/src/string/CMakeLists.txt
index e41f0e1..b652bef 100644
--- a/src/string/CMakeLists.txt
+++ b/src/string/CMakeLists.txt
@@ -9,54 +9,6 @@
)
add_entrypoint_object(
- strcat
- SRCS
- strcat.cpp
- HDRS
- strcat.h
- DEPENDS
- .strcpy
- .string_utils
-)
-
-add_entrypoint_object(
- strcpy
- SRCS
- strcpy.cpp
- HDRS
- strcpy.h
- DEPENDS
- .memcpy
- .string_utils
-)
-
-add_entrypoint_object(
- strlen
- SRCS
- strlen.cpp
- HDRS
- strlen.h
- DEPENDS
- libc.include.string
-)
-
-add_entrypoint_object(
- strcmp
- SRCS
- strcmp.cpp
- HDRS
- strcmp.h
-)
-
-add_entrypoint_object(
- strncmp
- SRCS
- strncmp.cpp
- HDRS
- strncmp.h
-)
-
-add_entrypoint_object(
memchr
SRCS
memchr.cpp
@@ -78,6 +30,25 @@
)
add_entrypoint_object(
+ memrchr
+ SRCS
+ memrchr.cpp
+ HDRS
+ memrchr.h
+)
+
+add_entrypoint_object(
+ strcat
+ SRCS
+ strcat.cpp
+ HDRS
+ strcat.h
+ DEPENDS
+ .strcpy
+ .string_utils
+)
+
+add_entrypoint_object(
strchr
SRCS
strchr.cpp
@@ -86,11 +57,50 @@
)
add_entrypoint_object(
- strstr
+ strcmp
SRCS
- strstr.cpp
+ strcmp.cpp
HDRS
- strstr.h
+ strcmp.h
+)
+
+add_entrypoint_object(
+ strcpy
+ SRCS
+ strcpy.cpp
+ HDRS
+ strcpy.h
+ DEPENDS
+ .memcpy
+ .string_utils
+)
+
+add_entrypoint_object(
+ strcspn
+ SRCS
+ strcspn.cpp
+ HDRS
+ strcspn.h
+ DEPENDS
+ .string_utils
+)
+
+add_entrypoint_object(
+ strlen
+ SRCS
+ strlen.cpp
+ HDRS
+ strlen.h
+ DEPENDS
+ libc.include.string
+)
+
+add_entrypoint_object(
+ strncmp
+ SRCS
+ strncmp.cpp
+ HDRS
+ strncmp.h
)
add_entrypoint_object(
@@ -112,11 +122,13 @@
)
add_entrypoint_object(
- memrchr
+ strpbrk
SRCS
- memrchr.cpp
+ strpbrk.cpp
HDRS
- memrchr.h
+ strpbrk.h
+ DEPENDS
+ .string_utils
)
add_entrypoint_object(
@@ -128,16 +140,6 @@
)
add_entrypoint_object(
- strcspn
- SRCS
- strcspn.cpp
- HDRS
- strcspn.h
- DEPENDS
- .string_utils
-)
-
-add_entrypoint_object(
strspn
SRCS
strspn.cpp
@@ -148,13 +150,11 @@
)
add_entrypoint_object(
- strpbrk
+ strstr
SRCS
- strpbrk.cpp
+ strstr.cpp
HDRS
- strpbrk.h
- DEPENDS
- .string_utils
+ strstr.h
)
add_entrypoint_object(
@@ -202,70 +202,35 @@
endfunction()
# ------------------------------------------------------------------------------
-# memcpy
+# bcmp
# ------------------------------------------------------------------------------
-function(add_memcpy memcpy_name)
- add_implementation(memcpy ${memcpy_name}
- SRCS ${MEMCPY_SRC}
- HDRS ${LIBC_SOURCE_DIR}/src/string/memcpy.h
+function(add_bcmp bcmp_name)
+ add_implementation(bcmp ${bcmp_name}
+ SRCS ${LIBC_BCMP_SRC}
+ HDRS ${LIBC_SOURCE_DIR}/src/string/bcmp.h
DEPENDS
.memory_utils.memory_utils
libc.include.string
COMPILE_OPTIONS
- -fno-builtin-memcpy
+ -fno-builtin-memcmp
+ -fno-builtin-bcmp
${ARGN}
)
endfunction()
if(${LIBC_TARGET_ARCHITECTURE_IS_X86})
- set(MEMCPY_SRC ${LIBC_SOURCE_DIR}/src/string/x86_64/memcpy.cpp)
- add_memcpy(memcpy_x86_64_opt_sse2 COMPILE_OPTIONS -march=k8 REQUIRE SSE2)
- add_memcpy(memcpy_x86_64_opt_sse4 COMPILE_OPTIONS -march=nehalem REQUIRE SSE4_2)
- add_memcpy(memcpy_x86_64_opt_avx2 COMPILE_OPTIONS -march=haswell REQUIRE AVX2)
- add_memcpy(memcpy_x86_64_opt_avx512 COMPILE_OPTIONS -march=skylake-avx512 REQUIRE AVX512F)
- add_memcpy(memcpy_opt_host COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_NATIVE})
- add_memcpy(memcpy)
-elseif(${LIBC_TARGET_ARCHITECTURE_IS_AARCH64})
- set(MEMCPY_SRC ${LIBC_SOURCE_DIR}/src/string/aarch64/memcpy.cpp)
- # Disable tail merging as it leads to lower performance.
- # Note that '-mllvm' needs to be prefixed with 'SHELL:' to prevent CMake flag deduplication.
- add_memcpy(memcpy_opt_host COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_NATIVE}
- COMPILE_OPTIONS "SHELL:-mllvm --tail-merge-threshold=0")
- add_memcpy(memcpy COMPILE_OPTIONS "SHELL:-mllvm --tail-merge-threshold=0")
+ set(LIBC_BCMP_SRC ${LIBC_SOURCE_DIR}/src/string/bcmp.cpp)
+ 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 AVX512F)
+ add_bcmp(bcmp_opt_host COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_NATIVE})
+ add_bcmp(bcmp)
else()
- set(MEMCPY_SRC ${LIBC_SOURCE_DIR}/src/string/memcpy.cpp)
- add_memcpy(memcpy_opt_host COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_NATIVE})
- add_memcpy(memcpy)
-endif()
-
-# ------------------------------------------------------------------------------
-# memset
-# ------------------------------------------------------------------------------
-
-function(add_memset memset_name)
- add_implementation(memset ${memset_name}
- SRCS ${LIBC_SOURCE_DIR}/src/string/memset.cpp
- HDRS ${LIBC_SOURCE_DIR}/src/string/memset.h
- DEPENDS
- .memory_utils.memory_utils
- libc.include.string
- COMPILE_OPTIONS
- -fno-builtin-memset
- ${ARGN}
- )
-endfunction()
-
-if(${LIBC_TARGET_ARCHITECTURE_IS_X86})
- add_memset(memset_x86_64_opt_sse2 COMPILE_OPTIONS -march=k8 REQUIRE SSE2)
- add_memset(memset_x86_64_opt_sse4 COMPILE_OPTIONS -march=nehalem REQUIRE SSE4_2)
- add_memset(memset_x86_64_opt_avx2 COMPILE_OPTIONS -march=haswell REQUIRE AVX2)
- add_memset(memset_x86_64_opt_avx512 COMPILE_OPTIONS -march=skylake-avx512 REQUIRE AVX512F)
- add_memset(memset_opt_host COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_NATIVE})
- add_memset(memset)
-else()
- add_memset(memset_opt_host COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_NATIVE})
- add_memset(memset)
+ set(LIBC_BCMP_SRC ${LIBC_SOURCE_DIR}/src/string/bcmp.cpp)
+ add_bcmp(bcmp_opt_host COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_NATIVE})
+ add_bcmp(bcmp)
endif()
# ------------------------------------------------------------------------------
@@ -333,33 +298,68 @@
endif()
# ------------------------------------------------------------------------------
-# bcmp
+# memcpy
# ------------------------------------------------------------------------------
-function(add_bcmp bcmp_name)
- add_implementation(bcmp ${bcmp_name}
- SRCS ${LIBC_BCMP_SRC}
- HDRS ${LIBC_SOURCE_DIR}/src/string/bcmp.h
+function(add_memcpy memcpy_name)
+ add_implementation(memcpy ${memcpy_name}
+ SRCS ${MEMCPY_SRC}
+ HDRS ${LIBC_SOURCE_DIR}/src/string/memcpy.h
DEPENDS
.memory_utils.memory_utils
libc.include.string
COMPILE_OPTIONS
- -fno-builtin-memcmp
- -fno-builtin-bcmp
+ -fno-builtin-memcpy
${ARGN}
)
endfunction()
if(${LIBC_TARGET_ARCHITECTURE_IS_X86})
- set(LIBC_BCMP_SRC ${LIBC_SOURCE_DIR}/src/string/bcmp.cpp)
- 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 AVX512F)
- add_bcmp(bcmp_opt_host COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_NATIVE})
- add_bcmp(bcmp)
+ set(MEMCPY_SRC ${LIBC_SOURCE_DIR}/src/string/x86_64/memcpy.cpp)
+ add_memcpy(memcpy_x86_64_opt_sse2 COMPILE_OPTIONS -march=k8 REQUIRE SSE2)
+ add_memcpy(memcpy_x86_64_opt_sse4 COMPILE_OPTIONS -march=nehalem REQUIRE SSE4_2)
+ add_memcpy(memcpy_x86_64_opt_avx2 COMPILE_OPTIONS -march=haswell REQUIRE AVX2)
+ add_memcpy(memcpy_x86_64_opt_avx512 COMPILE_OPTIONS -march=skylake-avx512 REQUIRE AVX512F)
+ add_memcpy(memcpy_opt_host COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_NATIVE})
+ add_memcpy(memcpy)
+elseif(${LIBC_TARGET_ARCHITECTURE_IS_AARCH64})
+ set(MEMCPY_SRC ${LIBC_SOURCE_DIR}/src/string/aarch64/memcpy.cpp)
+ # Disable tail merging as it leads to lower performance.
+ # Note that '-mllvm' needs to be prefixed with 'SHELL:' to prevent CMake flag deduplication.
+ add_memcpy(memcpy_opt_host COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_NATIVE}
+ COMPILE_OPTIONS "SHELL:-mllvm --tail-merge-threshold=0")
+ add_memcpy(memcpy COMPILE_OPTIONS "SHELL:-mllvm --tail-merge-threshold=0")
else()
- set(LIBC_BCMP_SRC ${LIBC_SOURCE_DIR}/src/string/bcmp.cpp)
- add_bcmp(bcmp_opt_host COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_NATIVE})
- add_bcmp(bcmp)
+ set(MEMCPY_SRC ${LIBC_SOURCE_DIR}/src/string/memcpy.cpp)
+ add_memcpy(memcpy_opt_host COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_NATIVE})
+ add_memcpy(memcpy)
+endif()
+
+# ------------------------------------------------------------------------------
+# memset
+# ------------------------------------------------------------------------------
+
+function(add_memset memset_name)
+ add_implementation(memset ${memset_name}
+ SRCS ${LIBC_SOURCE_DIR}/src/string/memset.cpp
+ HDRS ${LIBC_SOURCE_DIR}/src/string/memset.h
+ DEPENDS
+ .memory_utils.memory_utils
+ libc.include.string
+ COMPILE_OPTIONS
+ -fno-builtin-memset
+ ${ARGN}
+ )
+endfunction()
+
+if(${LIBC_TARGET_ARCHITECTURE_IS_X86})
+ add_memset(memset_x86_64_opt_sse2 COMPILE_OPTIONS -march=k8 REQUIRE SSE2)
+ add_memset(memset_x86_64_opt_sse4 COMPILE_OPTIONS -march=nehalem REQUIRE SSE4_2)
+ add_memset(memset_x86_64_opt_avx2 COMPILE_OPTIONS -march=haswell REQUIRE AVX2)
+ add_memset(memset_x86_64_opt_avx512 COMPILE_OPTIONS -march=skylake-avx512 REQUIRE AVX512F)
+ add_memset(memset_opt_host COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_NATIVE})
+ add_memset(memset)
+else()
+ add_memset(memset_opt_host COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_NATIVE})
+ add_memset(memset)
endif()
diff --git a/test/src/string/CMakeLists.txt b/test/src/string/CMakeLists.txt
index c8e8812..d68c1c9 100644
--- a/test/src/string/CMakeLists.txt
+++ b/test/src/string/CMakeLists.txt
@@ -3,56 +3,6 @@
add_subdirectory(memory_utils)
add_libc_unittest(
- strcat_test
- SUITE
- libc_string_unittests
- SRCS
- strcat_test.cpp
- DEPENDS
- libc.src.string.strcat
-)
-
-add_libc_unittest(
- strcpy_test
- SUITE
- libc_string_unittests
- SRCS
- strcpy_test.cpp
- DEPENDS
- libc.src.string.strcpy
-)
-
-add_libc_unittest(
- strlen_test
- SUITE
- libc_string_unittests
- SRCS
- strlen_test.cpp
- DEPENDS
- libc.src.string.strlen
-)
-
-add_libc_unittest(
- strcmp_test
- SUITE
- libc_string_unittests
- SRCS
- strcmp_test.cpp
- DEPENDS
- libc.src.string.strcmp
-)
-
-add_libc_unittest(
- strncmp_test
- SUITE
- libc_string_unittests
- SRCS
- strncmp_test.cpp
- DEPENDS
- libc.src.string.strncmp
-)
-
-add_libc_unittest(
memchr_test
SUITE
libc_string_unittests
@@ -63,6 +13,26 @@
)
add_libc_unittest(
+ memrchr_test
+ SUITE
+ libc_string_unittests
+ SRCS
+ memrchr_test.cpp
+ DEPENDS
+ libc.src.string.memrchr
+)
+
+add_libc_unittest(
+ strcat_test
+ SUITE
+ libc_string_unittests
+ SRCS
+ strcat_test.cpp
+ DEPENDS
+ libc.src.string.strcat
+)
+
+add_libc_unittest(
strchr_test
SUITE
libc_string_unittests
@@ -73,13 +43,53 @@
)
add_libc_unittest(
- strstr_test
+ strcmp_test
SUITE
libc_string_unittests
SRCS
- strstr_test.cpp
+ strcmp_test.cpp
DEPENDS
- libc.src.string.strstr
+ libc.src.string.strcmp
+)
+
+add_libc_unittest(
+ strcpy_test
+ SUITE
+ libc_string_unittests
+ SRCS
+ strcpy_test.cpp
+ DEPENDS
+ libc.src.string.strcpy
+)
+
+add_libc_unittest(
+ strcspn_test
+ SUITE
+ libc_string_unittests
+ SRCS
+ strcspn_test.cpp
+ DEPENDS
+ libc.src.string.strcspn
+)
+
+add_libc_unittest(
+ strlen_test
+ SUITE
+ libc_string_unittests
+ SRCS
+ strlen_test.cpp
+ DEPENDS
+ libc.src.string.strlen
+)
+
+add_libc_unittest(
+ strncmp_test
+ SUITE
+ libc_string_unittests
+ SRCS
+ strncmp_test.cpp
+ DEPENDS
+ libc.src.string.strncmp
)
add_libc_unittest(
@@ -103,13 +113,13 @@
)
add_libc_unittest(
- memrchr_test
+ strpbrk_test
SUITE
libc_string_unittests
SRCS
- memrchr_test.cpp
+ strpbrk_test.cpp
DEPENDS
- libc.src.string.memrchr
+ libc.src.string.strpbrk
)
add_libc_unittest(
@@ -123,16 +133,6 @@
)
add_libc_unittest(
- strcspn_test
- SUITE
- libc_string_unittests
- SRCS
- strcspn_test.cpp
- DEPENDS
- libc.src.string.strcspn
-)
-
-add_libc_unittest(
strspn_test
SUITE
libc_string_unittests
@@ -143,13 +143,13 @@
)
add_libc_unittest(
- strpbrk_test
+ strstr_test
SUITE
libc_string_unittests
SRCS
- strpbrk_test.cpp
+ strstr_test.cpp
DEPENDS
- libc.src.string.strpbrk
+ libc.src.string.strstr
)
add_libc_unittest(
@@ -195,9 +195,9 @@
endforeach()
endfunction()
-add_libc_multi_impl_test(memcpy SRCS memcpy_test.cpp)
-add_libc_multi_impl_test(memset SRCS memset_test.cpp)
+add_libc_multi_impl_test(bcmp SRCS bcmp_test.cpp)
add_libc_multi_impl_test(bzero SRCS bzero_test.cpp)
add_libc_multi_impl_test(memcmp SRCS memcmp_test.cpp)
-add_libc_multi_impl_test(bcmp SRCS bcmp_test.cpp)
+add_libc_multi_impl_test(memcpy SRCS memcpy_test.cpp)
add_libc_multi_impl_test(memmove SRCS memmove_test.cpp)
+add_libc_multi_impl_test(memset SRCS memset_test.cpp)