[bazel][libc] Add targets for integer abs and div functions.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D152084
This commit is contained in:
Siva Chandra Reddy
2023-06-03 23:04:20 +00:00
parent 355f466744
commit 2bd82c5462
3 changed files with 177 additions and 0 deletions

View File

@@ -1678,8 +1678,90 @@ libc_math_function(name = "scalbnf")
libc_math_function(name = "scalbnl")
############################## inttypes targets ##############################
libc_function(
name = "imaxabs",
srcs = ["src/inttypes/imaxabs.cpp"],
hdrs = ["src/inttypes/imaxabs.h"],
deps = [
":__support_common",
":__support_integer_operations",
],
)
libc_function(
name = "imaxdiv",
srcs = ["src/inttypes/imaxdiv.cpp"],
hdrs = ["src/inttypes/imaxdiv.h"],
deps = [
":__support_common",
":__support_integer_operations",
],
)
############################### stdlib targets ###############################
libc_function(
name = "abs",
srcs = ["src/stdlib/abs.cpp"],
hdrs = ["src/stdlib/abs.h"],
deps = [
":__support_common",
":__support_integer_operations",
],
)
libc_function(
name = "labs",
srcs = ["src/stdlib/labs.cpp"],
hdrs = ["src/stdlib/labs.h"],
deps = [
":__support_common",
":__support_integer_operations",
],
)
libc_function(
name = "llabs",
srcs = ["src/stdlib/llabs.cpp"],
hdrs = ["src/stdlib/llabs.h"],
deps = [
":__support_common",
":__support_integer_operations",
],
)
libc_function(
name = "div",
srcs = ["src/stdlib/div.cpp"],
hdrs = ["src/stdlib/div.h"],
deps = [
":__support_common",
":__support_integer_operations",
],
)
libc_function(
name = "ldiv",
srcs = ["src/stdlib/ldiv.cpp"],
hdrs = ["src/stdlib/ldiv.h"],
deps = [
":__support_common",
":__support_integer_operations",
],
)
libc_function(
name = "lldiv",
srcs = ["src/stdlib/lldiv.cpp"],
hdrs = ["src/stdlib/lldiv.h"],
deps = [
":__support_common",
":__support_integer_operations",
],
)
libc_function(
name = "atoi",
srcs = ["src/stdlib/atoi.cpp"],

View File

@@ -0,0 +1,30 @@
# This file is licensed under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# Tests for LLVM libc inttypes.h functions.
load("//libc/test:libc_test_rules.bzl", "libc_test")
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
libc_test(
name = "imaxabs_test",
srcs = ["imaxabs_test.cpp"],
libc_function_deps = [
"//libc:imaxabs",
],
)
libc_test(
name = "imaxdiv_test",
srcs = ["imaxdiv_test.cpp"],
libc_function_deps = [
"//libc:imaxdiv",
],
deps = [
"//libc/test/src/stdlib:div_test_helper",
],
)

View File

@@ -10,6 +10,71 @@ package(default_visibility = ["//visibility:public"])
licenses(["notice"])
libc_test(
name = "abs_test",
srcs = ["abs_test.cpp"],
libc_function_deps = [
"//libc:abs",
],
)
libc_test(
name = "labs_test",
srcs = ["labs_test.cpp"],
libc_function_deps = [
"//libc:labs",
],
)
libc_test(
name = "llabs_test",
srcs = ["llabs_test.cpp"],
libc_function_deps = [
"//libc:llabs",
],
)
cc_library(
name = "div_test_helper",
hdrs = ["DivTest.h"],
deps = [
"//libc/test/UnitTest:LibcUnitTest",
],
)
libc_test(
name = "div_test",
srcs = ["div_test.cpp"],
libc_function_deps = [
"//libc:div",
],
deps = [
":div_test_helper",
],
)
libc_test(
name = "ldiv_test",
srcs = ["ldiv_test.cpp"],
libc_function_deps = [
"//libc:ldiv",
],
deps = [
":div_test_helper",
],
)
libc_test(
name = "lldiv_test",
srcs = ["lldiv_test.cpp"],
libc_function_deps = [
"//libc:lldiv",
],
deps = [
":div_test_helper",
],
)
cc_library(
name = "atoi_test_helper",
hdrs = ["AtoiTest.h"],