about summary refs log tree commit diff
path: root/libio
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-07-05 11:57:59 +0000
committerUlrich Drepper <drepper@redhat.com>1998-07-05 11:57:59 +0000
commit77ccaba1fa58f871e797ced648c2966842e477db (patch)
treefec432e9338d6956a0a9b6e5a03d330ff580bb06 /libio
parenteb27c43f02ec7890c19f424de458df903745db5d (diff)
downloadglibc-77ccaba1fa58f871e797ced648c2966842e477db.tar.gz
glibc-77ccaba1fa58f871e797ced648c2966842e477db.tar.xz
glibc-77ccaba1fa58f871e797ced648c2966842e477db.zip
Update.
1998-07-05 11:54  Ulrich Drepper  <drepper@cygnus.com>

	* Versions: Add pthread_attr_init ti GLIBC_2.1 version in libc.
Diffstat (limited to 'libio')
-rw-r--r--libio/Makefile4
-rw-r--r--libio/Versions1
-rw-r--r--libio/iofgets_u.c56
-rw-r--r--libio/stdio.h6
4 files changed, 65 insertions, 2 deletions
diff --git a/libio/Makefile b/libio/Makefile
index 3c75183987..bc43ebb674 100644
--- a/libio/Makefile
+++ b/libio/Makefile
@@ -34,7 +34,7 @@ routines	:=							      \
 	clearerr feof ferror fgetc fileno fputc freopen fseek getc getchar    \
 	memstream pclose putc putchar rewind setbuf setlinebuf vasprintf      \
 	iovdprintf vscanf vsnprintf obprintf fcloseall fseeko ftello	      \
-	freopen64 fseeko64 ftello64 iofread_u iofwrite_u		      \
+	freopen64 fseeko64 ftello64					      \
 									      \
 	libc_fatal
 
@@ -50,7 +50,7 @@ CPPFLAGS-.o += -DIO_DEBUG
 
 ifneq (,$(filter %REENTRANT, $(defines)))
 routines += clearerr_u feof_u ferror_u fputc_u getc_u getchar_u		      \
-	    iofflush_u putc_u putchar_u peekc
+	    iofflush_u putc_u putchar_u peekc iofread_u iofwrite_u iofgets_u
 
 CPPFLAGS += -D_IO_MTSAFE_IO
 endif
diff --git a/libio/Versions b/libio/Versions
index 12277ae29f..e837abb5d7 100644
--- a/libio/Versions
+++ b/libio/Versions
@@ -99,5 +99,6 @@ libc {
     # f*
     fgetpos64; fopen64; freopen64; fseeko; fseeko64; fsetpos64; ftello;
     ftello64; fopen; fclose; fdopen; fread_unlocked; fwrite_unlocked;
+    fgets_unlocked;
   }
 }
diff --git a/libio/iofgets_u.c b/libio/iofgets_u.c
new file mode 100644
index 0000000000..1eb98bd542
--- /dev/null
+++ b/libio/iofgets_u.c
@@ -0,0 +1,56 @@
+/* Copyright (C) 1993, 1995, 1996, 1997, 1998 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>
+
+char *
+fgets_unlocked (buf, n, fp)
+     char *buf;
+     int n;
+     _IO_FILE *fp;
+{
+  _IO_size_t count;
+  char *result;
+  int old_error;
+  CHECK_FILE (fp, NULL);
+  if (n <= 0)
+    return NULL;
+  /* This is very tricky since a file descriptor may be in the
+     non-blocking mode. The error flag doesn't mean much in this
+     case. We return an error only when there is a new error. */
+  old_error = fp->_IO_file_flags & _IO_ERR_SEEN;
+  fp->_IO_file_flags &= ~_IO_ERR_SEEN;
+  count = _IO_getline (fp, buf, n - 1, '\n', 1);
+  if (count == 0 || (fp->_IO_file_flags & _IO_ERR_SEEN))
+    result = NULL;
+  else
+    {
+      buf[count] = '\0';
+      result = buf;
+    }
+  fp->_IO_file_flags |= old_error;
+  return result;
+}
diff --git a/libio/stdio.h b/libio/stdio.h
index e716cee61e..b220e41081 100644
--- a/libio/stdio.h
+++ b/libio/stdio.h
@@ -476,6 +476,12 @@ extern int putw __P ((int __w, FILE *__stream));
 extern char *fgets __P ((char *__restrict __s, int __n,
 			 FILE *__restrict __stream));
 
+#ifdef __USE_GNU
+/* This function does the same as `fgets' but does not lock the stream.  */
+extern char *fgets_unlocked __P ((char *__restrict __s, int __n,
+				  FILE *__restrict __stream));
+#endif
+
 /* Get a newline-terminated string from stdin, removing the newline.
    DO NOT USE THIS FUNCTION!!  There is no limit on how much it will read.  */
 extern char *gets __P ((char *__s));