[libc][bazel] add string to float targets
authorMichael Jones <michaelrj@google.com>
Wed, 15 Feb 2023 22:26:30 +0000 (14:26 -0800)
committerMichael Jones <michaelrj@google.com>
Thu, 16 Feb 2023 19:22:08 +0000 (11:22 -0800)
This patch adds atof, strtof, strtod, and strtold to the bazel build, as
well as their tests.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D144140

utils/bazel/llvm-project-overlay/libc/BUILD.bazel
utils/bazel/llvm-project-overlay/libc/test/src/stdlib/BUILD.bazel

index c11f0be..94d08a1 100644 (file)
@@ -292,6 +292,24 @@ libc_support_library(
 )
 
 libc_support_library(
+    name = "__support_str_to_float",
+    hdrs = [
+        "src/__support/detailed_powers_of_ten.h",
+        "src/__support/high_precision_decimal.h",
+        "src/__support/str_to_float.h",
+    ],
+    deps = [
+        ":__support_builtin_wrappers",
+        ":__support_common",
+        ":__support_cpp_limits",
+        ":__support_ctype_utils",
+        ":__support_fputil_fp_bits",
+        ":__support_str_to_integer",
+        ":__support_uint128",
+    ],
+)
+
+libc_support_library(
     name = "__support_fputil_basic_operations",
     hdrs = ["src/__support/FPUtil/BasicOperations.h"],
     deps = [
@@ -1324,6 +1342,16 @@ libc_function(
 )
 
 libc_function(
+    name = "atof",
+    srcs = ["src/stdlib/atof.cpp"],
+    hdrs = ["src/stdlib/atof.h"],
+    deps = [
+        ":__support_common",
+        ":__support_str_to_float",
+    ],
+)
+
+libc_function(
     name = "bsearch",
     srcs = ["src/stdlib/bsearch.cpp"],
     hdrs = ["src/stdlib/bsearch.h"],
@@ -1381,6 +1409,36 @@ libc_function(
     ],
 )
 
+libc_function(
+    name = "strtof",
+    srcs = ["src/stdlib/strtof.cpp"],
+    hdrs = ["src/stdlib/strtof.h"],
+    deps = [
+        ":__support_common",
+        ":__support_str_to_float",
+    ],
+)
+
+libc_function(
+    name = "strtod",
+    srcs = ["src/stdlib/strtod.cpp"],
+    hdrs = ["src/stdlib/strtod.h"],
+    deps = [
+        ":__support_common",
+        ":__support_str_to_float",
+    ],
+)
+
+libc_function(
+    name = "strtold",
+    srcs = ["src/stdlib/strtold.cpp"],
+    hdrs = ["src/stdlib/strtold.h"],
+    deps = [
+        ":__support_common",
+        ":__support_str_to_float",
+    ],
+)
+
 ############################### string targets ###############################
 
 no_sanitize_features = [
index e3c15f6..6646351 100644 (file)
@@ -46,6 +46,15 @@ libc_test(
 )
 
 libc_test(
+    name = "atof_test",
+    srcs = ["atof_test.cpp"],
+    deps = ["//libc:__support_fputil_fp_bits"],
+    libc_function_deps = [
+        "//libc:atof",
+    ],
+)
+
+libc_test(
     name = "bsearch_test",
     srcs = ["bsearch_test.cpp"],
     libc_function_deps = [
@@ -105,3 +114,39 @@ libc_test(
         "//libc:strtoull",
     ],
 )
+
+libc_test(
+    name = "strtof_test",
+    srcs = ["strtof_test.cpp"],
+    deps = [
+        "//libc:__support_fputil_fp_bits",
+        "//libc/utils/testutils:libc_test_utils",
+    ],
+    libc_function_deps = [
+        "//libc:strtof",
+    ],
+)
+
+libc_test(
+    name = "strtod_test",
+    srcs = ["strtod_test.cpp"],
+    deps = [
+        "//libc:__support_fputil_fp_bits",
+        "//libc/utils/testutils:libc_test_utils",
+    ],
+    libc_function_deps = [
+        "//libc:strtod",
+    ],
+)
+
+libc_test(
+    name = "strtold_test",
+    srcs = ["strtold_test.cpp"],
+    deps = [
+        "//libc:__support_fputil_fp_bits",
+        "//libc:__support_uint128",
+    ],
+    libc_function_deps = [
+        "//libc:strtold",
+    ],
+)