Commit graph

36467 commits

Author SHA1 Message Date
Elliott Hughes
b813a6a6be Add %b and %B support to the printf/wprintf family.
Coming to C23 via WG14 N2630, and already in glibc.

We're still missing clang support for %b and %B in format string checking,
but it's probably easier to fix this first. (Apparently GCC already has
support because of glibc.)

Test: treehugger
Change-Id: Ie8bfe4630d00c50e1d047d6756a7f799205356db
2022-08-01 22:18:40 +00:00
Elliott Hughes
27b3ad2c78 Merge "Simplify the implementation of get_nproc()." 2022-07-29 18:19:29 +00:00
Elliott Hughes
6f4bb0771e Merge "fread: cope with >2GiB totals." 2022-07-29 16:16:27 +00:00
Elliott Hughes
be78fc90e6 fread: cope with >2GiB totals.
The FILE::_read function pointer takes an int rather than a size_t, so
we need to be careful to break large reads up for it.

fwrite() hasn't (yet) been optimized in this way, so it's immune for
now, but add the corresponding write test anyway.

Seeking already uses a off64_t function pointer where possible, so I
don't think there's anything more to be done there.

No other function pointers in FILE are relevant.

Bug: https://issuetracker.google.com/240139009
Test: treehugger
Change-Id: Ife2537e10f178bb0d980719592539f4b00b67031
2022-07-28 20:58:45 +00:00
Elliott Hughes
d771a7cde3 Simplify the implementation of get_nproc().
It came up on the musl mailing list that there's not actually any need
to iterate over the directory entries:

https://www.openwall.com/lists/musl/2022/07/27/1

This lets us reuse the code for "online" processors in the
implementation of "configured" processors. The question of whether
"configured" should correspond to Linux's "possible" or "present" isn't
obvious to me, but the distinction seems unlikely to matter on mobile
devices anyway, and that's a trivial change should it ever be needed.
Plus the motivating argument from the person who brought this up was
that callers asking for "configured" processors are probably asking for
an upper bound, which sounds convincing to me.

Test: treehugger
Change-Id: I0d4e13538dc6b09a6dba520d9ac24f436906f7c0
2022-07-28 17:52:46 +00:00
Elliott Hughes
bf76fc6e64 Merge "Tidy up the x86 atom/silvermont stuff similar to x86-64." 2022-07-25 19:59:03 +00:00
Treehugger Robot
2d072335a6 Merge "Handle null TM_ZONE in z case in strftime." 2022-07-25 18:29:54 +00:00
Elliott Hughes
ed777145e7 Tidy up the x86 atom/silvermont stuff similar to x86-64.
Get rid of the bad precedent of having the architecture variant in the
file name *and* directory name.

Test: treehugger
Change-Id: I78582c12b4390578c51d52d4dd86f57470129abf
2022-07-25 16:27:25 +00:00
Elliott Hughes
61a42bf1ee Merge "avx2 implementation for memset." 2022-07-25 15:51:51 +00:00
Almaz Mingaleev
24bfd8eed7 Handle null TM_ZONE in z case in strftime.
For correct %z output tzcode requires tm struct to be modified by
mktime call or be output of localtime. But as TM_ZONE is null, we
are comparing against +0000.

See https://mm.icann.org/pipermail/tz/2022-July/031674.html

Europe/Lisbon test is added to confirm that current implementation
deviates from libc specification and uses more than just tm_isdst
to find out a time zone's offset.

Bug: 239128167

Test: adb shell /data/nativetest64/bionic-unit-tests-static/bionic-unit-tests-static
Test: adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static

Change-Id: Ic27775c840467c4e9ef55bc730a313709372314b
2022-07-25 16:39:12 +01:00
ahs
919fb7f2e0 avx2 implementation for memset.
This patch includes handwritten avx2
assembly for memset 64-bit. Uses
non-temporal stores for very large sizes.
Also includes dynamic dispatch for APIs
having multiple implementations.

Convincing benchmark improvements for sizes above 512 bytes, and
although the slight regression for small sizes is unfortunate, it's
probably small enough to be okay?

Before:

  BM_string_memset/8/0            3.06 ns         3.04 ns    222703428 bytes_per_second=2.45261G/s
  BM_string_memset/16/0           3.50 ns         3.47 ns    202569932 bytes_per_second=4.29686G/s
  BM_string_memset/32/0           3.50 ns         3.48 ns    200064955 bytes_per_second=8.57386G/s
  BM_string_memset/64/0           3.49 ns         3.46 ns    201928186 bytes_per_second=17.2184G/s
  BM_string_memset/512/0          14.8 ns         14.7 ns     47776178 bytes_per_second=32.3887G/s
  BM_string_memset/1024/0         27.3 ns         27.1 ns     25884933 bytes_per_second=35.2515G/s
  BM_string_memset/8192/0          203 ns          201 ns      3476903 bytes_per_second=37.9311G/s
  BM_string_memset/16384/0         402 ns          399 ns      1750471 bytes_per_second=38.2725G/s
  BM_string_memset/32768/0         932 ns          925 ns       755750 bytes_per_second=33.0071G/s
  BM_string_memset/65536/0        2038 ns         2014 ns       347060 bytes_per_second=30.3057G/s
  BM_string_memset/131072/0       4012 ns         3980 ns       175186 bytes_per_second=30.6682G/s

After:

  BM_string_memset/8/0            3.32 ns         3.23 ns    208939089 bytes_per_second=2.3051G/s
  BM_string_memset/16/0           4.07 ns         3.98 ns    173479615 bytes_per_second=3.74822G/s
  BM_string_memset/32/0           4.07 ns         3.95 ns    177208119 bytes_per_second=7.54344G/s
  BM_string_memset/64/0           4.09 ns         4.00 ns    174729144 bytes_per_second=14.8878G/s
  BM_string_memset/512/0          10.7 ns         10.4 ns     65922763 bytes_per_second=45.6611G/s
  BM_string_memset/1024/0         18.0 ns         17.6 ns     40489136 bytes_per_second=54.3166G/s
  BM_string_memset/8192/0          109 ns          106 ns      6577711 bytes_per_second=71.7667G/s
  BM_string_memset/16384/0         221 ns          210 ns      3343800 bytes_per_second=72.684G/s
  BM_string_memset/32768/0         655 ns          623 ns      1153501 bytes_per_second=48.9781G/s
  BM_string_memset/65536/0        1547 ns         1495 ns       461702 bytes_per_second=40.8154G/s
  BM_string_memset/131072/0       2991 ns         2924 ns       240189 bytes_per_second=41.7438G/s

This patch drops the wmemset() code because we don't even have a
microbenchmark for it, we have as many implementations checked in as we
have non-test call sites (!), so at this point it seems like we've spent
more time maintaining wmemset() than running it!

Test: bionic/tests/run-on-host.sh 64
Signed-off-by: ahs <amrita.h.s@intel.com>
Change-Id: Ie5047df5300638c1e4c69f8285d33d034f79c83b
2022-07-22 21:48:50 +00:00
Almaz Mingaleev
1031e0da38 Merge "Add post 2100 year mktime test." 2022-07-18 11:14:49 +00:00
Treehugger Robot
7c3f9cb63f Merge "Add the other known aliases for the recent Android releases." 2022-07-16 04:08:00 +00:00
Elliott Hughes
7b396aee5f Add the other known aliases for the recent Android releases.
Test: treehugger
Change-Id: Ic861cba14236a8e4cd60be340407a8c80cda6c8f
2022-07-15 17:04:50 -07:00
Almaz Mingaleev
10fed72517 Add post 2100 year mktime test.
tzdata now has transitions up to the year 2100. Added test to make
sure that dates beyond that are handled properly too.

Bug: 25413083

Test: see system/timezone CL
Change-Id: I02ea04b2c5cfb47bde5fb05f108113901ea33a39
2022-07-15 14:36:26 +01:00
Treehugger Robot
fee05f06fb Merge "Rewrite function definitions with identifier lists" 2022-07-13 17:29:04 +00:00
Yi Kong
7eeb11da01 Rewrite function definitions with identifier lists
This syntax is removed in C2x proposal N2432.

Test: presubmit
Change-Id: Ic1309841423143e48513dd8b67166b4fde2d67fb
2022-07-13 10:58:42 +08:00
Treehugger Robot
24062ac661 Merge "Sync with upstream openbsd." 2022-07-13 02:55:33 +00:00
Treehugger Robot
6c2804bc10 Merge "Sync libm with upstream freebsd." 2022-07-13 02:54:56 +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
fbac9af484 Sync with upstream openbsd.
Note that this is only a partial update; some other files have changes
upstream that aren't here, but they're changes that seem to require a
bit more thought, whereas these seem easy (and the base64.c and fputws.c
C2x compatibility changes were the motivation to sync right now).

Test: treehugger
Change-Id: I2f86708e25bcb9e779ecb6f9643b769cd4f83240
2022-07-12 13:32:02 -07:00
Treehugger Robot
c700432ba8 Merge "Extend bionic-unit-tests timeout." 2022-07-11 19:51:59 +00:00
Mitch Phillips
1f3c8d688c Extend bionic-unit-tests timeout.
GWP-ASan stress tests can take a while, especially under HWASan.

Bug: 238585984
Test: sleep(100) in one of the tests, and then 'atest bionic-unit-tests'
Change-Id: Ibd983da1c8fd06cffed756cf3b24523f4671d49e
2022-07-11 09:35:12 -07:00
Mark Dacek
7ff6a44dce Merge "Rename deps in libc to account for name/src collision work." 2022-07-08 18:32:06 +00:00
MarkDacek
d88d7ea329 Rename deps in libc to account for name/src collision work.
Test: m
Bug: 198619163
Change-Id: Ic41f7c1611d69c0c0936b8f5869a3450f1542b5c
2022-07-06 17:26:20 +00:00
Colin Cross
cb8b43e1dd Merge "Switch to the more common idiom for scripts in genrules." 2022-07-01 02:57:12 +00: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
Almaz Mingaleev
ecca88329b Merge "Revert "Revert "Do not look for tzdata file in /data.""" 2022-06-30 16:17:05 +00:00
Almaz Mingaleev
da75bb637d Revert "Revert "Do not look for tzdata file in /data.""
This reverts commit 4e013233b8.

Issue was in unexpected returned fd and errno value combination.
See comments in bionic.cpp and time_test.cpp.

Bug: 236967833
Fix: 236967833

Test: atest CtsBionicTestCases
Test: atest toybox-tests

Change-Id: I51b3e1527ff16b2a6ea4d6fedf8102019f7fd896
2022-06-30 09:39:53 +01:00
Spandan Das
727ab31fd8 Merge "Declare libc's contributions to API surface(s) in Multi-tree" 2022-06-29 23:51:05 +00:00
Mitch Phillips
4c5e40b98a Merge "Add persistent GWP-ASan sysprops." 2022-06-29 20:56:56 +00:00
Spandan Das
3523e8e393 Declare libc's contributions to API surface(s) in Multi-tree
As part of go/multitree-design, build dependencies between API domains
must be via stable API surfaces. The contributions to the API surfaces
will be declared in BUILD files so that we can skip the
migration from Soong->Bazel entirely for this (go/multi-tree-api-export)

libc is one such component of the system API domain that contributes to
the public API surface. This CL declares libc's contributions (its
headers/.map.txt/other_metadata). These BUILD files were generated
manually by looking at existing Android.bp files.

Test: STANDALONE_BAZEL=1 tools/bazel cquery
//bionic/libc:libc_contributions --output=starlark
--starlark:expr="providers(target).get(\"//build/bazel/rules/apis:cc_api_contribution.bzl%CcApiContributionInfo\")"
2>/dev/null | less

Change-Id: If2a429b782651872fd6d8bf8c291439fdf838d85
2022-06-29 20:40:11 +00:00
Mitch Phillips
9634c36565 Add persistent GWP-ASan sysprops.
Adds persistent sysprops for test infra usage, and adds the tests for
the sysprops.

The test does some fancy flocking in order to restore any existing
GWP-ASan sysprop usage in the test cleanup.

Bug: 236738714
Test: atest bionic-unit-tests
Change-Id: I8956296d39c98ce8c7dd0a703b240530d8ad48db
2022-06-29 09:25:13 -07:00
Treehugger Robot
fd0a1ea466 Merge "Add Android U API level to NDK headers" 2022-06-28 10:28:41 +00:00
Michael Wright
8cd2ebf80e Add Android U API level to NDK headers
Test: Build
Change-Id: Ic1e0d8b7e5abf07045944d2f610764709b45c923
2022-06-25 00:56:08 +00:00
Elliott Hughes
9da1b3fa29 Merge "Add the toybox tests to bionic's presubmit." 2022-06-24 15:50:19 +00:00
Elliott Hughes
8fda8fc0fd Add the toybox tests to bionic's presubmit.
I can't believe we didn't have this already.

Bug: http://b/236967833
Test: treehugger
Change-Id: Ic0fa7fd8e74860744d13d0c168b49240a86a8df2
2022-06-23 22:31:57 +00:00
Treehugger Robot
b566c53033 Merge "Revert "Do not look for tzdata file in /data."" 2022-06-23 19:02:19 +00:00
Almaz Mingaleev
4e013233b8 Revert "Do not look for tzdata file in /data."
This reverts commit e9a20895ea.

Reason for revert: b/236967833. Breaks toybox tests

Change-Id: Ia9832ff62b6d700673f41f0c1c013090a21fe5ec
2022-06-23 16:41:24 +00:00
Treehugger Robot
7ed88b6276 Merge "Do not look for tzdata file in /data." 2022-06-23 12:13:19 +00:00
Elliott Hughes
170ae1f96d Merge "Document another obsolete POSIX function." 2022-06-15 14:40:41 +00:00
Almaz Mingaleev
e9a20895ea Do not look for tzdata file in /data.
That was place where APK update mechanism placed tzdata file. Now
the mechanism is removed, so no need to look for tzdata there.

Bug: 148144561

Test: atest CtsBionicTestCases
Test: atest BionicTzdbConsistencyTest
Change-Id: I584400a75651cf24a25df74c7007fcd584838395
2022-06-15 10:02:44 +01:00
Elliott Hughes
a39ac04033 Document another obsolete POSIX function.
ualarm(3) was removed from POSIX in 2008, but somehow wasn't included in
the list of such functions (perhaps because it's not inherently useless
like a lot of the other stuff is; it just has a better replacement).

Test: N/A
Change-Id: I0347d3e7f1357bc2acb870f74e9084872c28ca3e
2022-06-14 17:23:35 -07:00
Ryan Prichard
7a0fc4167b Merge "Avoid using new/delete in locale.cpp" am: d18e608279
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2120600

Change-Id: I8a82972552849befdab22104f18616a5065b97ec
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-14 22:30:32 +00:00
Ryan Prichard
d18e608279 Merge "Avoid using new/delete in locale.cpp" 2022-06-14 20:57:55 +00:00
Ryan Prichard
bcb9715b63 Avoid using new/delete in locale.cpp
This file is included in libandroid_support.a, where using new/delete
breaks libc++ tests that assume that libc++ makes no extraneous
new/delete calls.

This CL changes newlocale/duplocale to return NULL on out-of-memory.
Previously, the behavior varied:
 - libc.so: aborted using async_safe_fatal
 - libandroid_support.a: throws std::bad_alloc

Bug: none
Test: std/input.output/filesystems/class.path/path.member/path.assign/move.pass.cpp
Test: libcxx/localization/locales/locale/locale.types/locale.facet/no_allocation.pass.cpp
Test: std/input.output/filesystems/class.path/path.member/path.construct/move.pass.cpp
Change-Id: I38c772f249f32322afb9402ebeeb4bb65a908b59
2022-06-13 17:39:32 -07:00
Christopher Ferris
2a769de6da Merge "Update to v5.18 kernel headers." am: a8cb33ff07
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2120313

Change-Id: I1f302ab521965affe1314a0f84546063e31c7a63
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-09 17:22:53 +00:00
Christopher Ferris
a8cb33ff07 Merge "Update to v5.18 kernel headers." 2022-06-09 16:51:59 +00:00
Almaz Mingaleev
dc4c1f7dd9 Merge "Set TZDEFAULT to NULL." am: 9465700983
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2101267

Change-Id: I7a0ee6a032366d01f0f14d7adef40b6bd9a2ebbb
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-09 10:44:06 +00:00
Almaz Mingaleev
9465700983 Merge "Set TZDEFAULT to NULL." 2022-06-09 09:59:01 +00:00