[libc-commits] [libc] eff1117 - [libc] Enable string to integer conversion functions in the default build
Michael Jones via libc-commits
libc-commits at lists.llvm.org
Mon Aug 23 14:18:17 PDT 2021
Author: Michael Jones
Date: 2021-08-23T21:18:14Z
New Revision: eff11176c5ca6a9d1fa8b27a998ba811824669c6
URL: https://github.com/llvm/llvm-project/commit/eff11176c5ca6a9d1fa8b27a998ba811824669c6
DIFF: https://github.com/llvm/llvm-project/commit/eff11176c5ca6a9d1fa8b27a998ba811824669c6.diff
LOG: [libc] Enable string to integer conversion functions in the default build
Adds atoi, atol, atoll, strtol, strtoll, strtoul, and strtoull to the
list of entrypoints for Windows and aarch64 linux, as well as moving
them out of the LLVM_LIBC_FULL_BUILD condition for x86_64 linux.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D108477
Added:
Modified:
libc/config/linux/aarch64/entrypoints.txt
libc/config/linux/x86_64/entrypoints.txt
libc/config/windows/entrypoints.txt
libc/src/CMakeLists.txt
libc/src/stdlib/CMakeLists.txt
libc/test/src/CMakeLists.txt
libc/test/src/stdlib/CMakeLists.txt
libc/test/src/stdlib/atol_test.cpp
libc/test/src/stdlib/atoll_test.cpp
Removed:
################################################################################
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index 0bb899cbc7d0b..cbdb9d92b9aa0 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -44,6 +44,15 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.string.strstr
libc.src.string.strtok
libc.src.string.strtok_r
+
+ # stdlib.h entrypoints
+ libc.src.stdlib.atoi
+ libc.src.stdlib.atol
+ libc.src.stdlib.atoll
+ libc.src.stdlib.strtol
+ libc.src.stdlib.strtoll
+ libc.src.stdlib.strtoul
+ libc.src.stdlib.strtoull
)
set(TARGET_LIBM_ENTRYPOINTS
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index 4fb4ad4ce9a7d..3640271177eac 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -44,6 +44,15 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.string.strstr
libc.src.string.strtok
libc.src.string.strtok_r
+
+ # stdlib.h entrypoints
+ libc.src.stdlib.atoi
+ libc.src.stdlib.atol
+ libc.src.stdlib.atoll
+ libc.src.stdlib.strtol
+ libc.src.stdlib.strtoll
+ libc.src.stdlib.strtoul
+ libc.src.stdlib.strtoull
)
set(TARGET_LIBM_ENTRYPOINTS
@@ -157,15 +166,8 @@ if(LLVM_LIBC_FULL_BUILD)
libc.src.stdlib._Exit
libc.src.stdlib.abort
libc.src.stdlib.abs
- libc.src.stdlib.atoi
- libc.src.stdlib.atol
- libc.src.stdlib.atoll
libc.src.stdlib.labs
libc.src.stdlib.llabs
- libc.src.stdlib.strtol
- libc.src.stdlib.strtoll
- libc.src.stdlib.strtoul
- libc.src.stdlib.strtoull
# signal.h entrypoints
libc.src.signal.raise
diff --git a/libc/config/windows/entrypoints.txt b/libc/config/windows/entrypoints.txt
index 28092183560df..9194d3dce1c7e 100644
--- a/libc/config/windows/entrypoints.txt
+++ b/libc/config/windows/entrypoints.txt
@@ -44,6 +44,15 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.string.strstr
libc.src.string.strtok
libc.src.string.strtok_r
+
+ # stdlib.h entrypoints
+ libc.src.stdlib.atoi
+ libc.src.stdlib.atol
+ libc.src.stdlib.atoll
+ libc.src.stdlib.strtol
+ libc.src.stdlib.strtoll
+ libc.src.stdlib.strtoul
+ libc.src.stdlib.strtoull
)
set(TARGET_LIBM_ENTRYPOINTS
diff --git a/libc/src/CMakeLists.txt b/libc/src/CMakeLists.txt
index db270217d22c2..a02c310e3ae70 100644
--- a/libc/src/CMakeLists.txt
+++ b/libc/src/CMakeLists.txt
@@ -5,6 +5,7 @@ add_subdirectory(errno)
add_subdirectory(fenv)
add_subdirectory(math)
add_subdirectory(string)
+add_subdirectory(stdlib)
if(NOT LLVM_LIBC_FULL_BUILD)
return()
@@ -13,7 +14,6 @@ endif()
add_subdirectory(assert)
add_subdirectory(signal)
add_subdirectory(stdio)
-add_subdirectory(stdlib)
# TODO: Add this target conditional to the target OS.
add_subdirectory(sys)
add_subdirectory(threads)
diff --git a/libc/src/stdlib/CMakeLists.txt b/libc/src/stdlib/CMakeLists.txt
index cd2f2f1f1e7e4..bf1b6371f245f 100644
--- a/libc/src/stdlib/CMakeLists.txt
+++ b/libc/src/stdlib/CMakeLists.txt
@@ -1,122 +1,126 @@
-if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
- add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
-endif()
-
add_entrypoint_object(
- _Exit
- ALIAS
+ atoi
+ SRCS
+ atoi.cpp
+ HDRS
+ atoi.h
DEPENDS
- .${LIBC_TARGET_OS}._Exit
+ libc.src.__support.str_conv_utils
)
add_entrypoint_object(
- abort
+ atol
SRCS
- abort.cpp
+ atol.cpp
HDRS
- abort.h
+ atol.h
DEPENDS
- libc.include.stdlib
- libc.src.signal.raise
- ._Exit
+ libc.src.__support.str_conv_utils
)
add_entrypoint_object(
- abs
+ atoll
SRCS
- abs.cpp
+ atoll.cpp
HDRS
- abs.h
+ atoll.h
DEPENDS
- libc.src.__support.integer_operations
+ libc.src.__support.str_conv_utils
)
add_entrypoint_object(
- atoi
+ strtol
SRCS
- atoi.cpp
+ strtol.cpp
HDRS
- atoi.h
+ strtol.h
DEPENDS
libc.src.__support.str_conv_utils
)
add_entrypoint_object(
- atol
+ strtoll
SRCS
- atol.cpp
+ strtoll.cpp
HDRS
- atol.h
+ strtoll.h
DEPENDS
libc.src.__support.str_conv_utils
)
add_entrypoint_object(
- atoll
+ strtoul
SRCS
- atoll.cpp
+ strtoul.cpp
HDRS
- atoll.h
+ strtoul.h
DEPENDS
libc.src.__support.str_conv_utils
)
add_entrypoint_object(
- labs
+ strtoull
SRCS
- labs.cpp
+ strtoull.cpp
HDRS
- labs.h
+ strtoull.h
DEPENDS
- libc.src.__support.integer_operations
+ libc.src.__support.str_conv_utils
)
+if(NOT LLVM_LIBC_FULL_BUILD)
+ return()
+endif()
+
+if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
+ add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
+endif()
+
add_entrypoint_object(
- llabs
- SRCS
- llabs.cpp
- HDRS
- llabs.h
+ _Exit
+ ALIAS
DEPENDS
- libc.src.__support.integer_operations
+ .${LIBC_TARGET_OS}._Exit
)
add_entrypoint_object(
- strtol
+ abort
SRCS
- strtol.cpp
+ abort.cpp
HDRS
- strtol.h
+ abort.h
DEPENDS
- libc.src.__support.str_conv_utils
+ libc.include.stdlib
+ libc.src.signal.raise
+ ._Exit
)
add_entrypoint_object(
- strtoll
+ abs
SRCS
- strtoll.cpp
+ abs.cpp
HDRS
- strtoll.h
+ abs.h
DEPENDS
- libc.src.__support.str_conv_utils
+ libc.src.__support.integer_operations
)
add_entrypoint_object(
- strtoul
+ labs
SRCS
- strtoul.cpp
+ labs.cpp
HDRS
- strtoul.h
+ labs.h
DEPENDS
- libc.src.__support.str_conv_utils
+ libc.src.__support.integer_operations
)
add_entrypoint_object(
- strtoull
+ llabs
SRCS
- strtoull.cpp
+ llabs.cpp
HDRS
- strtoull.h
+ llabs.h
DEPENDS
- libc.src.__support.str_conv_utils
+ libc.src.__support.integer_operations
)
diff --git a/libc/test/src/CMakeLists.txt b/libc/test/src/CMakeLists.txt
index 5fc3fbbc448df..04235dabfe075 100644
--- a/libc/test/src/CMakeLists.txt
+++ b/libc/test/src/CMakeLists.txt
@@ -31,6 +31,7 @@ add_subdirectory(errno)
add_subdirectory(fenv)
add_subdirectory(math)
add_subdirectory(string)
+add_subdirectory(stdlib)
if(NOT LLVM_LIBC_FULL_BUILD)
return()
@@ -39,7 +40,6 @@ endif()
add_subdirectory(assert)
add_subdirectory(signal)
add_subdirectory(stdio)
-add_subdirectory(stdlib)
add_subdirectory(sys)
add_subdirectory(threads)
add_subdirectory(time)
diff --git a/libc/test/src/stdlib/CMakeLists.txt b/libc/test/src/stdlib/CMakeLists.txt
index 648d85552bed7..6aed171938de9 100644
--- a/libc/test/src/stdlib/CMakeLists.txt
+++ b/libc/test/src/stdlib/CMakeLists.txt
@@ -1,96 +1,130 @@
add_libc_testsuite(libc_stdlib_unittests)
add_libc_unittest(
- _Exit_test
+ atoi_test
SUITE
libc_stdlib_unittests
SRCS
- _Exit_test.cpp
+ atoi_test.cpp
DEPENDS
- libc.include.stdlib
- libc.src.stdlib._Exit
+ libc.src.stdlib.atoi
)
add_libc_unittest(
- abort_test
+ atol_test
SUITE
libc_stdlib_unittests
SRCS
- abort_test.cpp
+ atol_test.cpp
DEPENDS
- libc.include.stdlib
- libc.include.signal
- libc.src.stdlib.abort
- libc.src.stdlib._Exit
- libc.src.signal.raise
+ libc.src.stdlib.atol
)
add_libc_unittest(
- abs_test
+ atoll_test
SUITE
libc_stdlib_unittests
SRCS
- abs_test.cpp
+ atoll_test.cpp
DEPENDS
- libc.src.stdlib.abs
+ libc.src.stdlib.atoll
)
add_libc_unittest(
- labs_test
+ strtol_test
SUITE
libc_stdlib_unittests
SRCS
- labs_test.cpp
+ strtol_test.cpp
DEPENDS
- libc.src.stdlib.labs
+ libc.src.stdlib.strtol
)
add_libc_unittest(
- llabs_test
+ strtoll_test
SUITE
libc_stdlib_unittests
SRCS
- llabs_test.cpp
+ strtoll_test.cpp
DEPENDS
- libc.src.stdlib.llabs
+ libc.src.stdlib.strtoll
)
add_libc_unittest(
- strtol_test
+ strtoul_test
SUITE
libc_stdlib_unittests
SRCS
- strtol_test.cpp
+ strtoul_test.cpp
DEPENDS
- libc.src.stdlib.strtol
+ libc.src.stdlib.strtoul
)
add_libc_unittest(
- strtoll_test
+ strtoull_test
SUITE
libc_stdlib_unittests
SRCS
- strtoll_test.cpp
+ strtoull_test.cpp
DEPENDS
- libc.src.stdlib.strtoll
+ libc.src.stdlib.strtoull
)
+if(NOT LLVM_LIBC_FULL_BUILD)
+ return()
+endif()
+
add_libc_unittest(
- strtoul_test
+ _Exit_test
SUITE
libc_stdlib_unittests
SRCS
- strtoul_test.cpp
+ _Exit_test.cpp
DEPENDS
- libc.src.stdlib.strtoul
+ libc.include.stdlib
+ libc.src.stdlib._Exit
)
add_libc_unittest(
- strtoull_test
+ abort_test
SUITE
libc_stdlib_unittests
SRCS
- strtoull_test.cpp
+ abort_test.cpp
DEPENDS
- libc.src.stdlib.strtoull
+ libc.include.stdlib
+ libc.include.signal
+ libc.src.stdlib.abort
+ libc.src.stdlib._Exit
+ libc.src.signal.raise
+)
+
+add_libc_unittest(
+ abs_test
+ SUITE
+ libc_stdlib_unittests
+ SRCS
+ abs_test.cpp
+ DEPENDS
+ libc.src.stdlib.abs
+)
+
+add_libc_unittest(
+ labs_test
+ SUITE
+ libc_stdlib_unittests
+ SRCS
+ labs_test.cpp
+ DEPENDS
+ libc.src.stdlib.labs
+)
+
+add_libc_unittest(
+ llabs_test
+ SUITE
+ libc_stdlib_unittests
+ SRCS
+ llabs_test.cpp
+ DEPENDS
+ libc.src.stdlib.llabs
)
diff --git a/libc/test/src/stdlib/atol_test.cpp b/libc/test/src/stdlib/atol_test.cpp
index a2e0444a629fc..7290ef1191cbf 100644
--- a/libc/test/src/stdlib/atol_test.cpp
+++ b/libc/test/src/stdlib/atol_test.cpp
@@ -46,7 +46,7 @@ TEST(LlvmLibcAToLTest, NonBaseTenWholeNumbers) {
ASSERT_EQ(__llvm_libc::atol(hexadecimal), 0l);
const char *octal = "010";
- ASSERT_EQ(__llvm_libc::atol(hexadecimal), 10l);
+ ASSERT_EQ(__llvm_libc::atol(octal), 10l);
const char *decimal_point = "5.9";
ASSERT_EQ(__llvm_libc::atol(decimal_point), 5l);
diff --git a/libc/test/src/stdlib/atoll_test.cpp b/libc/test/src/stdlib/atoll_test.cpp
index c716367295cb8..74c86211303cc 100644
--- a/libc/test/src/stdlib/atoll_test.cpp
+++ b/libc/test/src/stdlib/atoll_test.cpp
@@ -41,10 +41,10 @@ TEST(LlvmLibcAToLLTest, ValidNumbers) {
ASSERT_EQ(__llvm_libc::atoll(all_together), 110ll);
const char *biggest_long_long = "9223372036854775807";
- ASSERT_EQ(__llvm_libc::atoll(biggest_int), LLONG_MAX);
+ ASSERT_EQ(__llvm_libc::atoll(biggest_long_long), LLONG_MAX);
const char *smallest_long_long = "-9223372036854775808";
- ASSERT_EQ(__llvm_libc::atoll(smallest_int), LLONG_MIN);
+ ASSERT_EQ(__llvm_libc::atoll(smallest_long_long), LLONG_MIN);
}
TEST(LlvmLibcAToLLTest, NonBaseTenWholeNumbers) {
@@ -52,10 +52,10 @@ TEST(LlvmLibcAToLLTest, NonBaseTenWholeNumbers) {
ASSERT_EQ(__llvm_libc::atoll(hexadecimal), 0ll);
const char *octal = "010";
- ASSERT_EQ(__llvm_libc::atoll(hexadecimal), 10ll);
+ ASSERT_EQ(__llvm_libc::atoll(octal), 10ll);
const char *decimal_point = "5.9";
- ASSERT_EQ(__llvm_libc::atol(decimal_point), 5l);
+ ASSERT_EQ(__llvm_libc::atoll(decimal_point), 5ll);
}
TEST(LlvmLibcAToLLTest, NotNumbers) {
More information about the libc-commits
mailing list