Skip to content

Commit 4113c85

Browse files
committed
Add function-specific shared header and add support bazel targets.
1 parent dea47fd commit 4113c85

File tree

5 files changed

+58
-23
lines changed

5 files changed

+58
-23
lines changed

libc/shared/math.h

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,7 @@
1010
#define LLVM_LIBC_SHARED_MATH_H
1111

1212
#include "libc_common.h"
13-
#include "src/__support/math/expf.h"
1413

15-
namespace LIBC_NAMESPACE_DECL {
16-
namespace shared {
14+
#include "math/expf.h"
1715

18-
using math::expf;
19-
20-
} // namespace shared
21-
} // namespace LIBC_NAMESPACE_DECL
22-
23-
#endif // LLVM_LIBC_SHARED_FP_BITS_H
16+
#endif // LLVM_LIBC_SHARED_MATH_H

libc/shared/math/expf.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//===-- Shared expf function ------------------------------------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLVM_LIBC_SHARED_MATH_EXPF_H
10+
#define LLVM_LIBC_SHARED_MATH_EXPF_H
11+
12+
#include "shared/libc_common.h"
13+
#include "src/__support/math/expf.h"
14+
15+
namespace LIBC_NAMESPACE_DECL {
16+
namespace shared {
17+
18+
using math::expf;
19+
20+
} // namespace shared
21+
} // namespace LIBC_NAMESPACE_DECL
22+
23+
#endif // LLVM_LIBC_SHARED_MATH_EXPF_H

utils/bazel/llvm-project-overlay/libc/BUILD.bazel

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1616,13 +1616,18 @@ libc_header_library(
16161616

16171617
############################### errno ########################################
16181618

1619+
libc_support_library(
1620+
name = "__support_libc_errno",
1621+
hdrs = ["src/__support/libc_errno.h"],
1622+
)
1623+
16191624
libc_support_library(
16201625
name = "errno",
16211626
srcs = ["src/errno/libc_errno.cpp"],
1622-
hdrs = ["src/__support/libc_errno.h"],
16231627
deps = [
16241628
":__support_common",
16251629
":__support_cpp_atomic",
1630+
":__support_libc_errno",
16261631
":__support_macros_attributes",
16271632
":__support_macros_properties_architectures",
16281633
":hdr_errno_macros",
@@ -1973,6 +1978,29 @@ libc_support_library(
19731978
],
19741979
)
19751980

1981+
libc_support_library(
1982+
name = "__support_math_exp_float_constants",
1983+
hdrs = ["src/__support/math/exp_float_constants.h"],
1984+
)
1985+
1986+
libc_support_library(
1987+
name = "__support_math_expf",
1988+
hdrs = ["src/__support/math/expf.h"],
1989+
deps = [
1990+
":__support_common",
1991+
":__support_fputil_fenv_impl",
1992+
":__support_fputil_fp_bits",
1993+
":__support_fputil_multiply_add",
1994+
":__support_fputil_nearest_integer",
1995+
":__support_fputil_polyeval",
1996+
":__support_fputil_rounding_mode",
1997+
":__support_libc_errno",
1998+
":__support_macros_config",
1999+
":__support_macros_optimization",
2000+
":__support_math_exp_float_constants",
2001+
],
2002+
)
2003+
19762004
############################### complex targets ################################
19772005

19782006
libc_function(
@@ -2569,18 +2597,9 @@ libc_math_function(
25692597

25702598
libc_math_function(
25712599
name = "expf",
2572-
hdrs = [
2573-
"src/__support/exp_float_constants.h",
2574-
"src/__support/expf.h",
2575-
],
25762600
additional_deps = [
2577-
":__support_fputil_fma",
2578-
":__support_fputil_multiply_add",
2579-
":__support_fputil_nearest_integer",
2580-
":__support_fputil_polyeval",
2581-
":__support_fputil_rounding_mode",
2582-
":__support_macros_optimization",
2583-
":common_constants",
2601+
":__support_math_expf",
2602+
":errno",
25842603
],
25852604
)
25862605

utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,6 @@ def libc_header_library(name, hdrs, deps = [], **kwargs):
250250

251251
def libc_math_function(
252252
name,
253-
hdrs = [],
254253
additional_deps = None):
255254
"""Add a target for a math function.
256255
@@ -277,6 +276,6 @@ def libc_math_function(
277276
libc_function(
278277
name = name,
279278
srcs = ["src/math/generic/" + name + ".cpp"],
280-
hdrs = ["src/math/" + name + ".h"] + hdrs,
279+
hdrs = ["src/math/" + name + ".h"],
281280
deps = [":__support_common"] + OLD_FPUTIL_DEPS + additional_deps,
282281
)

utils/bazel/llvm-project-overlay/libc/test/libc_test_rules.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def libc_test(name, copts = [], deps = [], local_defines = [], **kwargs):
3131
deps = [
3232
"//libc/test/UnitTest:LibcUnitTest",
3333
"//libc:__support_macros_config",
34+
"//libc:__support_libc_errno",
3435
"//libc:errno",
3536
"//libc:func_aligned_alloc",
3637
"//libc:func_free",

0 commit comments

Comments
 (0)