History log of /bionic/libc/include/stdio.h
Revision Date Author Comments
2d80400a9e8454038a3ec29959436184be0c4c65 20-Aug-2014 Elliott Hughes <enh@google.com> Fix some 32-bit-isms in <stdio.h>.

Bug: 17157793
Change-Id: I8290e240b92e5617f4c12c0eacad6e622e677b6a
1242f7eb67c678922b55e2077d9cf2d5cdc85b15 30-Jul-2014 Elliott Hughes <enh@google.com> Remove declarations for things that don't exist.

The <grp.h> ones prevent gdb from building out of the box.

(cherry picked from commit f4c1a36a4500bc7f12e3065be3da4e8669ee011d)

Change-Id: I6958f2f1731de8c03df20b383decd414b78100aa
9635046e53e14ff44348853a9cacdffd444b35ae 18-Jun-2014 Dan Albert <danalbert@google.com> Hide declaration of gets(3) for C11 and later.

gets(3) was removed from C11.

This reverts commit 1291680c2a0c23b2163198d27e00261ca206298b.

Bug: 14500800
Change-Id: I5e5146bdbb80f2be818a17f287b112bab37d1f6d
1291680c2a0c23b2163198d27e00261ca206298b 18-Jun-2014 Dan Albert <danalbert@google.com> Revert "Hide declaration of gets(3) for C11 and later."

Breaks stlport. checkbuild lied to me?

This reverts commit c0ce5908277a9bf18628946629dba4277e9a2281.

Change-Id: I72fb21aba7eaea96a7c3208236fd03411527fa5e
c0ce5908277a9bf18628946629dba4277e9a2281 18-Jun-2014 Dan Albert <danalbert@google.com> Hide declaration of gets(3) for C11 and later.

gets(3) was removed from C11.

Change-Id: I4040a8a6c6d5d2a86878e8a80ca67964fbbb82a8
8e613cf342b369f7985135dbe11ebdbf8c736157 11-Jun-2014 Dan Albert <danalbert@google.com> Remove declaration for putw(3)/getw(3).

These were both removed from POSIX 2004, and we don't define an
implementation for getw(3). Keep the definition of put(3) on LP32 for
binary compatibility.

Bug: 13935372
Change-Id: Iba384b45093ac6d2d7c2d81f7980cd7701dd6f56
cd32219c5b3c402c99d3ad7d1997d42b5f04015e 11-Jun-2014 Dan Albert <danalbert@google.com> Remove declarations related to cuserid(3).

cuserid(3) was removed from POSIX 2004, and we don't have an
implementation anyway.

Bug: 13935372
Change-Id: I7ac7cde931ba802d0d5b917c22f5116618b21d2f
430cf1a6c32471ada4dad028acbfcc032da01fd3 03-Jun-2014 Elliott Hughes <enh@google.com> DO NOT MERGE fdprintf backward compatibility shim.

Fixes LP64 build.

Change-Id: Ic76005cd1f5a55344ea8ee3d070d25631d011037
4832a0961dc891ef69177c9cf0c3e3ba5dd7b69d 30-May-2014 Elliott Hughes <enh@google.com> DO NOT MERGE Fix lmp-preview-dev after bionic merge.

Other projects in lmp-preview-dev are out of date, and it's easier to patch
bionic than to fix all of them.

(cherry picked from commit a856c6f543c71f6778cdb9b39f6049ae8b2c4e53)

Change-Id: Id8fbdf35eb55150579f85b7bdddb5d68d3012218
a856c6f543c71f6778cdb9b39f6049ae8b2c4e53 30-May-2014 Elliott Hughes <enh@google.com> DO NOT MERGE Fix lmp-preview-dev after bionic merge.

Other projects in lmp-preview-dev are out of date, and it's easier to patch
bionic than to fix all of them.

Change-Id: Id55c3da7259ba0bb5e62462d5eca721d3716c07f
fcac8ff97f6b6cced6546e0096cadc1039b68b5e 22-May-2014 Elliott Hughes <enh@google.com> Switch to POSIX dprintf/vdprintf.

Bug: 11156955
Change-Id: I734bd02db514367ab119a48304aae9767958e367
7eb28b59c7665654255640e3fac4ccd5a9e1cbab 19-Mar-2014 Nick Kralevich <nnk@google.com> FORTIFY_SOURCE: don't define s?printf macros if already defined

Clang specific: Don't #define sprintf and snprintf macros if they
are already defined.

Change-Id: I30fc507d898377e1b8a57a65a147926229e0f9e2
f2cea021ab2c6d7d7feeb40cca098aa132605876 13-Mar-2014 Elliott Hughes <enh@google.com> Clean up <stdio.h> macros.

Also neuter __isthreaded.

We should come back to try to hide struct FILE's internals for LP64.

Bug: 3453512
Bug: 3453550
Change-Id: I7e115329fb4579246a72fea367b9fc8cb6055d18
cd0609f4fcec9bdcb99a2127137c5570b18c499c 19-Dec-2013 Elliott Hughes <enh@google.com> Allow GCC-built fortified code to run on a clang-built bionic.

Even though code built with clang won't be fully fortified
and won't contain calls to our various helpers, binaries built
with GCC will.

Change-Id: I389b2f1e22a3e89b22aadedc46397bf704f9ca79
c13fb75ceabb47f8292be206db80b93889fccf66 18-Dec-2013 Elliott Hughes <enh@google.com> Move bionic over to GCC's 'warning' attribute.

This is a better solution than the old __warn_references because it's
a compile-time rather than link-time warning, it doesn't rely on something
that doesn't appear to be supported by gold (which is why you only used
to see these warnings on mips builds), and the errors refer to the exact
call site(s) rather than just telling you which object file contains a
reference to the bad function.

This is primarily so we can build bionic for aarch64; building libc.so
caused these warnings to fire (because link time is the wrong time) and
warnings are errors.

Change-Id: I5df9281b2a9d98b164a9b11807ea9472c6faa9e3
f8fcfbc85a3ce3e195626b90736d3a484331494b 22-Oct-2013 Elliott Hughes <enh@google.com> Move away from the __ARCH_WANT_SYSCALL_NO_AT system calls.

Modern architectures only get the *at(2) system calls. For example,
aarch64 doesn't have open(2), and expects userspace to use openat(2)
instead.

Change-Id: I87b4ed79790cb8a80844f5544ac1a13fda26c7b5
6e38072addd556e3894284b5bd040ac64fffa72e 11-Oct-2013 Stephen Hines <srhines@google.com> Wrap sprintf()/snprintf() macros to prevent expansion errors.

Previously, FORTIFY_SOURCE used single macros to define these standard
functions for use with clang. This can cause conflicts with other macros used
to call these functions, particularly when those macros expand the number of
arguments to the function. This change wraps our macro definitions, so that
expansion properly takes place for programmer arguments first.

Change-Id: I55929b1fd2a643b9d14a17631c4bcab3b0b712cf
c8ae8bd9418b79f4da85dc12a61ebd82146b7e51 27-Jun-2013 Nick Kralevich <nnk@google.com> stdio.h: enable vs?printf clang FORTIFY_SOURCE

Enable FORTIFY_SOURCE protections under clang for the following
functions:

* vsprintf
* vsnprintf

and add unittests.

Change-Id: I90f8a27f7b202c78b5dd8ebf53050bf9e33496f7
621b19dddbfba1cd98c01cb95ce312baa20e0e7c 25-Jun-2013 Nick Kralevich <nnk@google.com> libc: enable FORTIFY_SOURCE snprintf under clang

Change-Id: I8b8059782a720104722b0841994b38f873ed02aa
c6eb9854542c115fd9aa87731adcb1b5da57e8ac 24-Jun-2013 Nick Kralevich <nnk@google.com> libc: enable sprintf FORTIFY_SOURCE under clang

clang doesn't support __builtin_va_arg_pack(), so we have
to use #define instead.

Change-Id: I2ee75e6267d60cdf997fee6b9b0547bf68f062a1
16d1af167f8e36a9aa4a07ae77034ad519b00463 17-Jun-2013 Nick Kralevich <nnk@google.com> libc: add limited FORTIFY_SOURCE support for clang

In 829c089f83ddee37203b52bcb294867a9ae7bdbc, we disabled all
FORTIFY_SOURCE support when compiling under clang. At the time,
we didn't have proper test cases, and couldn't easily create targeted
clang tests.

This change re-enables FORTIFY_SOURCE support under clang for a
limited set of functions, where we have explicit unittests available.
The functions are:

* memcpy
* memmove
* strcpy
* strncpy
* strcat
* strncat
* memset
* strlen (with modifications)
* strchr (with modifications)
* strrchr (with modifications)

It may be possible, in the future, to enable other functions. However,
I need to write unittests first.

For strlen, strchr, and strrchr, clang unconditionally calls the
fortified version of the relevant function. If it doesn't know the
size of the buffer it's dealing with, it passes in ((size_t) -1),
which is the largest possible size_t.

I added two new clang specific unittest files, primarily copied
from fortify?_test.cpp.

I've also rebuild the entire system with these changes, and didn't
observe any obvious problems.

Change-Id: If12a15089bb0ffe93824b485290d05b14355fcaa
b24c0637d06fe0980b9e13a8d0c3e6f4dbda9cd5 18-Jun-2013 Nick Kralevich <nnk@google.com> libc: Introduce __errordecl()

Define __errordecl and replace __attribute__((__error__("foo")))
with __errordecl. Make sure __errordecl is a no-op on clang, as it
generates a compile time warning.

Change-Id: Ifa1a2d3afd6881de9d479fc2adac6737871a2949
d04c18397946f87ac4495351537c31a3d67257da 15-May-2013 Elliott Hughes <enh@google.com> Add more __restricts, clean up __format__ attributes.

Change-Id: I7e2d270cc722d339d221eaea92747eaff3b51403
9020fd503c9eb073f70dbc239a212f8ece19359d 30-Apr-2013 Nick Kralevich <nnk@google.com> libc: upgrade some libc functions to _FORTIFY_SOURCE=2

Upgrade the following functions:

* vsnprintf
* vsprintf
* snprintf
* fgets
* strcpy
* strcat
* strncat
* strlcpy
* strlcat
* strlen
* strchr

Change-Id: Icc036fc7f0bb317e05f7c051617887a1601271aa
78d6d9888c24c50f65d694dc8283afdcb58db84c 30-Apr-2013 Nick Kralevich <nnk@google.com> libc: upgrade sprintf to _FORTIFY_SOURCE=2

Upgrade sprintf to fortify_source level 2, to catch
additional security bugs.

Change-Id: Ibc957d65e4cb96152de84b3745a04e00fa22659e
890c8ed6ef773160cd6840a92e0d469fe530871f 22-Mar-2013 Elliott Hughes <enh@google.com> Fix builds where _FORTIFY_SOURCE is off.

Also add a more intention-revealing guard so we don't have loads of
places checking whether our inlining macro is defined.

Change-Id: I168860cedcfc798b07a5145bc48a125700265e47
41b3179c9ef03ebb447cac7f5e8405dce399cb17 28-Jan-2013 Elliott Hughes <enh@google.com> Unit tests for formatting code, fix %%.

Also fix <signal.h> and <stdio.h> so they don't cause compiler warnings.

Change-Id: Ib1a746bf01de22d47dbd964de0e6af80a7c96303
3975cec694a0c9b42e3f7e671fcd678da92836c3 30-Nov-2012 Elliott Hughes <enh@google.com> Remove (near-)duplicate definitions of size_t and ssize_t.

The near duplicates upset fussier compilers that insist that
typedefs be exactly the same, but the fix isn't to make all
copies identical...

Change-Id: Icfdace41726f36ec33c9ae919dbb5a54d3529cc9
ce45fea03ddfd8d6d1900d6777a002dec98ea1e1 23-Oct-2012 Elliott Hughes <enh@google.com> Add missing BEGIN_DECLS/END_DECLS for FORTIFY_SOURCE stdio prototypes.

Change-Id: I35ceb09fedf873c5e98e1e26efce5e4f00a17e74
7d56ccbfaac2b702e4be0f71038efb7f251ef637 02-Oct-2012 Elliott Hughes <enh@google.com> Always take GCC's definition of NULL.

There's a (bad) definition of NULL in <linux/stddef.h>, and this
definition of NULL, and the One True definition in the <stddef.h> provided
by the compiler. This change at least kills one of the bad duplicates.
Killing the <linux/stddef.h> one is harder, because it's in a generated
file.

Change-Id: Iea4ccb12d6758199f312ea9cd753b84322d5c471
0cc0d250fd3097e4c26b70cdeb5c47caac634069 02-Oct-2012 Elliott Hughes <enh@google.com> Remove useless #defines and incorrect claims from header files.

The various __need_* macros were write-only.

Change-Id: Id3cca34188e0801fdf93a038b22f2817226ad9c2
422b6ef92c1cca3cfd412621dc3db3b8609fa88c 28-Sep-2012 Elliott Hughes <enh@google.com> Define ssize_t if necessary.

Change-Id: I63801cc1f09be5e4ca20a6da7ec3366ba6441afd
eac9eb462ed6f7fcfb791e7a08b4011fcca47829 08-Sep-2012 Irina Tirdea <irina.tirdea@intel.com> Add getdelim(3) and getline(3) to bionic

Some userspace programs (e.g. perf) need getline.

Changes:
() add getdelim.c, getline.c from NetBSD (http://netbsd.org/) under the
NetBSD Foundation's (TNF) license ("2 clause" Berkeley-style license).
() add stub for reentrant.h header that is needed by getdelim.c
() add tests for getdelim(3) and getline(3).
() update NOTICE file.

Change-Id: I22ed82dd5904b9d7a3695535c04f502be3c27c5d
Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
829c089f83ddee37203b52bcb294867a9ae7bdbc 29-Aug-2012 Nick Kralevich <nnk@google.com> disable _FORTIFY_SOURCE under clang

Clang and _FORTIFY_SOURCE are just plain incompatible with
each other. First of all, clang doesn't understand the
__attribute__((gnu_inline)) header. Second of all,
Clang doesn't have support for __builtin_va_arg_pack()
and __builtin_va_arg_pack_len() (see
http://clang.llvm.org/docs/UsersManual.html#c_unimpl_gcc)

Until we can resolve these issues, don't even try using
_FORTIFY_SOURCE under clang.

Change-Id: I81c2b8073bb3276fa9a4a6b93c427b641038356a
9b6cc223a36835c4367a036d4cfeff14d25bc742 13-Jul-2012 Nick Kralevich <nnk@google.com> FORTIFY_SOURCE: introduce __BIONIC_FORTIFY_UNKNOWN_SIZE macro

Replace all occurances of "(size_t) -1" with a
__BIONIC_FORTIFY_UNKNOWN_SIZE macro.

Change-Id: I0b188f6cf31417d2dbef0e1bd759de3f9782873a
965dbc6405aa2c3170270cfc53a8d4416444fddb 03-Jul-2012 Nick Kralevich <nnk@google.com> FORTIFY_SOURCE: add fgets support.

Change-Id: I8c3410a90c71a3336c4ac8581618fa9330edf5e3
9b549c39c938f54680f282c21e6885f53254bfb0 13-Jun-2012 Nick Kralevich <nnk@google.com> FORTIFY_SOURCE: add sprintf / vsprintf support

sprintf FORTIFY_SOURCE protections are not available
on clang.

Also add various __attribute__s to stdio functions.

Change-Id: I936d1f9e55fe53a68885c4524b7b59e68fed218d
cffdf6693ffb50d2a1258d955a162bca83038f25 12-Jun-2012 Nick Kralevich <nnk@google.com> FORTIFY_SOURCE: add snprintf, vsnprintf

Add _FORTIFY_SOURCE support for snprintf, vsnprintf

At this time, we opt out of these protections for clang, as clang
does not implement __builtin_va_arg_pack().

http://clang.llvm.org/docs/UsersManual.html#c_unimpl_gcc

Change-Id: I73ebe5ec8dad1dca8898a76d6afb693a25f75375
f39a3fe67d7f1faa21a39ea8e1f57a6596c8cadb 09-Feb-2012 Glenn Kasten <gkasten@google.com> Allow C++ to call fdprintf

Change-Id: I1adb7b165ab9f62eaee4e7a9108e8b461350b347
f582340a6a48588aa50da17e1620e8f91b146941 12-Feb-2011 Kenny Root <kroot@google.com> Fix the handle locking in stdio

Fix the handle locking in stdio to use flockfile/funlockfile
internally when and where required. Macros in <stdio.h> are updated
to automatically call the underlying functions when the process is
threaded to obtain the necessary locking. A private mutex is added
to protect __sglue, the internal list of FILE handles, and another
to protect the one-time initialization. Some routines in libc that
use getc() change to use getc_unlocked() as they're either protected
by their own lock or aren't thread-safe routines anyway.

Based on OpenBSD change by guenther@openbsd.org
http://www.mail-archive.com/source-changes@cvs.openbsd.org/msg01015.html

Bug: 3446659
Change-Id: Ie82116e358c541718d6709ec45ca6796be5a007b
bb5581ad6eec40041dab4e961149f7a8a3a83497 09-Oct-2010 David 'Digit' Turner <digit@google.com> libc: tag missing functions in system headers.

This matches recent changes in the NDK header.
We enclose missing functions in #if 0 .. #endif blocks
with a clear "MISSING" in comments in order to locate
them later.

Change-Id: I87b3a62e777897e75c9243360fb0a82bcc53d9fb
50ace4fec5e8cb5afcbc656a4556fa528adfd760 17-Jun-2010 David 'Digit' Turner <digit@google.com> Remove compiler warnings when building Bionic.

Also add missing declarations to misc. functions.
Fix clearerr() implementation (previous was broken).
Handle feature test macros like _POSIX_C_SOURCE properly.

Change-Id: Icdc973a6b9d550a166fc2545f727ea837fe800c4
fc10b24accd082fb33c8f92ff8b92481c22fe3dc 14-Jan-2010 Colin Cross <ccross@android.com> Add implementation of fdprintf, clearenv, and stubs for ttyname_r, *usershell

Change-Id: I5fe7e8b6ee5edbb49e707c3b6737a58563781fa3
c1202510b67f200b668d85ac0190db2b179b0c4d 25-Nov-2009 Andy McFadden <fadden@android.com> Added a comment.

The structs for stdin/stdout/stderr are formed with a static initializer
that needs to be updated if something in FILE is changed.
1dc9e472e19acfe6dc7f41e429236e7eef7ceda1 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
1767f908af327fa388b1c66883760ad851267013 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
e5cc1f386b167b9f7bfdebc7219e89aa9b71e4b2 16-Jan-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@126645
4e468ed2eb86a2406e14f1eca82072ee501d05fd 18-Dec-2008 The Android Open Source Project <initial-contribution@android.com> Code drop from //branches/cupcake/...@124589
a27d2baa0c1a2ec70f47ea9199b1dd6762c8a349 21-Oct-2008 The Android Open Source Project <initial-contribution@android.com> Initial Contribution