Index: include/stdio.h =================================================================== --- include/stdio.h +++ include/stdio.h @@ -302,7 +302,16 @@ char *ctermid(char *); FILE *fdopen(int, const char *); +#ifndef FILENO_C +#if defined(__STDC_VERSION__) +/* C95 compatible source code. */ +static inline int fileno(FILE *); +#else +/* defined(__ANSI__) || defined(__cplusplus) */ +/* C89 compatible source code. for C89 we DONT HAVE 'inline' keyword and for C++ we dont need static inline one (as not defined :D) */ int fileno(FILE *); +#endif +#endif #endif /* __POSIX_VISIBLE */ #if __POSIX_VISIBLE >= 199209 @@ -328,8 +337,17 @@ void clearerr_unlocked(FILE *); int feof_unlocked(FILE *); int ferror_unlocked(FILE *); +#ifndef FILENO_C +#if defined(__STDC_VERSION__) +/* C95 compatible source code. */ +static inline int fileno_unlocked(FILE *); +#else +/* defined(__ANSI__) || defined(__cplusplus) */ +/* C89 compatible source code. for C89 we DONT HAVE 'inline' keyword and for C++ we dont need static inline one (as not defined :D) */ int fileno_unlocked(FILE *); #endif +#endif +#endif #if __POSIX_VISIBLE >= 200112 int fseeko(FILE *, __off_t, int); @@ -495,8 +513,21 @@ #define clearerr(p) (!__isthreaded ? __sclearerr(p) : (clearerr)(p)) #if __POSIX_VISIBLE +#ifndef FILENO_C +#if defined(__STDC_VERSION__) +/* C95 compatible source code. */ +static inline int +fileno(FILE *p) +{ + return (!__isthreaded ? __sfileno(p) : (fileno)(p)); +} +#else +/* defined(__ANSI__) but here we are sure !defined(__cplusplus) :D */ +/* C89 compatible source code. for C89 we DONT HAVE 'inline' keyword */ #define fileno(p) (!__isthreaded ? __sfileno(p) : (fileno)(p)) #endif +#endif +#endif #define getc(fp) (!__isthreaded ? __sgetc(fp) : (getc)(fp)) #define putc(x, fp) (!__isthreaded ? __sputc(x, fp) : (putc)(x, fp)) @@ -512,8 +543,21 @@ #define feof_unlocked(p) __sfeof(p) #define ferror_unlocked(p) __sferror(p) #define clearerr_unlocked(p) __sclearerr(p) +#ifndef FILENO_C +#if defined(__STDC_VERSION__) +/* C95 compatible source code. */ +static inline int +fileno_unlocked(FILE *p) +{ + return __sfileno(p); +} +#else +/* defined(__ANSI__) but here we are sure !defined(__cplusplus) :D */ +/* C89 compatible source code. for C89 we DONT HAVE 'inline' keyword */ #define fileno_unlocked(p) __sfileno(p) #endif +#endif +#endif #if __POSIX_VISIBLE >= 199506 #define getc_unlocked(fp) __sgetc(fp) #define putc_unlocked(x, fp) __sputc(x, fp) Index: lib/libc/stdio/fileno.c =================================================================== --- lib/libc/stdio/fileno.c +++ lib/libc/stdio/fileno.c @@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$"); #include "namespace.h" +#define FILENO_C #include #include "un-namespace.h" #include "libc_private.h" @@ -62,3 +63,4 @@ return (__sfileno(fp)); } +#undef FILENO_C