aboutsummaryrefslogtreecommitdiffstats
path: root/libc/stdio
Commit message (Collapse)AuthorAgeFilesLines
* Don't use TEMP_FAILURE_RETRY on close in bionic.Elliott Hughes2015-05-151-1/+1
| | | | | | Bug: http://b/20501816 Change-Id: Id64b5109cc2b165fa0351b6edbb865a5e5058008 (cherry picked from commit 4e8ef698d0d76be3f8d75de32701e6e6327c1fbd)
* Hide internal of pthread_mutex_t.Yabin Cui2015-03-251-1/+5
| | | | | Bug: 19249079 Change-Id: Iffb79c8d861b698d474f212dc80c638fc2cf1620
* Fix fread returning bad data.Christopher Ferris2015-02-271-0/+6
| | | | | Bug: 19172514 Change-Id: I05016577858a02aca7d14e75e6ec28abc925037c
* Fix optimized fread.Elliott Hughes2015-01-241-1/+1
| | | | | | | | gcov does writes after reads on the same stream, but the bulk read optimization was clobbering the FILE _flags, causing fwrite to fail. Bug: 19129055 Change-Id: I9650cb7de4bb173a706b502406266ed0d2b654d7
* Turn on -Wold-style-cast and fix the errors.Elliott Hughes2015-01-212-0/+7
| | | | | | A couple of dodgy cases where we cast away const, but otherwise pretty boring. Change-Id: Ibc39ebd525377792b5911464be842121c20f03b9
* Implement __fsetlocking.Elliott Hughes2015-01-213-15/+23
| | | | | | | | | | | | The old __isthreaded hack was never very useful on Android because all user code runs in a VM where there are lots of threads running. But __fsetlocking lets a caller say "I'll worry about the locking for this FILE*", which is useful for the normal case where you don't share a FILE* between threads so you don't need any locking. Bug: 17154740 Bug: 18593728 Change-Id: I2a8dddc29d3edff39a3d7d793387f2253608a68d
* Fix signed/unsigned comparison that was upsetting clang.Elliott Hughes2015-01-201-1/+1
| | | | | | bionic/libc/stdio/fread.c:86:27: error: comparison of integers of different signs: 'int' and 'size_t' (aka 'unsigned int') [-Werror,-Wsign-compare] Change-Id: Ia7e1e053e0cb13113e8f2eede820be013acbab82
* Add TEMP_FAILURE_RETRY to stdio's low-level read/write functions.Elliott Hughes2015-01-201-0/+90
| | | | | | | | This is correctness rather than performance, but found while investigating performance. Bug: 18593728 Change-Id: Idbdfed89d1931fcfae65db29d662108d4bbd9b65
* Optimized fread.Elliott Hughes2015-01-201-35/+64
| | | | | | | | | This makes us competitive with glibc for fully-buffered and unbuffered reads, except in single-threaded situations where glibc avoids locking, but since we're never really single-threaded anyway, that isn't a priority. Bug: 18593728 Change-Id: Ib776bfba422ccf46209581fc0dc54f3567645b8f
* Avoid pathological behavior in OpenBSD's fread.Elliott Hughes2014-12-021-0/+104
| | | | | | Bug: https://code.google.com/p/android/issues/detail?id=81155 Bug: 18556607 Change-Id: Idc60976b79610e2202cc42dc393dcb4ca6c42e05
* Fix flockfile(3) and friends for stdin/stdout/stderr too.Elliott Hughes2014-11-194-0/+20
| | | | | | | | | | | | stdin/stdout/stderr are special; their mutexes are initialized by __sinit. There's no unit test for this, because __sinit has already been called by the time the first unit test runs, but you could reproduce this failure with a trivial main() that calls flockfile or ftrylockfile on one of the standard streams before otherwise using stdio. Bug: 18208568 Change-Id: I28d232cf05a9f198a2bed61854d8047b23d2091d
* Add non-macro stdin/stdout/stderr too.Elliott Hughes2014-11-142-5/+4
| | | | | | | | | | | | Various C and C++ standards explicitly say that stdin/stdout/stderr should be macros, but glibc makes them global variables too. This means it's possible to write code that uses those names as locals, but that code (toybox being an example) won't build on bionic. If we'd done this earlier, we could have hidden __sF for LP64, but it's too late now. Change-Id: I90cf8c73f52b66e1760b8fa2e135b9f9f9651230
* Fix warning of missing field initializer.Chih-Hung Hsieh2014-11-041-2/+2
| | | | | BUG: 18241135 Change-Id: I91304eb608bc3336ce5fcd5744fbe080d64f1cc2
* Ensure we initialize stdin/stdout/stderr's recursive mutexes.Elliott Hughes2014-11-031-0/+188
| | | | | Bug: 18208568 Change-Id: I9da16ce0f9375bc363d1d02be706d73fd3b1e150
* Add back symbols to fix Greed for Glory franchise.Christopher Ferris2014-10-091-6/+8
| | | | | | | | Bug: 17813018 (cherry picked from commit c891e24073830e07ba7373dee554ff2c70e1d313) Change-Id: I4e891c2dbad9ea00d2377c5175317d9ae3840153
* Re-expose more stdio implementation details for LP32.Elliott Hughes2014-09-242-12/+9
| | | | | | | | | Keeps a variety of apps running. (cherry-pick of 5def2f5aecd968e4022b0afbe4441fa7ba3e7c7e.) Bug: 17047819 Change-Id: I55882ec95f2b59a5df76e5a89c23aa315609e01d
* Sync with upstream findfp.c.Elliott Hughes2014-09-241-0/+2
| | | | Change-Id: Ib298f46de0c4d0fd4ce0a9b456c163e8b8b06342
* Expose __swsetup for LP32 binary compatibility.Elliott Hughes2014-09-111-10/+6
| | | | | | | (cherry-pick of 7e00b44e80d6e38b8ab86d0ebc86b666c0ac2ef6.) Bug: 17476127 Change-Id: I0ef1355ac913d782c268a638f88642d6cfc236c2
* Add <stdio_ext.h> for elfutils.Elliott Hughes2014-08-201-0/+96
| | | | | Bug: 17139679 Change-Id: I1605ac382dbb6f23b2d874dbb9769f3cde4a6a99
* Fix visibility for a bunch more symbols.Elliott Hughes2014-07-141-8/+1
| | | | | | Bug: 11156955 Bug: 15291317 Change-Id: I664f25cce7c17085a101d6593d8e01525a1f6a90
* Expose __srefill for LP64 until we can fix the NDK.Elliott Hughes2014-05-271-1/+3
| | | | | | | | | The LP64 has a duplicate copy of part of stdio, and relies on bionic supplying this part. We should remove the hack from the NDK, at least for LP64, and then revert this. Bug: 15291317 Change-Id: I75e06e130188ca0aeb9d50dfe3a3e48a1d3968b7
* Restore __srefill for LP32.Elliott Hughes2014-05-271-3/+10
| | | | | | | | The NDK apparently includes an android_support.a library that refers to __srefill in its copy of the vsnprintf implementation. Bug: 15249361 Change-Id: Ic2cf6f21290b3146c42fbe0624f5e4d54f6194b4
* Restore __srget and __swbuf for LP32.Elliott Hughes2014-05-251-2/+12
| | | | | | | | | Anthony King <anthonydking@slimroms.net> reports that for Grouper the Nvidia GL blobs need access to __swbuf. This is because the old <stdio.h> had inline getc and putc implementations that directly referred to these symbols. Change-Id: I11a7b5550018ecc93d8f195c99857759669b2906
* Hide various stdio implementation details.Elliott Hughes2014-05-222-0/+13
| | | | | | | | | I've left __sF exposed since that's how the OpenBSD stdin, stdout, stderr are implemented. Other BSDs and glibc use a separate global for each instead of an array. Bug: 11156955 Change-Id: I9f3d2d4314a8d4a78c3197b9acd9258820c5f150
* Fix the newly-introduced warning and turn on -Werror.Elliott Hughes2014-05-161-4/+1
| | | | | | | | | I cleaned up most of our warnings last week but forgot to turn on -Werror, so of course we're getting new warnings already. I've left -Werror commented out in those places where we still have warnings to deal with before we can turn on -Werror. Change-Id: Ia58ff8b8c1ada4bf81eec6f19ec1d34e133cf4b1
* Register _cleanup function with atexitDmitriy Ivanov2014-05-151-206/+0
| | | | | | | | | | | | | | | | * Register cleanup function with atexit instead of calling it explicitly on exit() * abort() no longer calls _cleanup: Flushing stdio buffers on abort is no longer required by POSIX. * dlmalloc no longer need to reset cleanup (see above) * Upstream findfp.c makebuf.c setvbuf.cexit.c to openbsd versions. Bug: 14415367 Change-Id: I277058852485a9d3dbb13e5c232db5f9948d78ac
* Merge "Add include guard to fileext.h"Calin Juravle2014-05-061-0/+5
|\
| * Add include guard to fileext.hCalin Juravle2014-05-021-0/+5
| | | | | | | | Change-Id: I89b0e3bf0b15989727b5903b40bec92d49e122d9
* | Merge "Disable %n in printf and vfwprintf."Elliott Hughes2014-05-051-0/+1
|\ \
| * | Disable %n in printf and vfwprintf.Elliott Hughes2014-05-051-0/+1
| |/ | | | | | | | | Bug: 14492135 Change-Id: If190bede29e5f68a65043ddbe8e878c660933d03
* / Switch to current upstream OpenBSD fwrite.c.Elliott Hughes2014-05-021-48/+0
|/ | | | Change-Id: Ife527aafc1e5438f477d711902efe6e6f59f3f8e
* Switch to the OpenBSD implementations of the wide scanf functions.Elliott Hughes2014-04-294-38/+62
| | | | | | | | | This also gets us the C99 wcstoimax and wcstoumax, and a working fgetwc and ungetwc, all of which are needed in the implementation. This also brings several other files closer to upstream. Change-Id: I23b025a8237a6dbb9aa50d2a96765ea729a85579
* Switch to upstream OpenBSD fread/fvwrite.Elliott Hughes2014-04-182-383/+0
| | | | Change-Id: I3dc11083693bc8d99edc0cbcc6f70dc9e5dc6565
* Upgrade to current vfprintf.Elliott Hughes2014-04-173-1370/+2
| | | | | | | This gets us various bug fixes and missing C99 functionality. Bug: https://code.google.com/p/android/issues/detail?id=64886 Change-Id: Ie9f8ac569e9b5eec1e4a1faacfe2c21662eaf895
* Switch to gdtoa.Elliott Hughes2014-04-161-3/+3
| | | | | | | | This gives us a real strtold for LP64 and fixes various LP64 bugs. Bug: 13563801 Change-Id: I277858d718ee746e136b6b6308a495ba50dfa488
* Reimplement isinf/isnan/fpclassify.Elliott Hughes2014-04-141-33/+2
| | | | | | | | | | | | | | | | Also move isinf and isnan into libc like everyone else. Also move fpclassify to libc like the BSDs (but unlike glibc). We need this to be able to upgrade our float/double/long double parsing to gdtoa. Also add some missing aliases. We now have all of: isnan, __isnan, isnanf, __isnanf, isnanl, __isnanl, isinf, __isinf, isinff, __isinff, isinfl, __isinfl, __fpclassify, __fpclassifyd, __fpclassifyf, __fpclassifyl. Bug: 13469877 Change-Id: I407ffbac06c765a6c5fffda8106c37d7db04f27d
* Replace the bionic hack for a vfprintf leak with (roughly) the upstream fix.Elliott Hughes2014-04-111-14/+8
| | | | | | | | Currently in bionic free and freedtoa are equivalent, but that's not true of gdtoa. This makes it easier to test gdtoa without having to replace everything. (Yes, I found this bug the hard way.) Change-Id: I290823a2a0a83329def5f2719b349215ad0dbbde
* Fix the printf issue for 64 bits. The following case:Alexander Ivchenko2014-04-021-67/+103
| | | | | | | | | | | | | | | | | | | | | | | | | | printf("%1$s %1$s\n", "test"); would print garbage instead of the second "test". The problem is __find_arguments and the patch is a backport of two patches from OpenBSD that fix the issue: Author: tedu <tedu@cvs.openbsd.org> Date: Sat Apr 29 23:00:24 2006 +0000 check mmap for failure. the helper functions using it return -1, but callers do not yet check since printf() for example is not documented to return an error. some formatting cleanups. mostly ok deraadt millert Author: millert <millert@cvs.openbsd.org> Date: Fri May 16 14:28:54 2008 +0000 C99 says that for each va_copy() there must be a matching va_end(). Replace the non-portable hackery in __find_arguments() with a union. From FreeBSD. Change-Id: I6ea392ce6fcf4a319ae6a67ec58cc52fe7cbe534 Signed-off-by: Alexander Ivchenko <alexander.ivchenko@intel.com>
* Remove ALIGNBYTES and ALIGN from <sys/param.h>Calin Juravle2014-03-211-0/+3
| | | | | | | | | | There are only three users of bionic definition of ALIGN and keeping it in sys/param.h polutes the namespace. I inline the definition in the the three places that's used. Bug: 13400663 Change-Id: I565008e8426c38ffb07422f42cd8e547d53044e9
* Clean up <stdio.h> macros.Elliott Hughes2014-03-131-2/+20
| | | | | | | | | | Also neuter __isthreaded. We should come back to try to hide struct FILE's internals for LP64. Bug: 3453512 Bug: 3453550 Change-Id: I7e115329fb4579246a72fea367b9fc8cb6055d18
* Upgrade to current upstream scanf implementation.Elliott Hughes2014-03-123-926/+0
| | | | | | Also add a basic test. Change-Id: Icc0e68a5716b9579244f6eb8bac1ab5a24eda85a
* More stdio cleanup.Elliott Hughes2014-03-113-268/+0
| | | | Change-Id: Idc909cd3dc7b072f1edd2ae4980932d6550e8568
* More OpenBSD cleanup (primarily string).Elliott Hughes2014-02-241-10/+1
| | | | | | This patch removes the string/ and wchar/ directories. Change-Id: Ia489904bc67047e4bc79acb1f3eec21aa3fe5f0d
* Clean up our OpenBSD usage.Elliott Hughes2014-02-2119-1486/+0
| | | | | | | | | Also undo some of the mess where we have OpenBSD <stdio.h> but a mix of different BSD's implementations. In this first pass, I've only moved easy OpenBSD stuff. Change-Id: Iae67b02cde6dba9d8d06fedeb53efbfdac0a8cf6
* Fix x86_64 build, clean up intermediate libraries.Elliott Hughes2013-10-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | The x86_64 build was failing because clone.S had a call to __thread_entry which was being added to a different intermediate .a on the way to making libc.so, and the linker couldn't guarantee statically that such a relocation would be possible. ld: error: out/target/product/generic_x86_64/obj/STATIC_LIBRARIES/libc_common_intermediates/libc_common.a(clone.o): requires dynamic R_X86_64_PC32 reloc against '__thread_entry' which may overflow at runtime; recompile with -fPIC This patch addresses that by ensuring that the caller and callee end up in the same intermediate .a. While I'm here, I've tried to clean up some of the mess that led to this situation too. In particular, this removes libc/private/ from the default include path (except for the DNS code), and splits out the DNS code into its own library (since it's a weird special case of upstream NetBSD code that's diverged so heavily it's unlikely ever to get back in sync). There's more cleanup of the DNS situation possible, but this is definitely a step in the right direction, and it's more than enough to get x86_64 building cleanly. Change-Id: I00425a7245b7a2573df16cc38798187d0729e7c4
* Remove _FORTIFY_SOURCE in implementation files.Stephen Hines2013-10-012-0/+2
| | | | | | | This was causing conflicting declarations for the library definitions of common functions like sprintf(), snprintf(), and strchr(). Change-Id: I5daaa8a58183aa0d4d0fae8a7cb799671810f576
* Fix %hhd formats in the printf family.Elliott Hughes2013-09-232-1/+8
| | | | | | | | Found by adapting the simple unit tests for libc logging to test snprintf too. Fix taken from upstream OpenBSD without updating the rest of stdio. Change-Id: Ie339a8e9393a36080147aae4d6665118e5d93647
* Upgrade mktemp.c to the current upstream version.Elliott Hughes2013-07-191-184/+0
| | | | | | | | Yet another archaic relic containing bugs that had been fixed years before the Android project even started... Bug: 9935113 Change-Id: I3c9d019a216efd609ee568cf8c70bc360f357403
* Switch to current upstream stdio makebuf.c and setvbuf.c.Elliott Hughes2013-06-122-258/+0
| | | | Change-Id: I4761b5e94459815520f01062eef39abf62af621f
* Clean up abort.Elliott Hughes2013-06-124-10/+9
| | | | | | | | | | | | | | | | | | * A dlmalloc usage error shouldn't call abort(3) because we want to cause a SIGSEGV by writing the address dlmalloc didn't like to an address the kernel won't like, so that debuggerd will dump the memory around the address that upset dlmalloc. * Switch to the simpler FreeBSD/NetBSD style of registering stdio cleanup. Hopefully this will let us simplify more of the stdio implementation. * Clear the stdio cleanup handler before we abort because of a dlmalloc corruption error. This fixes the reported bug, where we'd hang inside dlmalloc because the stdio cleanup reentered dlmalloc. Bug: 9301265 Change-Id: Ief31b389455d6876e5a68f0f5429567d37277dbc