* commit '4ed111efe3a7f5b37039e3cce8039941977f390f': Fix flockfile(3) and friends for stdin/stdout/stderr too.
This commit is contained in:
		@@ -36,12 +36,20 @@
 | 
				
			|||||||
// struct __sfileext (see fileext.h).
 | 
					// struct __sfileext (see fileext.h).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void flockfile(FILE* fp) {
 | 
					void flockfile(FILE* fp) {
 | 
				
			||||||
 | 
					  if (!__sdidinit) {
 | 
				
			||||||
 | 
					    __sinit();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (fp != NULL) {
 | 
					  if (fp != NULL) {
 | 
				
			||||||
    pthread_mutex_lock(&_FLOCK(fp));
 | 
					    pthread_mutex_lock(&_FLOCK(fp));
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int ftrylockfile(FILE* fp) {
 | 
					int ftrylockfile(FILE* fp) {
 | 
				
			||||||
 | 
					  if (!__sdidinit) {
 | 
				
			||||||
 | 
					    __sinit();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // The specification for ftrylockfile() says it returns 0 on success,
 | 
					  // The specification for ftrylockfile() says it returns 0 on success,
 | 
				
			||||||
  // or non-zero on error. So return an errno code directly on error.
 | 
					  // or non-zero on error. So return an errno code directly on error.
 | 
				
			||||||
  if (fp == NULL) {
 | 
					  if (fp == NULL) {
 | 
				
			||||||
@@ -52,6 +60,10 @@ int ftrylockfile(FILE* fp) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void funlockfile(FILE* fp) {
 | 
					void funlockfile(FILE* fp) {
 | 
				
			||||||
 | 
					  if (!__sdidinit) {
 | 
				
			||||||
 | 
					    __sinit();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (fp != NULL) {
 | 
					  if (fp != NULL) {
 | 
				
			||||||
    pthread_mutex_unlock(&_FLOCK(fp));
 | 
					    pthread_mutex_unlock(&_FLOCK(fp));
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -34,6 +34,8 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include <pthread.h>
 | 
					#include <pthread.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					__BEGIN_DECLS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * file extension
 | 
					 * file extension
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
@@ -61,4 +63,6 @@ do { \
 | 
				
			|||||||
	_FILEEXT_INIT(f); \
 | 
						_FILEEXT_INIT(f); \
 | 
				
			||||||
} while (0)
 | 
					} while (0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					__END_DECLS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif /* _FILEEXT_H_ */
 | 
					#endif /* _FILEEXT_H_ */
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -32,6 +32,10 @@
 | 
				
			|||||||
 * SUCH DAMAGE.
 | 
					 * SUCH DAMAGE.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <sys/cdefs.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					__BEGIN_DECLS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * The first few FILEs are statically allocated; others are dynamically
 | 
					 * The first few FILEs are statically allocated; others are dynamically
 | 
				
			||||||
 * allocated and linked in via this glue structure.
 | 
					 * allocated and linked in via this glue structure.
 | 
				
			||||||
@@ -44,3 +48,5 @@ struct glue {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
/* This was referenced by a couple of different pieces of middleware and the Crystax NDK. */
 | 
					/* This was referenced by a couple of different pieces of middleware and the Crystax NDK. */
 | 
				
			||||||
__LIBC64_HIDDEN__ extern struct glue __sglue;
 | 
					__LIBC64_HIDDEN__ extern struct glue __sglue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					__END_DECLS
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -41,6 +41,8 @@
 | 
				
			|||||||
#include "wcio.h"
 | 
					#include "wcio.h"
 | 
				
			||||||
#include "fileext.h"
 | 
					#include "fileext.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					__BEGIN_DECLS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Android <= KitKat had getc/putc macros in <stdio.h> that referred
 | 
					 * Android <= KitKat had getc/putc macros in <stdio.h> that referred
 | 
				
			||||||
 * to __srget/__swbuf, so those symbols need to be public for LP32
 | 
					 * to __srget/__swbuf, so those symbols need to be public for LP32
 | 
				
			||||||
@@ -137,3 +139,5 @@ extern int __sfvwrite(FILE *, struct __suio *);
 | 
				
			|||||||
wint_t __fputwc_unlock(wchar_t wc, FILE *fp);
 | 
					wint_t __fputwc_unlock(wchar_t wc, FILE *fp);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#pragma GCC visibility pop
 | 
					#pragma GCC visibility pop
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					__END_DECLS
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -32,6 +32,10 @@
 | 
				
			|||||||
#ifndef _WCIO_H_
 | 
					#ifndef _WCIO_H_
 | 
				
			||||||
#define _WCIO_H_
 | 
					#define _WCIO_H_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <sys/cdefs.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					__BEGIN_DECLS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* minimal requirement of SUSv2 */
 | 
					/* minimal requirement of SUSv2 */
 | 
				
			||||||
#define WCIO_UNGETWC_BUFSIZE 1
 | 
					#define WCIO_UNGETWC_BUFSIZE 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -78,4 +82,6 @@ do {\
 | 
				
			|||||||
#define WCIO_INIT(fp) \
 | 
					#define WCIO_INIT(fp) \
 | 
				
			||||||
	memset(&(_EXT(fp)->_wcio), 0, sizeof(struct wchar_io_data))
 | 
						memset(&(_EXT(fp)->_wcio), 0, sizeof(struct wchar_io_data))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					__END_DECLS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif /*_WCIO_H_*/
 | 
					#endif /*_WCIO_H_*/
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user