diff options
Diffstat (limited to 'libio/stdio')
-rw-r--r-- | libio/stdio/ChangeLog | 3 | ||||
-rw-r--r-- | libio/stdio/feof.c | 53 | ||||
-rw-r--r-- | libio/stdio/ferror.c | 41 | ||||
-rw-r--r-- | libio/stdio/getc.c | 45 | ||||
-rw-r--r-- | libio/stdio/putc.c | 38 | ||||
-rw-r--r-- | libio/stdio/putchar.c | 2 | ||||
-rw-r--r-- | libio/stdio/stdio.h | 42 |
7 files changed, 185 insertions, 39 deletions
diff --git a/libio/stdio/ChangeLog b/libio/stdio/ChangeLog index 788c055..f98baec 100644 --- a/libio/stdio/ChangeLog +++ b/libio/stdio/ChangeLog @@ -65,7 +65,7 @@ Wed May 10 03:05:53 1995 Jason Merrill <jason@python.cygnus.com> Tue Oct 18 17:15:09 1994 Per Bothner <bothner@kalessin.cygnus.com> * getline.c, snprintf.c, vsnprintf.c: New files, providing - functionality of the GNU C C library. + functionality of the GNU C library. * Makefile.in (STDIO_OBJECTS), configure.in: Add new files. * stdio.h: Add new functions. @@ -131,4 +131,3 @@ Fri Aug 20 00:28:28 1993 Per Bothner (bothner@kalessin.cygnus.com) * configure.in (stdio_renamed): Removed feof. Added sprintf sscanf vsscanf. * ChangeLog.old: Copy of old libg++/iostream/stdio/ChangeLog. - diff --git a/libio/stdio/feof.c b/libio/stdio/feof.c index bd30c17..d06de044 100644 --- a/libio/stdio/feof.c +++ b/libio/stdio/feof.c @@ -1,34 +1,43 @@ -/* -Copyright (C) 1993 Free Software Foundation +/* Copyright (C) 1993, 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU IO Library. -This file is part of the GNU IO Library. This library is free -software; you can redistribute it and/or modify it under the -terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) -any later version. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This library is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. -You should have received a copy of the GNU General Public License -along with this library; see the file COPYING. If not, write to the Free -Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + You should have received a copy of the GNU General Public License + along with this library; see the file COPYING. If not, write to + the Free Software Foundation, 59 Temple Place - Suite 330, Boston, + MA 02111-1307, USA. -As a special exception, if you link this library with files -compiled with a GNU compiler to produce an executable, this does not cause -the resulting executable to be covered by the GNU General Public License. -This exception does not however invalidate any other reasons why -the executable file might be covered by the GNU General Public License. */ + As a special exception, if you link this library with files + compiled with a GNU compiler to produce an executable, this does + not cause the resulting executable to be covered by the GNU General + Public License. This exception does not however invalidate any + other reasons why the executable file might be covered by the GNU + General Public License. */ #include "libioP.h" #include "stdio.h" int -feof(fp) +_IO_feof (fp) _IO_FILE* fp; { - CHECK_FILE(fp, EOF); - return _IO_feof(fp); + int result; + CHECK_FILE (fp, EOF); + _IO_flockfile (fp); + result = _IO_feof_unlocked (fp); + _IO_funlockfile (fp); + return result; } + +#ifdef weak_alias +weak_alias (_IO_feof, feof) +#endif diff --git a/libio/stdio/ferror.c b/libio/stdio/ferror.c index ef95d7c..855627a 100644 --- a/libio/stdio/ferror.c +++ b/libio/stdio/ferror.c @@ -1,10 +1,43 @@ +/* Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU IO Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This library is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this library; see the file COPYING. If not, write to + the Free Software Foundation, 59 Temple Place - Suite 330, Boston, + MA 02111-1307, USA. + + As a special exception, if you link this library with files + compiled with a GNU compiler to produce an executable, this does + not cause the resulting executable to be covered by the GNU General + Public License. This exception does not however invalidate any + other reasons why the executable file might be covered by the GNU + General Public License. */ + #include "libioP.h" #include "stdio.h" int -ferror(fp) - FILE* fp; +_IO_ferror (fp) + _IO_FILE* fp; { - CHECK_FILE(fp, EOF); - return _IO_ferror(fp); + int result; + CHECK_FILE (fp, EOF); + _IO_flockfile (fp); + result = _IO_ferror_unlocked (fp); + _IO_funlockfile (fp); + return result; } + +#ifdef weak_alias +weak_alias (_IO_ferror, ferror) +#endif diff --git a/libio/stdio/getc.c b/libio/stdio/getc.c index 9db0987..1dc53b5 100644 --- a/libio/stdio/getc.c +++ b/libio/stdio/getc.c @@ -1,11 +1,48 @@ +/* Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU IO Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This library is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this library; see the file COPYING. If not, write to + the Free Software Foundation, 59 Temple Place - Suite 330, Boston, + MA 02111-1307, USA. + + As a special exception, if you link this library with files + compiled with a GNU compiler to produce an executable, this does + not cause the resulting executable to be covered by the GNU General + Public License. This exception does not however invalidate any + other reasons why the executable file might be covered by the GNU + General Public License. */ + #include "libioP.h" #include "stdio.h" -#undef getc +#undef _IO_getc int -getc(stream) - FILE *stream; +_IO_getc (fp) + FILE *fp; { - return _IO_getc (stream); + int result; + CHECK_FILE (fp, EOF); + _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp); + _IO_flockfile (fp); + result = _IO_getc_unlocked (fp); + _IO_cleanup_region_end (1); + return result; } + +#undef getc + +#ifdef weak_alias +weak_alias (_IO_getc, getc) +#endif diff --git a/libio/stdio/putc.c b/libio/stdio/putc.c index 2a3dcc3..3c35c36 100644 --- a/libio/stdio/putc.c +++ b/libio/stdio/putc.c @@ -1,12 +1,42 @@ +/* Copyright (C) 1991, 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + #include "libioP.h" #include "stdio.h" -#undef putc +#undef _IO_putc int -putc(c, stream) +_IO_putc (c, fp) int c; - FILE *stream; + _IO_FILE *fp; { - return _IO_putc(c, stream); + int result; + CHECK_FILE (fp, EOF); + _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp); + _IO_flockfile (fp); + result = _IO_putc_unlocked (c, fp); + _IO_cleanup_region_end (1); + return result; } + +#undef putc + +#ifdef weak_alias +weak_alias (_IO_putc, putc) +#endif diff --git a/libio/stdio/putchar.c b/libio/stdio/putchar.c index f97af04..1e1dd13 100644 --- a/libio/stdio/putchar.c +++ b/libio/stdio/putchar.c @@ -27,7 +27,7 @@ putchar (c) { int result; _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, - _IO_stdout); + _IO_stdout); _IO_flockfile (_IO_stdout); result = _IO_putc_unlocked (c, _IO_stdout); _IO_cleanup_region_end (1); diff --git a/libio/stdio/stdio.h b/libio/stdio/stdio.h index d1c4130..30065ac 100644 --- a/libio/stdio/stdio.h +++ b/libio/stdio/stdio.h @@ -169,10 +169,48 @@ extern int vsnprintf __P ((char *, size_t, const char *, _IO_va_list)); extern int __underflow __P((struct _IO_FILE*)); extern int __overflow __P((struct _IO_FILE*, int)); +/* Handle locking of streams. */ +#if defined _REENTRANT || defined _THREAD_SAFE +extern void clearerr_locked __P ((FILE *)); +extern void clearerr_unlocked __P ((FILE *)); +extern int feof_locked __P ((FILE *)); +extern int feof_unlocked __P ((FILE *)); +extern int ferror_locked __P ((FILE*)); +extern int ferror_unlocked __P ((FILE*)); +extern int fileno_locked __P ((FILE *)); +extern int fileno_unlocked __P ((FILE *)); +extern void flockfile __P ((FILE *)); +extern void funlockfile __P ((FILE *)); +extern int ftrylockfile __P ((FILE *)); +extern int fclose_unlocked __P ((FILE *)); +extern int fflush_locked __P ((FILE *)); +extern int fflush_unlocked __P ((FILE *)); +extern size_t fread_unlocked __P ((void *, size_t, size_t, FILE *)); +extern size_t fwrite_unlocked __P ((const void *, size_t, size_t, FILE *)); + +extern int fputc_locked __P ((int, FILE*)); +extern int fputc_unlocked __P ((int, FILE*)); +extern int getc_locked __P ((FILE *)); +extern int getc_unlocked __P ((FILE *)); +extern int getchar_locked __P ((void)); +extern int getchar_unlocked __P ((void)); +extern int putc_locked __P ((int, FILE *)); +extern int putc_unlocked __P ((int, FILE *)); +extern int putchar_locked __P ((int)); +extern int putchar_unlocked __P ((int)); + +# define getc_unlocked(fp) _IO_getc_unlocked (fp) +# define getc_locked(fp) _IO_getc (fp) +# define getchar_unlocked() _IO_getc_unlocked (stdin) +# define getchar_locked() _IO_getc (stdin) +# define putchar_unlocked(c) _IO_putc_unlocked (c, stdout) +# define putchar_locked(c) _IO_putc (c, stdout) +#endif /* __USE_REENTRANT */ + #define getc(fp) _IO_getc(fp) #define putc(c, fp) _IO_putc(c, fp) -#define putchar(c) putc(c, stdout) -#define getchar() getc(stdin) +#define putchar(c) _IO_putc(c, stdout) +#define getchar() _IO_getc(stdin) #ifdef __cplusplus } |