Index: include/stdio.h =================================================================== --- include/stdio.h +++ include/stdio.h @@ -302,7 +302,7 @@ char *ctermid(char *); FILE *fdopen(int, const char *); -int fileno(FILE *); +int fileno(FILE *); #endif /* __POSIX_VISIBLE */ #if __POSIX_VISIBLE >= 199209 @@ -328,7 +328,7 @@ void clearerr_unlocked(FILE *); int feof_unlocked(FILE *); int ferror_unlocked(FILE *); -int fileno_unlocked(FILE *); +static __inline int fileno_unlocked(FILE *); #endif #if __POSIX_VISIBLE >= 200112 @@ -482,22 +482,31 @@ extern int __isthreaded; +#define __sfileno(p) ((p)->_file) + +#if __BSD_VISIBLE +/* + * See ISO/IEC 9945-1 ANSI/IEEE Std 1003.1 Second Edition 1996-07-12 + * B.8.2.7 for the rationale behind the *_unlocked() macros. + */ +static __inline int +fileno_unlocked(FILE *p) +{ + return __sfileno(p); +} +#endif + #ifndef __cplusplus #define __sfeof(p) (((p)->_flags & __SEOF) != 0) #define __sferror(p) (((p)->_flags & __SERR) != 0) #define __sclearerr(p) ((void)((p)->_flags &= ~(__SERR|__SEOF))) -#define __sfileno(p) ((p)->_file) #define feof(p) (!__isthreaded ? __sfeof(p) : (feof)(p)) #define ferror(p) (!__isthreaded ? __sferror(p) : (ferror)(p)) #define clearerr(p) (!__isthreaded ? __sclearerr(p) : (clearerr)(p)) -#if __POSIX_VISIBLE -#define fileno(p) (!__isthreaded ? __sfileno(p) : (fileno)(p)) -#endif - #define getc(fp) (!__isthreaded ? __sgetc(fp) : (getc)(fp)) #define putc(x, fp) (!__isthreaded ? __sputc(x, fp) : (putc)(x, fp)) @@ -512,7 +521,6 @@ #define feof_unlocked(p) __sfeof(p) #define ferror_unlocked(p) __sferror(p) #define clearerr_unlocked(p) __sclearerr(p) -#define fileno_unlocked(p) __sfileno(p) #endif #if __POSIX_VISIBLE >= 199506 #define getc_unlocked(fp) __sgetc(fp) Index: lib/libc/Versions.def =================================================================== --- lib/libc/Versions.def +++ lib/libc/Versions.def @@ -27,6 +27,9 @@ FBSD_1.4 { } FBSD_1.3; +FBSD_1.4.1 { +} FBSD_1.4; + # This is our private namespace. Any global interfaces that are # strictly for use only by other FreeBSD applications and libraries Index: lib/libc/stdio/Symbol.map =================================================================== --- lib/libc/stdio/Symbol.map +++ lib/libc/stdio/Symbol.map @@ -21,7 +21,7 @@ fgetwc; fgetwln; fgetws; - fileno; + /* fileno; moved to FBSD_1.4.1 */ __sF; __stdinp; __stdoutp; @@ -90,7 +90,7 @@ feof_unlocked; ferror_unlocked; clearerr_unlocked; - fileno_unlocked; + /* fileno_unlocked; moved to FBSD_1.4.1 */ vasprintf; vfprintf; vfscanf; @@ -166,6 +166,11 @@ fdclose; }; +FBSD_1.4.1 { + fileno; + fileno_unlocked; +}; + FBSDprivate_1.0 { _flockfile; _flockfile_debug_stub; Index: lib/libc/stdio/fileno.c =================================================================== --- lib/libc/stdio/fileno.c +++ lib/libc/stdio/fileno.c @@ -45,7 +45,7 @@ #undef fileno_unlocked int -fileno(FILE *fp) +__fileno_10(FILE *fp) { int fd; @@ -57,8 +57,19 @@ } int -fileno_unlocked(FILE *fp) +__fileno_unlocked_10(FILE *fp) { return (__sfileno(fp)); } + +#if __POSIX_VISIBLE +__inline int +fileno(FILE *p) +{ + return (!__isthreaded ? __sfileno(p) : (__fileno_10)(p)); +} +#endif + +__sym_compat(fileno, __fileno_10, FBSD_1.0); +__sym_compat(fileno_unlocked, __fileno_unlocked_10, FBSD_1.0);