Implement __fsetlocking.
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
This commit is contained in:
@@ -133,7 +133,10 @@ TEST(stdio_ext, __freadable__fwritable) {
|
||||
|
||||
TEST(stdio_ext, __fsetlocking) {
|
||||
FILE* fp = fopen("/proc/version", "r");
|
||||
// Android doesn't actually support the other modes.
|
||||
ASSERT_EQ(FSETLOCKING_INTERNAL, __fsetlocking(fp, FSETLOCKING_QUERY));
|
||||
ASSERT_EQ(FSETLOCKING_INTERNAL, __fsetlocking(fp, FSETLOCKING_BYCALLER));
|
||||
ASSERT_EQ(FSETLOCKING_BYCALLER, __fsetlocking(fp, FSETLOCKING_QUERY));
|
||||
ASSERT_EQ(FSETLOCKING_BYCALLER, __fsetlocking(fp, FSETLOCKING_INTERNAL));
|
||||
ASSERT_EQ(FSETLOCKING_INTERNAL, __fsetlocking(fp, FSETLOCKING_QUERY));
|
||||
fclose(fp);
|
||||
}
|
||||
|
Reference in New Issue
Block a user