+2017-05-11 Zack Weinberg <zackw@panix.com>
+
+ * libio/libio.h: Condition dummy definition of _IO_lock_t on
+ _IO_lock_t_defined, not _IO_MTSAFE_IO. Unconditionally use the
+ non-_IO_MTSAFE_IO definitions for _IO_peekc, _IO_flockfile,
+ _IO_funlockfile, and _IO_ftrylockfile. Only define
+ _IO_cleanup_region_start and _IO_cleanup_region_end if not
+ already defined.
+ * include/libio.h: If _IO_MTSAFE_IO is defined, redefine
+ _IO_peekc, _IO_flockfile, _IO_funlockfile, and _IO_ftrylockfile
+ appropriately.
+ * sysdeps/generic/stdio-lock.h, sysdeps/nptl/stdio-lock.h:
+ Define _IO_lock_t_defined after defining _IO_lock_t.
+
2016-05-10 Adhemerval Zanella <adhemerval.zanella@linaro.org>
* sysdeps/powerpc/powerpc32/backtrace.c (is_sigtramp_address): Use
libc_hidden_proto (_IO_vfprintf)
libc_hidden_proto (_IO_vfscanf)
-#if defined _IO_MTSAFE_IO && _IO_lock_inexpensive
+#ifdef _IO_MTSAFE_IO
+# undef _IO_peekc
# undef _IO_flockfile
-# define _IO_flockfile(_fp) \
- if (((_fp)->_flags & _IO_USER_LOCK) == 0) \
- _IO_lock_lock (*(_fp)->_lock)
# undef _IO_funlockfile
-# define _IO_funlockfile(_fp) \
- if (((_fp)->_flags & _IO_USER_LOCK) == 0) \
- _IO_lock_unlock (*(_fp)->_lock)
-#endif
+# undef _IO_ftrylockfile
+
+# define _IO_peekc(_fp) _IO_peekc_locked (_fp)
+# if _IO_lock_inexpensive
+# define _IO_flockfile(_fp) \
+ if (((_fp)->_flags & _IO_USER_LOCK) == 0) _IO_lock_lock (*(_fp)->_lock)
+# define _IO_funlockfile(_fp) \
+ if (((_fp)->_flags & _IO_USER_LOCK) == 0) _IO_lock_unlock (*(_fp)->_lock)
+# else
+# define _IO_flockfile(_fp) \
+ if (((_fp)->_flags & _IO_USER_LOCK) == 0) _IO_flockfile (_fp)
+# define _IO_funlockfile(_fp) \
+ if (((_fp)->_flags & _IO_USER_LOCK) == 0) _IO_funlockfile (_fp)
+# endif
+#endif /* _IO_MTSAFE_IO */
#endif
#endif
struct _IO_jump_t; struct _IO_FILE;
-/* Handle lock. */
-#ifdef _IO_MTSAFE_IO
-/* _IO_lock_t defined in internal headers during the glibc build. */
-#else
+/* During the build of glibc itself, _IO_lock_t will already have been
+ defined by internal headers. */
+#ifndef _IO_lock_t_defined
typedef void _IO_lock_t;
#endif
extern void _IO_funlockfile (_IO_FILE *) __THROW;
extern int _IO_ftrylockfile (_IO_FILE *) __THROW;
-#ifdef _IO_MTSAFE_IO
-# define _IO_peekc(_fp) _IO_peekc_locked (_fp)
-# define _IO_flockfile(_fp) \
- if (((_fp)->_flags & _IO_USER_LOCK) == 0) _IO_flockfile (_fp)
-# define _IO_funlockfile(_fp) \
- if (((_fp)->_flags & _IO_USER_LOCK) == 0) _IO_funlockfile (_fp)
-#else
-# define _IO_peekc(_fp) _IO_peekc_unlocked (_fp)
-# define _IO_flockfile(_fp) /**/
-# define _IO_funlockfile(_fp) /**/
-# define _IO_ftrylockfile(_fp) /**/
-# define _IO_cleanup_region_start(_fct, _fp) /**/
-# define _IO_cleanup_region_end(_Doit) /**/
-#endif /* !_IO_MTSAFE_IO */
+#define _IO_peekc(_fp) _IO_peekc_unlocked (_fp)
+#define _IO_flockfile(_fp) /**/
+#define _IO_funlockfile(_fp) /**/
+#define _IO_ftrylockfile(_fp) /**/
+#ifndef _IO_cleanup_region_start
+#define _IO_cleanup_region_start(_fct, _fp) /**/
+#endif
+#ifndef _IO_cleanup_region_end
+#define _IO_cleanup_region_end(_Doit) /**/
+#endif
extern int _IO_vfscanf (_IO_FILE * __restrict, const char * __restrict,
_IO_va_list, int *__restrict);
#include <libc-lock.h>
__libc_lock_define_recursive (typedef, _IO_lock_t)
+#define _IO_lock_t_defined 1
/* We need recursive (counting) mutexes. */
#ifdef _LIBC_LOCK_RECURSIVE_INITIALIZER
#define _IO_lock_inexpensive 1
typedef struct { int lock; int cnt; void *owner; } _IO_lock_t;
+#define _IO_lock_t_defined 1
#define _IO_lock_initializer { LLL_LOCK_INITIALIZER, 0, NULL }