diff options
author | Elliott Hughes <enh@google.com> | 2014-03-13 14:54:53 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2014-03-13 14:54:53 -0700 |
commit | f2cea021ab2c6d7d7feeb40cca098aa132605876 (patch) | |
tree | 119daf06820264a62bf3290bbbf8839dcb0196e3 /libc/stdio | |
parent | 6ece7fc33a389ef9bcbe78a83a6633e4cb4e4743 (diff) | |
download | bionic-f2cea021ab2c6d7d7feeb40cca098aa132605876.zip bionic-f2cea021ab2c6d7d7feeb40cca098aa132605876.tar.gz bionic-f2cea021ab2c6d7d7feeb40cca098aa132605876.tar.bz2 |
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
Diffstat (limited to 'libc/stdio')
-rw-r--r-- | libc/stdio/local.h | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/libc/stdio/local.h b/libc/stdio/local.h index a175d6f..facaa66 100644 --- a/libc/stdio/local.h +++ b/libc/stdio/local.h @@ -91,7 +91,25 @@ extern int __sdidinit; (fp)->_lb._base = NULL; \ } -#define FLOCKFILE(fp) do { if (__isthreaded) flockfile(fp); } while (0) -#define FUNLOCKFILE(fp) do { if (__isthreaded) funlockfile(fp); } while (0) +#define FLOCKFILE(fp) flockfile(fp) +#define FUNLOCKFILE(fp) funlockfile(fp) #define FLOATING_POINT + +/* OpenBSD exposes these in <stdio.h>, but we only want them exposed to the implementation. */ +__BEGIN_DECLS +int __srget(FILE*); +int __swbuf(int, FILE*); +__END_DECLS +#define __sfeof(p) (((p)->_flags & __SEOF) != 0) +#define __sferror(p) (((p)->_flags & __SERR) != 0) +#define __sclearerr(p) ((void)((p)->_flags &= ~(__SERR|__SEOF))) +#define __sfileno(p) ((p)->_file) +#define __sgetc(p) (--(p)->_r < 0 ? __srget(p) : (int)(*(p)->_p++)) +static __inline int __sputc(int _c, FILE* _p) { + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) { + return (*_p->_p++ = _c); + } else { + return (__swbuf(_c, _p)); + } +} |