diff --git a/library/include/stdio.h b/library/include/stdio.h index d0adb7a..850d7e3 100644 --- a/library/include/stdio.h +++ b/library/include/stdio.h @@ -1,5 +1,5 @@ /* - * $Id: stdio.h,v 1.7 2005-02-28 10:07:35 obarthel Exp $ + * $Id: stdio.h,v 1.8 2005-02-28 13:42:54 obarthel Exp $ * * :ts=4 * @@ -200,21 +200,6 @@ extern int putchar(int c); /****************************************************************************/ -/* The following four functions are not part of ISO 'C' (1994). */ - -/****************************************************************************/ - -extern int getc_unlocked(FILE *stream); -extern int getchar_unlocked(void); -extern int putc_unlocked(int c,FILE *stream); -extern int putchar_unlocked(int c); - -/****************************************************************************/ - -/* ISO 'C' (1994) functions continue below. */ - -/****************************************************************************/ - extern char *fgets(char *s,int n,FILE *stream); extern char *gets(char *s); @@ -264,23 +249,6 @@ extern char *tmpnam(char *buf); /****************************************************************************/ -/* - * A special buffer flush routine which returns the last character written - * in case of success and EOF in case of failure. This is used by the - * putc_unlocked() macro defined below. - */ -extern int __flush(FILE *stream); - -/****************************************************************************/ - -/* - * A special function which returns the input character. This is used by - * the getc() macro defined below. - */ -extern int __unlockfile(FILE *stream,int c); - -/****************************************************************************/ - /* * fgetc() implemented as a "simple" macro; note that fgetc() does much more than * can be conveniently expressed as a macro! @@ -292,8 +260,6 @@ extern int __unlockfile(FILE *stream,int c); ((FILE *)(f))->buffer[((FILE *)(f))->position++] : \ fgetc(f)) -#define getc_unlocked(f) __getc_unlocked(f) - /****************************************************************************/ /* @@ -311,13 +277,6 @@ extern int __unlockfile(FILE *stream,int c); (((FILE *)(f))->buffer[((FILE *)(f))->num_write_bytes-1]))) : \ fputc((c),(f))) -#define putc_unlocked(c,f) __putc_unlocked((c),(f)) - -/****************************************************************************/ - -#define getchar_unlocked() __getc_unlocked(stdin) -#define putchar_unlocked(c) __putc_unlocked((c),stdout) - /****************************************************************************/ #if defined(__THREAD_SAFE) @@ -365,6 +324,38 @@ extern int __unlockfile(FILE *stream,int c); /****************************************************************************/ +/* + * A special buffer flush routine which returns the last character written + * in case of success and EOF in case of failure. This is used by the + * putc_unlocked() macro defined above. + */ +extern int __flush(FILE *stream); + +/****************************************************************************/ + +/* + * A special function which returns the input character. This is used by + * the getc() macro defined above. + */ +extern int __unlockfile(FILE *stream,int c); + +/****************************************************************************/ + +extern int getc_unlocked(FILE *stream); +extern int getchar_unlocked(void); +extern int putc_unlocked(int c,FILE *stream); +extern int putchar_unlocked(int c); + +/****************************************************************************/ + +#define getc_unlocked(f) __getc_unlocked(f) +#define putc_unlocked(c,f) __putc_unlocked((c),(f)) + +#define getchar_unlocked() __getc_unlocked(stdin) +#define putchar_unlocked(c) __putc_unlocked((c),stdout) + +/****************************************************************************/ + extern FILE * fdopen(int file_descriptor, const char * type); extern int fileno(FILE * file); extern int asprintf(char **ret, const char *format, ...); @@ -375,12 +366,30 @@ extern FILE * popen(const char *command, const char *type); /****************************************************************************/ +#if defined(__THREAD_SAFE) + +/****************************************************************************/ + extern void flockfile(FILE * file); extern void funlockfile(FILE * file); extern int ftrylockfile(FILE * file); /****************************************************************************/ +#else + +/****************************************************************************/ + +#define flockfile(file) ((void)0) +#define funlockfile(file) ((void)0) +#define ftrylockfile(file) (0) + +/****************************************************************************/ + +#endif /* __THREAD_SAFE */ + +/****************************************************************************/ + extern int vasprintf(char **ret,const char *format,va_list arg); #ifdef __MEM_DEBUG diff --git a/library/stdio_flockfile.c b/library/stdio_flockfile.c index 286b278..a91a4b3 100644 --- a/library/stdio_flockfile.c +++ b/library/stdio_flockfile.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_flockfile.c,v 1.2 2005-02-28 10:07:30 obarthel Exp $ + * $Id: stdio_flockfile.c,v 1.3 2005-02-28 13:42:52 obarthel Exp $ * * :ts=4 * @@ -43,6 +43,10 @@ /****************************************************************************/ +#if defined(__THREAD_SAFE) + +/****************************************************************************/ + void flockfile(FILE *stream) { @@ -87,3 +91,7 @@ flockfile(FILE *stream) LEAVE(); } + +/****************************************************************************/ + +#endif /* __THREAD_SAFE */ diff --git a/library/stdio_ftrylockfile.c b/library/stdio_ftrylockfile.c index db479f6..75b2e91 100644 --- a/library/stdio_ftrylockfile.c +++ b/library/stdio_ftrylockfile.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_ftrylockfile.c,v 1.2 2005-02-28 10:07:30 obarthel Exp $ + * $Id: stdio_ftrylockfile.c,v 1.3 2005-02-28 13:42:52 obarthel Exp $ * * :ts=4 * @@ -43,6 +43,10 @@ /****************************************************************************/ +#if defined(__THREAD_SAFE) + +/****************************************************************************/ + int ftrylockfile(FILE *stream) { @@ -91,3 +95,7 @@ ftrylockfile(FILE *stream) RETURN(result); return(result); } + +/****************************************************************************/ + +#endif /* __THREAD_SAFE */ diff --git a/library/stdio_funlockfile.c b/library/stdio_funlockfile.c index 59dae4e..5ff8c69 100644 --- a/library/stdio_funlockfile.c +++ b/library/stdio_funlockfile.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_funlockfile.c,v 1.2 2005-02-28 10:07:31 obarthel Exp $ + * $Id: stdio_funlockfile.c,v 1.3 2005-02-28 13:42:52 obarthel Exp $ * * :ts=4 * @@ -43,6 +43,10 @@ /****************************************************************************/ +#if defined(__THREAD_SAFE) + +/****************************************************************************/ + void funlockfile(FILE *stream) { @@ -87,3 +91,7 @@ funlockfile(FILE *stream) LEAVE(); } + +/****************************************************************************/ + +#endif /* __THREAD_SAFE */