Commit graph

312 commits

Author SHA1 Message Date
Elliott Hughes
383349cf06 Remove an unused header file.
This was our only remaining BSD 4-clause file.

Test: N/A
Change-Id: I3a4042a92f1ff6ab7d3e1a0cd043952f98f0861e
2024-03-19 19:37:41 +00:00
Elliott Hughes
526bd985c8 Include the SPDX identifiers in NOTICE files.
We're starting to see projects _only_ use the SPDX identifiers (and
they're more readable "at a glance" anyway), so it's probably time to
include these...

Test: N/A
Change-Id: I5c76d77dcd392a8db1166108e410389d349a42c3
2024-03-19 15:56:30 +00:00
Pirama Arumuga Nainar
6896552367 Disable -Wignored-pragmas only for arm32
Bug: http://b/178516148

Recent clang versions support `#pragma STDC FENV_ACCESS ON` for aarch64 and riscv64.

Change-Id: I8117130c4d7d64221699ca7a27b93a3a86f64d00
Test: presubmit
2024-01-16 19:52:02 +00:00
Elliott Hughes
a137234742 Update NOTICE file.
I don't know why we seem to keep missing this so much these days...

Test: treehugger
Change-Id: I018a528f35aa938f8fc5cdafe2eaf3f1bbc1a6d9
2023-08-04 12:43:21 -07:00
Elliott Hughes
9a80691e38 Merge "Sync upstream FreeBSD libm." into main 2023-08-04 14:51:38 +00:00
Elliott Hughes
4088e3a587 Sync upstream FreeBSD libm.
Test: treehugger
Change-Id: I583a3e93821d512c975db34fc1610ffd22445d58
2023-08-03 13:33:56 -07:00
Matthias Maennich
68cbdca6bb libm/libc: remove 'allow_untyped_symbols' flags
Those flags were used to suppress ABI tidy errors, but by now are not in
use anymore and can safely be removed.

Bug: 156513478
Change-Id: Ibc9625d139f933e48ebb4ddebe70d424f6231f3f
Signed-off-by: Matthias Maennich <maennich@google.com>
2023-08-01 17:23:49 +00:00
Elliott Hughes
c204334b06 Reuse the libm scalbn() as ldexp().
These are the same function for machines with binary floats (that is:
all machines), but ldexp() is in libc rather than libm, so we can't just
use an alias.

We were using this duplicate copy of the code, but upstream FreeBSD has
removed it, and I'd prefer to do the same.

Longer term, we should just move all of libm into libc (but keep an
empty libm for compatibility), but this is probably easier for now.

Test: treehugger
Change-Id: I1a1d6d4f1771316f791ad59c714a3a65aedefc81
2023-07-20 21:05:44 +00:00
Treehugger Robot
8a771303b8 Merge "Sync upstream FreeBSD libm (trivial changes)." into main 2023-07-20 14:15:41 +00:00
Elliott Hughes
8810bd7585 Sync upstream FreeBSD libm (real changes).
Test: treehugger
Change-Id: Icf591ba195a3f5080203b157aa7f43d518a9cc69
2023-07-19 14:11:58 -07:00
Elliott Hughes
c1e46b62e9 Sync upstream FreeBSD libm (trivial changes).
More interesting changes to come, but there's enough of this noise I'm
separating it out...

Test: treehugger
Change-Id: I0efc0ac860a147112369df7561ee48a92a2a5e84
2023-07-19 14:08:03 -07:00
Elliott Hughes
ab2d3e1049 Remove __RENAME_LDBL.
Discussion of this during my recent minor cleanup convinced me that we
should just remove __RENAME_LDBL. There's no obvious benefit to being
able to build something for 32-bit if you can't build the same code for
64-bit, given that most new hardware (and entire verticals such as Auto)
are 64-bit-only, and the Play Store requires any app with 32-bit code to
also ship 64-bit code.

Test: treehugger
Change-Id: I1c5503b968ca66925d7bd125bd3630c41ec1bfd0
2023-06-07 17:20:53 +00:00
Cole Faust
f5968d82f5 Rename files/modules that have the same name
Bazel doesn't like it when modules produce files with the same name
as the module itself, and gives warnings.

Rename either the module or file in this case so that the file has
an extension and the module doesn't.

Bug: 198619163
Test: m nothing
Change-Id: Ic4592b06f575496ffd54ac75cb4d682118b29d93
2023-04-11 15:20:19 -07:00
Elliott Hughes
2289ca2bd3 risc-v: use clang's builtins for more of libm.
This completes the set, and gets riscv64 to parity with arm64.

Test: llvm-objdump -d
Test: bionic-unit-tests-static --gtest_filter='math*'
Bug: https://github.com/google/android-riscv64/issues/11
Change-Id: I4230005abcd8d6025d82f1e8afe5831fad2db04d
2023-03-22 14:11:35 -07:00
Elliott Hughes
2f5829b55d Remove <fenv.h> inlines for obsolete API levels.
The next NDK to take these headers only supports API 21 and later, so
clean up some of the trivial cruft.

Test: treehugger
Change-Id: Ib735a776d244cc82858f2ed629dd63a54dbaf650
2023-02-24 00:16:41 +00:00
Elliott Hughes
079f6fd857 libm: admit we use SSE4.1 in x86's libm.
Although the NDK ABI for x86 doesn't include SSE4.1, it's needed for
roundss/roundsd, and we've used that (via hand-written assembler) in the
x86 libm since Android M. We've recently switched to using compiler
builtins to generate the assembler instead, and without allowing the
compiler to use SSE4.1, it can't (resulting in infinite recursion as
these functions defer to themselves for an answer).

Given that the x86 libm.so has required SSE4.1 for 8 years at this
point without anyone noticing, let alone caring, let's just retain the
status quo rather.

(Despite the fact that this caused boot failures for cf_x86, I didn't
notice when testing the 32-bit libm.so from a cf_x86_64 build because our
x86-64 ABI *does* include SSE4.1, and the BoardConfig.mk for cf_x86_64
explicitly chooses "silvermont" as the 32-bit cpu variant, implicitly
enabling SSE4.1.)

Test: llvm-objdump -d on a cf_x86 build
Change-Id: I9392d3699057fcca96677de52f8d36d377b1719a
2023-02-10 16:42:50 +00:00
Elliott Hughes
37d72a31ab Fix floor()/floorl() on armv7 arm32 devices.
armv8 arm32 has a single instruction for the floor() family, but armv7
arm32 doesn't. Play stupid preprocessor and namespace tricks to get
the best of both worlds (using __ARM_ARCH in code is less awkward than
trying to do similar with armv7_a and armv7_a_neon in the build system).

Bug: http://b/268267713
Test: llvm-objdump -d
Change-Id: I2a4bef6e6caa49092810f53eb7bf6ea46237743f
2023-02-09 06:54:18 +00:00
Elliott Hughes
0d2c71d882 Move the copysign() family over to builtins all the time.
Test: llvm-objdump -d
Change-Id: Ic65250652362fd69bda31605b215d1a587cb5bce
2023-02-08 01:26:43 +00:00
Elliott Hughes
2f1a7b9852 Let clang generate most of our assembler for x86/x86-64 too.
It looks like the only functions current clang can't do are the lrint
family. Everything else looks good, and the fact that clang has builtins
means we shouldn't normally see calls to any of these functions anyway.

Test: llvm-objdump
Change-Id: I65b4da96b6c9b10f01cb54a7ebd1de5934ba4488
2023-02-07 01:22:29 +00:00
Elliott Hughes
47aa5b93fe libm: remove hand-written assembler for arm32 too.
The clang builtins for arm32 give us identical code to what we had for
sqrt()/sqrtf(), and significantly better (neon) code for
floor()/floorf() than the integer-only implementations we had.

Test: llvm-objdump
Change-Id: I224bcfcf4739a80e1a7cdd07b0b1fa232fdf2dab
2023-02-03 01:21:12 +00:00
Elliott Hughes
2dcc5ce03c Use clang's builtins for sqrt()/sqrtf() and lrint() family.
Bug: https://github.com/google/android-riscv64/issues/12
Test: llvm-objdump
Change-Id: I2b5647ca245b28433faabe633d970ea2fd69c763
2023-02-01 02:05:24 +00:00
Chih-Hung Hsieh
e343db3f54 Disable clang-tidy for upstream files.
Bug: 264302877
Test: presubmit tests; make tidy-bionic_subset
Change-Id: I278201c62e70898103bf20ce8823106418c8fb05
2023-01-03 15:08:22 -08:00
Elliott Hughes
7d2f1b3a46 Add a code comment explaining the riscv64 TODOs in libm/Android.bp.
Test: treehugger
Change-Id: Ia52217533328321375bc0cd132b8571c9b9874f5
2022-12-12 17:08:30 +00:00
Elliott Hughes
edf386b1f9 Use more compiler builtins for libm.
Once we have an llvm with https://reviews.llvm.org/D136508, we will be
able to defer to more compiler builtins, but for now let's do what we
can...

Test: llvm-objdump (plus the tests still pass!)
Change-Id: Ia5c704409ca88ab1a02342c1b5dde8525da95243
2022-12-12 16:40:46 +00:00
Elliott Hughes
591a2a798d Remove obsolete hacks for the fabs() family.
We don't support GCC any more, and clang's got better since this commit
was written. It doesn't produce _identical_ code, but it's a similar
single-instruction bit twiddle.

This also doesn't regress x86 for fabsl (that code looks the same before
and after) and there is no riscv32.

Test: llvm-objdump -d
Change-Id: I7acea6fd26f8760763f3744201ed42a99186562b
2022-12-05 20:58:15 +00:00
Elliott Hughes
a0faeb299d Remove remaining "ASCII binary blobs".
We stopped accepting new code in this form (compiler output from
compilers we don't have compiling source we don't have [or possibly the
same source we do have --- how would be know?]) years ago, but never
went back to clean up existing instances.

This doesn't affect the string/memory routines, which are intelligible,
nor all of the libm stuff (we're keeping the intelligible subset), but
does affect all the trig functions.

The right way to do this is to either have commented hand-written
assembler (which we have always taken, and will continue to take) or to
have C/C++ source that can be built with LLVM (which will then be built
as part of the regular build). This is what we do for arm/arm64, for
example, with the C/C++ source coming from
https://github.com/ARM-software/optimized-routines and being mirrored
in external/arm-optimized-routines, and built by Android's clang at
build time.

Test: treehugger
Change-Id: Icd69ef34b8a9ea16ea2b7d5d6587c2a9143b7740
2022-11-18 20:15:40 +00:00
Elliott Hughes
e0942db080 Remove fallback C sqrt/sqrtf.
Everyone uses assembler.

Test: treehugger
Change-Id: Id88b029e7d3558f203223d5153ec6098c7230d64
2022-10-28 20:18:17 +00:00
Treehugger Robot
836753a22b Merge "Simplify the libm build now we don't support non-neon." 2022-10-28 17:18:12 +00:00
Elliott Hughes
0cbb902e0d arm64: use llvm's builtins for lround/lroundf/llround/llroundf.
Test: objdump
Change-Id: I1c5c4dc5cd769f0580d91355e4e5706f9bce46c1
2022-10-28 00:00:00 +00:00
Elliott Hughes
46f24a18c0 arm64: use llvm's builtins for copysign() and copysignf().
Test: objdump
Change-Id: I26ab2c4745c5f64140cf781a9f42bce6fc79e1ef
2022-10-26 21:55:34 +00:00
Elliott Hughes
4ceb3474be Add riscv64 lrint.S.
This is mainly just to match what we have for arm64.

The test failures before and after this change are all for the long
double variant, which this change doesn't touch. (The problem there is
that clang is calling `__fixtfdi` for the cast in lrintl(), but that
doesn't respect the current rounding mode, which lrintl() is required
to do. `#pragma STDC FENV_ACCESS ON` doesn't fix this, so there's going
to be some llvm work needed to fix this.)

I've replaced the ASSERTs with EXPECTs in the relevant test to ensure
we're checking all the other assertions despite the `long double`
failures.

Test: bionic-unit-tests-static
Change-Id: Ia24bf21619631b6f8b3b607d30536011bb4cd826
2022-10-25 22:27:10 +00:00
Elliott Hughes
a70e345da0 Simplify the libm build now we don't support non-neon.
Test: treehugger
Change-Id: I582ee2477186ba25a455b3b63f74e915be861365
2022-10-24 21:57:57 +00:00
Elliott Hughes
a4398452fd Add trivial assembler implementations of sqrt()/sqrtf().
10x faster in the usual bionic benchmarks.

Test: treehugger
Change-Id: If121cb1ed1ff0756310f34cbaa2c14e28484f1b8
2022-10-24 20:31:09 +00:00
Elliott Hughes
7047431d2f arm64: fix fesetround().
The FE_* rounding mode constants have different values on different
architectures, so you can't just copy & paste the validity check from
one to another, like I did here...

Bug: http://b/254501880
Test: treehugger
Change-Id: I2ffa766ffcbe22c1afcd28eab4bd964100dc2d98
2022-10-19 18:44:33 +00:00
Treehugger Robot
5a4a2fec44 Merge "arm64: simplify the fenv implementation a bit." 2022-10-19 00:09:10 +00:00
Elliott Hughes
6a1b0f3cac riscv64: fenv implementation.
Signed-off-by: Mao Han <han_mao@linux.alibaba.com>
Signed-off-by: Xia Lifang <lifang_xia@linux.alibaba.com>
Signed-off-by: Chen Guoyin <chenguoyin.cgy@linux.alibaba.com>
Signed-off-by: Wang Chen <wangchen20@iscas.ac.cn>
Signed-off-by: Lu Xufan <luxufan@iscas.ac.cn>
Test: treehugger
Change-Id: I0f0227cd4cb5e78aba1a749f8d8fce296a024dfb
2022-10-14 21:34:18 +00:00
Elliott Hughes
a93431ca4c arm64: simplify the fenv implementation a bit.
The macOS man page was helpful in advancing my understanding of
feupdateenv() in particular.

Test: treehugger
Change-Id: I511e8b31ac16f3fdf08b42eee5a2e6558ec3b70b
2022-10-14 20:38:35 +00:00
Elliott Hughes
022e1aa767 Sync libm with upstream freebsd.
This is a complete update.

Test: treehugger
Change-Id: I91cc4d57ea49b46b607fde8fa30e2e04ecc9e690
2022-07-12 17:01:46 -07:00
Elliott Hughes
291f98a66d Switch to the more common idiom for scripts in genrules.
Bug: http://b/198619163
Test: treehugger
Change-Id: I8a6e9e179aef45e1b0622a2e15f80f92041f9736
2022-06-30 23:35:11 +00:00
Dan Albert
2d8d2a0064 Disable strict abigail checking pending asm fix.
Test: m ndk
Bug: http://b/190554910
Change-Id: Ideb0c6d8ac5428c2ebe211393929f1d5c891dfba
2022-03-29 15:59:00 -07:00
Colin Cross
335e27b740 Use single module for libclang_rt.builtins-exported
The clang prebuilts now provide a single module with per-architecture
variants instead of a module per architecture.

Bug: 220019988
Test: m checkbuild
Ignore-AOSP-First: topic contains vendor projects
Change-Id: I079f36f94b13e06d59a16cf665b65db76084021a
Merged-In: I079f36f94b13e06d59a16cf665b65db76084021a
2022-03-01 11:36:55 -08:00
Elliott Hughes
99ef447d0f libm: sync with upstream.
There's potential here to maybe lose some/all of builtins.cpp, but I'll
look at that separately later.

Test: treehugger
Change-Id: I2c2bc1d0753affdd214daeb09fa1ac7cd73db347
2022-01-12 17:52:15 -08:00
Elliott Hughes
a13d0660fe Use -fno-builtin for libc and libm.
clang was getting in the way of a strftime(3) optimization, and smaller
hammers weren't working, and this seems like the right choice for libc
anyway? If we have code that can usefully be optimized, we should do it
in the source. In general, though, no libc/libm author should be
ignorant of memset(3) or memcpy(3), and would have used it themselves if
it made sense. (And the compiler isn't using profiling data or anything;
it's just always assuming it should use the functions, and doesn't
consider whether the cost of the calls can be amortized or not.)

Test: treehugger
Change-Id: Ia7e22623e47bfbfcfe46c1af0d95ef7e8669c0f6
2021-12-02 14:42:16 -08:00
Chih-Hung Hsieh
9935aa7a27 Add/allow clang-14 warnings.
* -Wstatic-in-inline found in
  libm/upstream-freebsd/lib/msun/src/s_lround.c

Test: mm in bionic/tests
Bug: 201432564
Bug: 202752322
Change-Id: I4d506fa539ab0de939d85924a5fd9a61644e4fb0
2021-10-11 12:37:56 -07:00
Pirama Arumuga Nainar
0c3bb2cf8f [libm] Set pragma FENV_EACCESS for x86_64, i386
Bug: http://b/157914307

This pragma enables
- -frounding-math, i.e. rounding mode set at runtime are honored
- -ffp-exception-behavior=strict, i.e. FPE semantics are preserved.
- Prevents use of FMA instructions.

Test: Build toolchain without revert https://r.android.com/1298100
      and run bionic-unit-tests.math_h*
Change-Id: I6249b20c93e0fd4ebbdfbe433da4ad4a65d3747b
2021-08-20 14:49:17 -07:00
Colin Cross
b5bfe0bd51 Move system_shared_libs into target.bionic clause
Use target.bionic.system_shared_libs when it is used to limit the
default shared libraries (as opposed to remove them completely).
This avoids attempting to add a host dependency on libc when
system_shared_libs is modified to apply to all variants.

Bug: 193559105
Test: m checkbuild
Change-Id: I8d623321ce5145cf2968f83f78b5cb50711290f4
2021-07-13 16:26:28 -07:00
Colin Cross
a0a4a6c296 Replace llndk_library with llndk clause in cc_library
Remove the vestigial llndk_library and replace it with properties
in the llndk clause of the implementation cc_library.

In order to reduce duplication of the arch-specific headers used
by the implementation and LLNDK, rename libc_headers_arch to
libc_llndk_headers and hoist the "include" directory out of it,
since that directory is preproccessed separately for LLNDK
libraries.

Bug: 170784825
Test: m checkbuild
Test: compare out/soong/build.ninja
Change-Id: I75f0ff9129d910640da55eee6a6387467e6e4a9d
2021-04-26 17:45:57 -07:00
Bob Badour
aa7d835fdd Add LOCAL_LICENSE_KINDS to bionic
Added SPDX-license-identifier-Apache-2.0 to:
  apex/Android.bp
  libdl/Android.bp
  tools/Android.bp
  tools/versioner/Android.bp
  tools/versioner/src/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD to:
  benchmarks/Android.bp
  benchmarks/linker_relocation/gen/Android.bp
  libc/malloc_debug/Android.bp
  libc/system_properties/Android.bp
  tests/Android.bp
  tests/libs/Android.bp
  tests/libs/Android.build.dlext_testzip.mk
  tests/make_fortify_compile_test.mk

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD
    SPDX-license-identifier-ISC SPDX-license-identifier-MIT
    legacy_notice legacy_unencumbered
to:
  libc/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD
    SPDX-license-identifier-MIT legacy_unencumbered
to:
  libm/Android.bp

Added SPDX-license-identifier-Apache-2.0 legacy_unencumbered
to:
  libc/tools/Android.bp

Added SPDX-license-identifier-BSD
to:
  benchmarks/linker_relocation/Android.bp
  benchmarks/spawn/Android.bp
  libc/async_safe/Android.bp
  libc/malloc_hooks/Android.bp
  libfdtrack/Android.bp
  linker/Android.bp
  tests/headers/Android.bp
  tests/headers/posix/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all
Exempt-From-Owner-Approval: janitorial work
Change-Id: Ib05bcaa276b3aa71a7654ccbe8e67e1f16aec9f3
2021-02-19 23:38:28 +00:00
Elliott Hughes
aa8db1b9d1 Fix/update notices.
Auto-generate NOTICE files for all the directories, and for each one
individually rather than mixing libc and libm together.

Test: N/A
Change-Id: I7e251194a8805c4ca78fcc5675c3321bcd5abf0a
2021-02-16 15:06:50 -08:00
Chih-Hung Hsieh
444e2f69e9 Add -Wno-ignored-pragmas.
* https://reviews.llvm.org/D90316 changed warning on
  FENV_ACCESS pragma from unknown to ignored.
  Existing -Wno-unknown-pragmas cannot suppress the new
  -Wignored-pragmas.

Bug: 178516148
Test: make with WITH_TIDY=1
Change-Id: I783feef35324ef43946efca844cd944410875bfa
2021-02-04 23:51:53 +00:00