aboutsummaryrefslogtreecommitdiffstats
path: root/libc/stdio/fileext.h
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2015-01-20 18:09:05 -0800
committerElliott Hughes <enh@google.com>2015-01-21 10:33:30 -0800
commit8c4994bbc1a9a01e34ea92c91eb5b2d1a27bd074 (patch)
tree8b632cea0832373b9cb843427bb5976b3668f1a2 /libc/stdio/fileext.h
parentf374358414812d3e5a45ba75a2b1926693924420 (diff)
downloadandroid_bionic-8c4994bbc1a9a01e34ea92c91eb5b2d1a27bd074.tar.gz
android_bionic-8c4994bbc1a9a01e34ea92c91eb5b2d1a27bd074.tar.bz2
android_bionic-8c4994bbc1a9a01e34ea92c91eb5b2d1a27bd074.zip
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
Diffstat (limited to 'libc/stdio/fileext.h')
-rw-r--r--libc/stdio/fileext.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/libc/stdio/fileext.h b/libc/stdio/fileext.h
index 25b7bda24..75230cda1 100644
--- a/libc/stdio/fileext.h
+++ b/libc/stdio/fileext.h
@@ -33,6 +33,7 @@
#define _FILEEXT_H_
#include <pthread.h>
+#include <stdbool.h>
__BEGIN_DECLS
@@ -40,9 +41,10 @@ __BEGIN_DECLS
* file extension
*/
struct __sfileext {
- struct __sbuf _ub; /* ungetc buffer */
+ struct __sbuf _ub; /* ungetc buffer */
struct wchar_io_data _wcio; /* wide char io status */
- pthread_mutex_t _lock; /* file lock */
+ pthread_mutex_t _lock; /* file lock */
+ bool _stdio_handles_locking; /* __fsetlocking support */
};
#define _EXT(fp) ((struct __sfileext *)((fp)->_ext._base))
@@ -54,7 +56,8 @@ do { \
_UB(fp)._base = NULL; \
_UB(fp)._size = 0; \
WCIO_INIT(fp); \
- _FLOCK(fp).value = __PTHREAD_RECURSIVE_MUTEX_INIT_VALUE; \
+ _FLOCK(fp).value = __PTHREAD_RECURSIVE_MUTEX_INIT_VALUE; \
+ _EXT(fp)->_stdio_handles_locking = true; \
} while (0)
#define _FILEEXT_SETUP(f, fext) \