Age | Commit message (Collapse) | Author |
|
On LP32, just abort if we're asked to handle an fd that's too big for
the `short` field in `struct FILE`. This is unreachable anyway because
the ulimit is 32Ki, and this will make issues far more noticeable if we
ever do increase that limit (which seems unlikely for LP32 devices).
Also rename __finit() to __FILE_init() to match __FILE_close().
Test: treehugger
Change-Id: I5db4d6c4529a1f558aff135b4dea071d73666be5
|
|
This has been in the standard since C99, but we've never supported it
before. It's apparently used by SPIRV-Tools.
I tried implementing this the other way (with fcntl(2)) first, but
eventually realized that that's more complicated and gives worse
results. This implementation assumes that /proc is mounted, but so much
of libc relies on that at this point that I don't think there's any
realistic case where the fcntl(2) implementation would be preferable,
and there are many where it's not.
The fact that no-one's mentioned this until now suggests that it's not a
heavily used feature anyway.
I've also replaced AssertCloseOnExec() with a CloseOnExec()
boolean-valued function instead, because it's really annoying getting
assertion failures that don't point you at the test line in question,
and instead point to some common helper code.
Test: treehugger
Change-Id: Ia2e53bf2664a4f782581042054ecd492830e2aed
|
|
Noticed while updating fts.c.
Bug: http://b/177003648
Test: treehugger
Change-Id: Ic3625c1c3af47c4dafb8ad686bbbddbc82b69b70
|
|
Mostly from extra test cases, but also:
* Move the fgets size < 0 assertion into fgets.
* Use ELF aliases for strtoq/strtouq rather than duplicating code.
* Don't check uname() succeeded, since it can't fail.
Test: treehugger
Change-Id: I2e6b3b88b0a3eb16bd68be68b9bc9f40d8043291
|
|
Test: treehugger
Change-Id: Iec1af942b5dee37f08ad390afe9fbdb79c47c085
|
|
Test: treehugger
Change-Id: I7ff0496c5c2792a41781e74634247f55b0548213
|
|
Bug: http://b/144165498
Test: treehugger
Change-Id: Ifcf352525abc74850053a1a019f90c72e488b71c
|
|
Test: treehugger
Change-Id: Ie473914f4c8924c7240b3ac22093a9daf42fc948
|
|
Plain __ for generated syscalls didn't mean it was a hidden symbol, it
just meant "please don't use this". We added ___ to signify that a
hidden symbol should be generated, but then we added the map files
anyway so you now have to explicitly export symbols. Given that, this
convention serves no particular purpose so we may as well just use the
nicer names have everything look the same.
Test: treehugger
Change-Id: If424e17a49c36f4be545f5d283c4561a6ea9c7ea
|
|
The locking can fail in a couple of ways:
- A concurrent fread from an unbuffered or line-buffered file flushes
the output of other line-buffered files, and if _fwalk locks every
file, then the fread blocks until other file reads have completed.
- __sfp can initialize a file lock while _fwalk is locking/unlocking it.
For now, revert to the behavior Bionic had in previous releases. This
commit reverts the file locking parts of commit
468efc80da2504f4ae7de8b5e137426d44dda9d7.
Bug: http://b/131251441
Bug: http://b/130189834
Test: bionic unit tests
Change-Id: I9e20b9cd8ccd14e7962f7308e174f08af72b56c6
|
|
|
|
Test: None
Bug: None
Change-Id: I061fe1d3cac6307d878155f1fabdba70da8e9fd5
|
|
|
|
We regressed on this recently: code under the upstream-* directories has
_PATH_BSHELL defined as a call to __bionic_get_shell_path(). In our own
code, we may as well just call it directly.
Bug: https://issuetracker.google.com/129030706
Test: ran tests
Change-Id: Ic2423f521272be95e67f94771772fe8072636ef0
|
|
We don't need this now that popen always uses O_CLOEXEC, and it's unsafe
because _fwalk takes a lock. (In <= P, the equivalent code walked the
list without a lock in the child.)
Bug: http://b/129156634
Test: ran tests
Change-Id: Ic9cee7eb59cfc9397f370d1dc47ea3d3326179ca
|
|
Bug: http://b/120752721
Test: ran tests
Change-Id: I3f03ae204ab5de40fd4402a5562c50ffe51ef998
|
|
I failed to convince the compiler/linker to just refrain (via factoring out,
attribute `noinline`, or meddling with `--icf=none`), but luckily I noticed
that we should have CHECK_FP in each function for a better error message,
and the distinct error messages keep the two functions apart.
(Also add a missing CHECK_FP to `clearerr_unlocked`.)
Bug: http://b/116969207
Test: manual with a modified `crasher`
Change-Id: Ic122e90e94f7e22f486be57d3dac7137a225d682
|
|
There's TLS space used for unknown errno values, and a call to printf
shouldn't clobber that. No-one will ever hit this in real life, but
since it's easily fixed...
Bug: http://b/112776560
Test: ran tests
Change-Id: I8c2437f2e5214e652119791d4e162a197b049d5b
|
|
And remove the local hack from syslog(3).
Bug: http://b/112776560
Test: ran tests
Change-Id: I5807e729a978df26187ea0ee255bba4ca74220c8
|
|
libc had some -Wimplicit-fallthrough warnings. They all seem to be
benign. We're trying to enable this flag globally, so we need to
annotate these breaks here.
Bug: 112564944
Test: Builds
Change-Id: I5afae694cc4cf26ad1a61e2c8ae91f00cda7c733
|
|
|
|
POSIX says "The popen() function shall ensure that any streams from
previous popen() calls that remain open in the parent process are closed
in the new child process". It doesn't appear to disallow all popen(3) file
descriptors from being O_CLOEXEC, and it's not obvious why anyone would want
them inherited. Let's see if we can make the stricter guarantee...
Bug: N/A
Test: ran tests
Change-Id: I2c85170d730b211637afb8ba10df150ca3237262
|
|
Fixes -Wzero-as-null-pointer-constant warning.
Test: m
Bug: 68236239
Change-Id: I5b4123bc6709641315120a191e36cc57541349b2
|
|
Add two functions to allow objects that own a file descriptor to
enforce that only they can close their file descriptor.
Use them in FILE* and DIR*.
Bug: http://b/110100358
Test: bionic_unit_tests
Test: aosp/master boots without errors
Test: treehugger
Change-Id: Iecd6e8b26c62217271e0822dc3d2d7888b091a45
|
|
pclose(3) is now an alias for fclose(3). We could add a FORTIFY check
that you use pclose(3) if and only if you used popen(3), but there seems
little value to that when we can just do the right thing.
This patch also adds the missing locking to _fwalk --- we need to lock
both the global list of FILE*s and also each FILE* we touch. POSIX says
that "The popen() function shall ensure that any streams from previous
popen() calls that remain open in the parent process are closed in the
new child process", which we implement via _fwalk(fclose) in the child,
but we might want to just make *all* popen(3) file descriptors O_CLOEXEC
in all cases.
Ignore fewer errors in popen(3) failure cases.
Improve popen(3) test coverage.
Bug: http://b/72470344
Test: ran tests
Change-Id: Ic937594bf28ec88b375f7e5825b9c05f500af438
|
|
We've ignored %n for a long time, but that's dangerous too because it
makes it unclear whether the corresponding pointer argument should be
supplied or not.
Remove the ambiguity by just rejecting %n outright.
Bug: http://b/31832608
Test: ran tests
Change-Id: Ic046ad3436a30c6f8f580ea738bdcaeb01c858f8
|
|
Bug: N/A
Test: builds
Change-Id: I3b1b238eefc67e6d627dbd6820849522fd7d961b
|
|
Bug: N/A
Test: ran tests
Change-Id: I683a1c45db0b880c73f8d190a46deeeab4cfef6e
|
|
Trivial, obvious counterpart to the standard ferror(3) and clearerr(3),
and lets us build bison out of the box.
Bug: http://b/64273806
Test: ran tests
Change-Id: I20affabddb71210051165c41e86adfe5ae04f77f
|
|
We've been using #pragma once for new internal files, but let's be more bold.
Bug: N/A
Test: builds
Change-Id: I7e2ee2730043bd884f9571cdbd8b524043030c07
|
|
Now that we have a clang that supports transparent overloads, we can
kill all of this cruft, and restore our upstream sources to their
untouched glory. Woohoo!
Bug: 12231437
Test: Built aosp_marlin; no obvious patch-related aosp_mips issues.
Change-Id: I520a19d014f12137f80e43f973dccd6711c571cd
|
|
API levels are generally more useful anyway.
Bug: N/A
Test: N/A
Change-Id: Ie7bd69c3d0223c9bc8ed52c871b1d2d34373e2d0
|
|
Makes no difference to the benchmarks, but does make the code a bit
more readable.
Bug: http://b/68672236
Test: ran tests, benchmarks
Change-Id: I63fa5f78d077c86e4f4f194f2c76ab5510c29109
|
|
Also support the "long" (wchar_t) variants.
Bug: http://b/68672236
Test: ran tests
Change-Id: I060e98b4d2feb61e12986d9d51e4710b2b1d9724
|
|
|
|
The internal uses don't need to actually initialize a mutex since they'll
never escape and don't need locking. It's a small saving, but easy.
Before:
BM_stdio_scanf_d 465 ns 465 ns 1507891
BM_stdio_scanf_maps 1836 ns 1836 ns 381082
BM_stdio_scanf_maps_baseline 846 ns 845 ns 830881
BM_stdio_scanf_s 419 ns 419 ns 1671979
After:
BM_stdio_scanf_d 434 ns 434 ns 1612930
BM_stdio_scanf_maps 1815 ns 1815 ns 386470
BM_stdio_scanf_maps_baseline 875 ns 873 ns 803304
BM_stdio_scanf_s 382 ns 382 ns 1833198
Bug: http://b/70862888
Test: ran tests, benchmarks
Change-Id: Ic8822aaca5d8ca1a73390089153d0fe35d91673e
|
|
This also let us remove the `unsigned char` casts, since we define our
inlines to work for all values.
Before:
Benchmark Time CPU Iterations
-------------------------------------------------------------
BM_inttypes_strtoimax 112 ns 112 ns 6222193
BM_inttypes_strtoumax 104 ns 104 ns 6725010
BM_stdlib_strtol 113 ns 113 ns 6195861
BM_stdlib_strtoll 113 ns 113 ns 6195633
BM_stdlib_strtoul 105 ns 105 ns 6691394
BM_stdlib_strtoull 105 ns 105 ns 6690695
BM_stdio_scanf_d 504 ns 503 ns 1385224
BM_stdio_scanf_maps 1900 ns 1898 ns 369260
BM_stdio_scanf_maps_baseline 1030 ns 1030 ns 678832
BM_stdio_scanf_s 433 ns 432 ns 1619086
After:
BM_inttypes_strtoimax 91 ns 91 ns 7718194
BM_inttypes_strtoumax 82 ns 82 ns 8508052
BM_stdlib_strtol 92 ns 92 ns 7674694
BM_stdlib_strtoll 91 ns 91 ns 7639228
BM_stdlib_strtoul 83 ns 82 ns 8500304
BM_stdlib_strtoull 82 ns 82 ns 8504929
BM_stdio_scanf_d 465 ns 465 ns 1507891
BM_stdio_scanf_maps 1836 ns 1836 ns 381082
BM_stdio_scanf_maps_baseline 846 ns 845 ns 830881
BM_stdio_scanf_s 419 ns 419 ns 1671979
Bug: N/A
Test: ran tests, benchmarks
Change-Id: I44681daf16c4328b060770cf11fc0633157c427f
|
|
Merge CT_CCL and CT_STRING handling before we add %m.
Also fix an accidental scanf/wscanf difference.
Add currently-disabled tests for questionable behavior noticed during
code review that isn't a regression, but should be fixed later.
Bug: http://b/68672236
Bug: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=202240
Test: ran tests
Change-Id: I3eec9b7dfce84f63c68426406224822c52551d64
|
|
Strictly, POSIX says "If a '-' is in the scanlist and is not the first
wide character, nor the second where the first wide character is a '^',
nor the last wide character, the behavior is implementation-defined",
but it seems unreasonable for swscanf to interpret `a-c` differently
from sscanf. Make ours behave the same as each other by making swscanf
work the same as sscanf.
Bug: http://b/68672236
Test: ran tests
Change-Id: Ia84805897628d7128e901b468e02504373730e61
|
|
Bug: http://b/67371539
Test: ran tests
Change-Id: I899458af92517dc21f874519716fa3f3a0f0e3d6
|
|
|
|
Bug: N/A
Test: ran tests
Change-Id: Ifb8bd91132865f8c6d0b95baf1021af3b3b3c353
|
|
Bug: http://b/67371539
Test: ran tests
Change-Id: Iae38055426596919c0de4f5080c99eba95fac3a9
|
|
Bug: http://b/67371539
Test: ran tests
Change-Id: I24eae6a5d2c64ff4fd65c8d508a3709bab5a11c4
|
|
Just trivial use of macros.
The %s/%ls case in __find_arguments was backwards in the wide copy of
the code, but not problematically so because all pointers are the same
size anyway.
Bug: http://b/67371539
Test: ran tests
Change-Id: I8d34915d75ae5425c56c59510a16c328fc481d20
|
|
Bug: http://b/68837650
Test: /data/nativetest/bionic-unit-tests/bionic-unit-tests
Test: /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static
Test: /data/nativetest64/bionic-unit-tests/bionic-unit-tests
Change-Id: I367e0238c31d35f76d8ad89fd0aa27ecfeb7c149
|
|
Android is UTF-8. Don't make everyone pay to convert UTF-8 to ASCII just
so we can recognize '%'. With UTF-8 we can just strchr forwards.
Before:
---------------------------------------------------------------
Benchmark Time CPU Iterations
---------------------------------------------------------------
BM_stdio_printf_literal 1290 ns 1290 ns 442554
BM_stdio_printf_s 1204 ns 1204 ns 582446
BM_stdio_printf_d 1206 ns 1206 ns 578311
BM_stdio_printf_1$s 2263 ns 2263 ns 310002
After:
---------------------------------------------------------------
Benchmark Time CPU Iterations
---------------------------------------------------------------
BM_stdio_printf_literal 178 ns 178 ns 3394001
BM_stdio_printf_s 246 ns 246 ns 2850284
BM_stdio_printf_d 252 ns 252 ns 2778610
BM_stdio_printf_1$s 363 ns 363 ns 1929011
Add missing __find_arguments error checking to the wide variant to match
the regular one.
Also replace various char/wchar_t differences with the macro.
Bug: http://b/67371539
Test: ran tests
Change-Id: I18f122009c22699943ab5d666a98ea594a972c40
|
|
Fix the 'j' (intmax_t/uintmax_t) length qualifier in the wide
variant. (With new tests that fail without this fix.)
Fix a typo in the wide support for intmax_t*, which isn't testable because
%n is disabled on Android (and will be removed in a later cleanup pass).
Also move the public vfprintf/vfwprint functions into stdio.cpp.
Bug: http://b/67371539
Test: ran tests
Change-Id: Ib003599b1e9cb789044a068940b59e447f2cb7cb
|
|
This patch switches to C++ (in anticipation of needing it later), removes
a little duplication (via a macro for now), and ensures uniform support
for %C/%lc and %S/%ls between regular and wide (with new tests).
Since it's so hard to debug problems in printf (as the time I've wasted
already today will testify), that's all I want to do in this change. The
other 500 lines of diff can wait...
(Also merge "floatio.h" into "local.h" now all the users are in forked
code.)
Bug: http://b/67371539
Test: ran tests
Change-Id: I083353d89c32b9302d759ca6967cc6d8a62cd8a5
|
|
|