Merge "Add __fseterr."

This commit is contained in:
Treehugger Robot 2018-02-15 02:36:38 +00:00 committed by Gerrit Code Review
commit d5172fced0
10 changed files with 29 additions and 0 deletions

View file

@ -45,6 +45,8 @@ void __fpurge(FILE* __fp) __INTRODUCED_IN(23);
size_t __fpending(FILE* __fp) __INTRODUCED_IN(23);
void _flushlbf(void) __INTRODUCED_IN(23);
void __fseterr(FILE* __fp) __INTRODUCED_IN(28);
#define FSETLOCKING_QUERY 0
#define FSETLOCKING_INTERNAL 1
#define FSETLOCKING_BYCALLER 2

View file

@ -1322,6 +1322,7 @@ LIBC_P { # introduced=P
global:
__freading;
__free_hook;
__fseterr;
__fwriting;
__malloc_hook;
__memalign_hook;

View file

@ -1242,6 +1242,7 @@ LIBC_P { # introduced=P
global:
__freading;
__free_hook;
__fseterr;
__fwriting;
__malloc_hook;
__memalign_hook;

View file

@ -1347,6 +1347,7 @@ LIBC_P { # introduced=P
global:
__freading;
__free_hook;
__fseterr;
__fwriting;
__malloc_hook;
__memalign_hook;

View file

@ -1306,6 +1306,7 @@ LIBC_P { # introduced=P
global:
__freading;
__free_hook;
__fseterr;
__fwriting;
__malloc_hook;
__memalign_hook;

View file

@ -1242,6 +1242,7 @@ LIBC_P { # introduced=P
global:
__freading;
__free_hook;
__fseterr;
__fwriting;
__malloc_hook;
__memalign_hook;

View file

@ -1304,6 +1304,7 @@ LIBC_P { # introduced=P
global:
__freading;
__free_hook;
__fseterr;
__fwriting;
__malloc_hook;
__memalign_hook;

View file

@ -1242,6 +1242,7 @@ LIBC_P { # introduced=P
global:
__freading;
__free_hook;
__fseterr;
__fwriting;
__malloc_hook;
__memalign_hook;

View file

@ -72,6 +72,10 @@ void _flushlbf() {
fflush(NULL);
}
void __fseterr(FILE* fp) {
fp->_flags |= __SERR;
}
int __fsetlocking(FILE* fp, int type) {
int old_state = _EXT(fp)->_caller_handles_locking ? FSETLOCKING_BYCALLER : FSETLOCKING_INTERNAL;
if (type == FSETLOCKING_QUERY) {

View file

@ -190,6 +190,22 @@ TEST(stdio_ext, __freading__fwriting) {
}
}
TEST(stdio_ext, __fseterr) {
#if defined(__GLIBC__)
GTEST_LOG_(INFO) << "glibc doesn't have __fseterr, but gnulib will use it";
#else
FILE* fp = fopen("/dev/null", "w");
ASSERT_FALSE(ferror(fp));
__fseterr(fp);
ASSERT_TRUE(ferror(fp));
clearerr(fp);
ASSERT_FALSE(ferror(fp));
fclose(fp);
#endif
}
TEST(stdio_ext, __fsetlocking) {
FILE* fp = fopen("/proc/version", "r");
ASSERT_EQ(FSETLOCKING_INTERNAL, __fsetlocking(fp, FSETLOCKING_QUERY));