1998-07-05 11:54  Ulrich Drepper  <drepper@cygnus.com>

	* Versions: Add pthread_attr_init ti GLIBC_2.1 version in libc.
This commit is contained in:
Ulrich Drepper 1998-07-05 11:57:59 +00:00
parent eb27c43f02
commit 77ccaba1fa
9 changed files with 83 additions and 4 deletions

View File

@ -326,7 +326,7 @@ read_conf_file (const char *filename, const char *directory, size_t dir_len,
/* Process the known entries of the file. Comments start with `#' and
end with the end of the line. Empty lines are ignored. */
while (!feof (fp))
while (!feof_unlocked (fp))
{
char *rp, *endp, *word;
ssize_t n = __getdelim (&line, &line_len, '\n', fp);

View File

@ -265,7 +265,7 @@ token()
int c;
struct toktab *t;
if (feof(cfile) || ferror(cfile))
if (feof_unlocked(cfile) || ferror_unlocked(cfile))
return (0);
while ((c = getc_unlocked(cfile)) != EOF &&
(c == '\n' || c == '\t' || c == ' ' || c == ','))

View File

@ -131,6 +131,15 @@ struct block_list
# define alloca(size) (malloc (size))
#endif /* have alloca */
#if defined _LIBC || defined HAVE_FGETS_UNLOCKED
# undef fgets
# define fgets(buf, len, s) fgets_unlocked (buf, len, s)
#endif
#if defined _LIBC || defined HAVE_FEOF_UNLOCKED
# undef feof
# define feof(s) feof_unlocked (s)
#endif
struct alias_map
{

View File

@ -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

View File

@ -99,5 +99,6 @@ libc {
# f*
fgetpos64; fopen64; freopen64; fseeko; fseeko64; fsetpos64; ftello;
ftello64; fopen; fclose; fdopen; fread_unlocked; fwrite_unlocked;
fgets_unlocked;
}
}

56
libio/iofgets_u.c Normal file
View File

@ -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;
}

View File

@ -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));

View File

@ -1,3 +1,7 @@
1998-07-05 11:54 Ulrich Drepper <drepper@cygnus.com>
* Versions: Add pthread_attr_init ti GLIBC_2.1 version in libc.
1998-07-01 Andreas Jaeger <aj@arthur.rhein-neckar.de>
* attr.c: Include <string.h>.

View File

@ -14,6 +14,9 @@ libc {
pthread_self; pthread_setcancelstate; pthread_setcanceltype;
pthread_setschedparam;
}
GLIBC_2.1 {
pthread_attr_init;
}
}
libpthread {