* commit '7cc4d2efa9a89928c3ff51d171f7a03e12793038': Add non-macro stdin/stdout/stderr too.
This commit is contained in:
		@@ -146,7 +146,16 @@ typedef	struct __sFILE {
 | 
				
			|||||||
	fpos_t	_offset;	/* current lseek offset */
 | 
						fpos_t	_offset;	/* current lseek offset */
 | 
				
			||||||
} FILE;
 | 
					} FILE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Legacy BSD implementation of stdin/stdout/stderr. */
 | 
				
			||||||
extern FILE __sF[];
 | 
					extern FILE __sF[];
 | 
				
			||||||
 | 
					/* More obvious implementation. */
 | 
				
			||||||
 | 
					extern FILE* stdin;
 | 
				
			||||||
 | 
					extern FILE* stdout;
 | 
				
			||||||
 | 
					extern FILE* stderr;
 | 
				
			||||||
 | 
					/* C99 and earlier plus current C++ standards say these must be macros. */
 | 
				
			||||||
 | 
					#define stdin stdin
 | 
				
			||||||
 | 
					#define stdout stdout
 | 
				
			||||||
 | 
					#define stderr stderr
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define	__SLBF	0x0001		/* line buffered */
 | 
					#define	__SLBF	0x0001		/* line buffered */
 | 
				
			||||||
#define	__SNBF	0x0002		/* unbuffered */
 | 
					#define	__SNBF	0x0002		/* unbuffered */
 | 
				
			||||||
@@ -209,10 +218,6 @@ extern FILE __sF[];
 | 
				
			|||||||
#define	SEEK_END	2	/* set file offset to EOF plus offset */
 | 
					#define	SEEK_END	2	/* set file offset to EOF plus offset */
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define	stdin	(&__sF[0])
 | 
					 | 
				
			||||||
#define	stdout	(&__sF[1])
 | 
					 | 
				
			||||||
#define	stderr	(&__sF[2])
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Functions defined in ANSI C standard.
 | 
					 * Functions defined in ANSI C standard.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -43,10 +43,6 @@ struct __sfileext {
 | 
				
			|||||||
	pthread_mutex_t _lock; /* file lock */
 | 
						pthread_mutex_t _lock; /* file lock */
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
__LIBC_HIDDEN__ extern struct __sfileext __sFext[3];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define _FILEEXT_INITIALIZER  {{NULL,0},{0},PTHREAD_RECURSIVE_MUTEX_INITIALIZER}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define _EXT(fp) ((struct __sfileext *)((fp)->_ext._base))
 | 
					#define _EXT(fp) ((struct __sfileext *)((fp)->_ext._base))
 | 
				
			||||||
#define _UB(fp) _EXT(fp)->_ub
 | 
					#define _UB(fp) _EXT(fp)->_ub
 | 
				
			||||||
#define _FLOCK(fp)  _EXT(fp)->_lock
 | 
					#define _FLOCK(fp)  _EXT(fp)->_lock
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -59,12 +59,15 @@ static struct glue uglue = { 0, FOPEN_MAX - 3, usual };
 | 
				
			|||||||
static struct glue *lastglue = &uglue;
 | 
					static struct glue *lastglue = &uglue;
 | 
				
			||||||
_THREAD_PRIVATE_MUTEX(__sfp_mutex);
 | 
					_THREAD_PRIVATE_MUTEX(__sfp_mutex);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct __sfileext __sFext[3];
 | 
					static struct __sfileext __sFext[3];
 | 
				
			||||||
FILE __sF[3] = {
 | 
					FILE __sF[3] = {
 | 
				
			||||||
	std(__SRD, STDIN_FILENO),		/* stdin */
 | 
						std(__SRD, STDIN_FILENO),		/* stdin */
 | 
				
			||||||
	std(__SWR, STDOUT_FILENO),		/* stdout */
 | 
						std(__SWR, STDOUT_FILENO),		/* stdout */
 | 
				
			||||||
	std(__SWR|__SNBF, STDERR_FILENO)	/* stderr */
 | 
						std(__SWR|__SNBF, STDERR_FILENO)	/* stderr */
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					FILE* stdin = &__sF[0];
 | 
				
			||||||
 | 
					FILE* stdout = &__sF[1];
 | 
				
			||||||
 | 
					FILE* stderr = &__sF[2];
 | 
				
			||||||
struct glue __sglue = { &uglue, 3, __sF };
 | 
					struct glue __sglue = { &uglue, 3, __sF };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static struct glue *
 | 
					static struct glue *
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user