aboutsummaryrefslogtreecommitdiff
path: root/libio
diff options
context:
space:
mode:
Diffstat (limited to 'libio')
-rw-r--r--libio/clearerr.c26
-rw-r--r--libio/fgetc.c4
-rw-r--r--libio/filedoalloc.c7
-rw-r--r--libio/fileops.c17
-rw-r--r--libio/fputc.c4
-rw-r--r--libio/freopen.c4
-rw-r--r--libio/fseek.c4
-rw-r--r--libio/genops.c4
-rw-r--r--libio/getc.c4
-rw-r--r--libio/getchar.c5
-rw-r--r--libio/iofclose.c34
-rw-r--r--libio/iofflush.c5
-rw-r--r--libio/iofgetpos.c4
-rw-r--r--libio/iofgets.c4
-rw-r--r--libio/iofputs.c4
-rw-r--r--libio/iofread.c4
-rw-r--r--libio/iofsetpos.c4
-rw-r--r--libio/ioftell.c4
-rw-r--r--libio/iofwrite.c4
-rw-r--r--libio/iogetdelim.c4
-rw-r--r--libio/iogets.c8
-rw-r--r--libio/iopadn.c6
-rw-r--r--libio/ioputs.c4
-rw-r--r--libio/ioseekoff.c6
-rw-r--r--libio/ioseekpos.c6
-rw-r--r--libio/iosetbuffer.c4
-rw-r--r--libio/iosetvbuf.c4
-rw-r--r--libio/ioungetc.c4
-rw-r--r--libio/iovsprintf.c3
-rw-r--r--libio/iovsscanf.c11
-rw-r--r--libio/libio.h2
-rw-r--r--libio/libioP.h2
32 files changed, 123 insertions, 87 deletions
diff --git a/libio/clearerr.c b/libio/clearerr.c
index 9dfdb11530..7c7fb93dc0 100644
--- a/libio/clearerr.c
+++ b/libio/clearerr.c
@@ -1,20 +1,20 @@
/* Copyright (C) 1995, 1996 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+ 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 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.
+ 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. */
+ 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"
diff --git a/libio/fgetc.c b/libio/fgetc.c
index a754c4b78b..25bfed5596 100644
--- a/libio/fgetc.c
+++ b/libio/fgetc.c
@@ -31,9 +31,9 @@ fgetc (fp)
{
int result;
CHECK_FILE (fp, EOF);
- __libc_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
_IO_flockfile (fp);
result = _IO_getc_unlocked (fp);
- __libc_cleanup_region_end (1);
+ _IO_cleanup_region_end (1);
return result;
}
diff --git a/libio/filedoalloc.c b/libio/filedoalloc.c
index f36bfb3e32..836c56b63b 100644
--- a/libio/filedoalloc.c
+++ b/libio/filedoalloc.c
@@ -49,9 +49,12 @@ the executable file might be covered by the GNU General Public License. */
#include <sys/stat.h>
#ifdef __STDC__
#include <stdlib.h>
+#include <unistd.h>
#endif
+
#ifdef _LIBC
-# include <unistd.h>
+# undef isatty
+# define isatty(Fd) __isatty (Fd)
#endif
/*
@@ -100,7 +103,7 @@ DEFUN(_IO_file_doallocate, (fp),
}
ALLOC_BUF(p, size, EOF);
_IO_setb(fp, p, p+size, 1);
- if (couldbetty && __isatty (fp->_fileno))
+ if (couldbetty && isatty(fp->_fileno))
fp->_flags |= _IO_LINE_BUF;
return 1;
}
diff --git a/libio/fileops.c b/libio/fileops.c
index 3294befbd2..dd1f573400 100644
--- a/libio/fileops.c
+++ b/libio/fileops.c
@@ -37,6 +37,11 @@ the executable file might be covered by the GNU General Public License. */
extern int errno;
#endif
+
+#ifdef _LIBC
+# define open(Name, Flags, Prot) __open ((Name), (Flags), (Prot))
+#endif
+
/* An fstream can be in at most one of put mode, get mode, or putback mode.
Putback mode is a variant of get mode.
@@ -177,7 +182,7 @@ DEFUN(_IO_file_fopen, (fp, filename, mode),
omode = O_RDWR;
read_write &= _IO_IS_APPENDING;
}
- fdesc = __open (filename, omode|oflags, oprot);
+ fdesc = open(filename, omode|oflags, oprot);
if (fdesc < 0)
return NULL;
fp->_fileno = fdesc;
@@ -223,7 +228,7 @@ DEFUN(_IO_file_setbuf, (fp, p, len),
}
/* Write TO_DO bytes from DATA to FP.
- Then mark FP has having empty buffers. */
+ Then mark FP as having empty buffers. */
int
DEFUN(_IO_do_write, (fp, data, to_do),
@@ -548,6 +553,10 @@ DEFUN(_IO_file_read, (fp, buf, size),
{
_IO_ssize_t count = _IO_read(fp->_fileno, buf, size);
#if 0 && defined EINTR
+ /* We must not do this optimization since POSIX.1 explicitly
+ requests that the stream operations must return with the
+ error EINTR if this happens. There must be the possibility
+ that stream operations time out. --drepper */
if (count == -1 && errno == EINTR)
continue;
#endif
@@ -587,6 +596,10 @@ DEFUN(_IO_file_write, (f, data, n),
if (count == EOF)
{
#if 0 && defined EINTR
+ /* We must not do this optimization since POSIX.1 explicitly
+ requests that the stream operations must return with the
+ error EINTR if this happens. There must be the
+ possibility that stream operations time out. --drepper */
if (errno == EINTR)
continue;
else
diff --git a/libio/fputc.c b/libio/fputc.c
index 865ac8cde0..89359dc46d 100644
--- a/libio/fputc.c
+++ b/libio/fputc.c
@@ -32,10 +32,10 @@ fputc (c, fp)
{
int result;
CHECK_FILE (fp, EOF);
- __libc_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
_IO_flockfile (fp);
result = _IO_putc_unlocked (c, fp);
- __libc_cleanup_region_end (1);
+ _IO_cleanup_region_end (1);
return result;
}
diff --git a/libio/freopen.c b/libio/freopen.c
index 0b782dd770..bb0c59788f 100644
--- a/libio/freopen.c
+++ b/libio/freopen.c
@@ -35,9 +35,9 @@ freopen (filename, mode, fp)
CHECK_FILE (fp, NULL);
if (!(fp->_flags & _IO_IS_FILEBUF))
return NULL;
- __libc_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
_IO_flockfile (fp);
result = _IO_freopen (filename, mode, fp);
- __libc_cleanup_region_end (1);
+ _IO_cleanup_region_end (1);
return result;
}
diff --git a/libio/fseek.c b/libio/fseek.c
index 61f2e9205e..3d4e4925b9 100644
--- a/libio/fseek.c
+++ b/libio/fseek.c
@@ -33,9 +33,9 @@ fseek (fp, offset, whence)
{
int result;
CHECK_FILE (fp, -1);
- __libc_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
_IO_flockfile (fp);
result = _IO_fseek (fp, offset, whence);
- __libc_cleanup_region_end (1);
+ _IO_cleanup_region_end (1);
return result;
}
diff --git a/libio/genops.c b/libio/genops.c
index 52b8fc312a..7679445c2b 100644
--- a/libio/genops.c
+++ b/libio/genops.c
@@ -466,7 +466,7 @@ DEFUN(_IO_init, (fp, flags),
fp->_markers = NULL;
fp->_cur_column = 0;
#ifdef _IO_MTSAFE_IO
- __libc_lock_init_recursive (*fp->_lock);
+ _IO_lock_init_recursive (*fp->_lock);
#endif
}
@@ -501,7 +501,7 @@ DEFUN(_IO_default_finish, (fp),
}
#ifdef _IO_MTSAFE_IO
- __libc_lock_fini (*fp->_lock);
+ _IO_lock_fini (*fp->_lock);
#endif
_IO_un_link(fp);
diff --git a/libio/getc.c b/libio/getc.c
index 0c0b6b84d3..eede63984f 100644
--- a/libio/getc.c
+++ b/libio/getc.c
@@ -33,10 +33,10 @@ _IO_getc (fp)
{
int result;
CHECK_FILE (fp, EOF);
- __libc_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
_IO_flockfile (fp);
result = _IO_getc_unlocked (fp);
- __libc_cleanup_region_end (1);
+ _IO_cleanup_region_end (1);
return result;
}
#undef getc
diff --git a/libio/getchar.c b/libio/getchar.c
index d54ec58c1e..aa675591ad 100644
--- a/libio/getchar.c
+++ b/libio/getchar.c
@@ -31,11 +31,10 @@ int
getchar ()
{
int result;
- __libc_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
- stdin);
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, stdin);
_IO_flockfile (stdin);
result = _IO_getc_unlocked (stdin);
- __libc_cleanup_region_end (1);
+ _IO_cleanup_region_end (1);
return result;
}
diff --git a/libio/iofclose.c b/libio/iofclose.c
index 77c7b50088..79a0543471 100644
--- a/libio/iofclose.c
+++ b/libio/iofclose.c
@@ -33,21 +33,31 @@ _IO_fclose (fp)
{
int status;
- CHECK_FILE(fp, EOF);
-
- __libc_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
- _IO_flockfile (fp);
- if (fp->_IO_file_flags & _IO_IS_FILEBUF)
- status = _IO_file_close_it (fp);
+ if (fp == NULL)
+ {
+ /* Close all streams. */
+ _IO_cleanup ();
+ status = 0;
+ }
else
- status = fp->_flags & _IO_ERR_SEEN ? -1 : 0;
- _IO_FINISH (fp);
- __libc_cleanup_region_end (1);
- if (fp != _IO_stdin && fp != _IO_stdout && fp != _IO_stderr)
{
- fp->_IO_file_flags = 0;
- free(fp);
+ CHECK_FILE(fp, EOF);
+
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
+ _IO_flockfile (fp);
+ if (fp->_IO_file_flags & _IO_IS_FILEBUF)
+ status = _IO_file_close_it (fp);
+ else
+ status = fp->_flags & _IO_ERR_SEEN ? -1 : 0;
+ _IO_FINISH (fp);
+ _IO_cleanup_region_end (1);
+ if (fp != _IO_stdin && fp != _IO_stdout && fp != _IO_stderr)
+ {
+ fp->_IO_file_flags = 0;
+ free(fp);
+ }
}
+
return status;
}
diff --git a/libio/iofflush.c b/libio/iofflush.c
index 385c9629eb..af69486164 100644
--- a/libio/iofflush.c
+++ b/libio/iofflush.c
@@ -35,11 +35,10 @@ _IO_fflush (fp)
{
int result;
CHECK_FILE (fp, EOF);
- __libc_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
- fp);
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
_IO_flockfile (fp);
result = _IO_SYNC (fp) ? EOF : 0;
- __libc_cleanup_region_end (1);
+ _IO_cleanup_region_end (1);
return result;
}
}
diff --git a/libio/iofgetpos.c b/libio/iofgetpos.c
index 07128c16a3..cae5df7b39 100644
--- a/libio/iofgetpos.c
+++ b/libio/iofgetpos.c
@@ -33,10 +33,10 @@ _IO_fgetpos (fp, posp)
{
_IO_fpos_t pos;
CHECK_FILE (fp, EOF);
- __libc_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
_IO_flockfile (fp);
pos = _IO_seekoff (fp, 0, _IO_seek_cur, 0);
- __libc_cleanup_region_end (1);
+ _IO_cleanup_region_end (1);
if (pos == _IO_pos_BAD)
{
#ifdef EIO
diff --git a/libio/iofgets.c b/libio/iofgets.c
index 79ba1a9cd6..7a1044f801 100644
--- a/libio/iofgets.c
+++ b/libio/iofgets.c
@@ -36,7 +36,7 @@ _IO_fgets (buf, n, fp)
CHECK_FILE (fp, NULL);
if (n <= 0)
return NULL;
- __libc_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
_IO_flockfile (fp);
count = _IO_getline (fp, buf, n - 1, '\n', 1);
if (count == 0 || (fp->_IO_file_flags & _IO_ERR_SEEN))
@@ -46,7 +46,7 @@ _IO_fgets (buf, n, fp)
buf[count] = '\0';
result = buf;
}
- __libc_cleanup_region_end (1);
+ _IO_cleanup_region_end (1);
return result;
}
diff --git a/libio/iofputs.c b/libio/iofputs.c
index 6e94223a5c..9ce3caa194 100644
--- a/libio/iofputs.c
+++ b/libio/iofputs.c
@@ -33,13 +33,13 @@ _IO_fputs (str, fp)
_IO_size_t len = strlen (str);
int result;
CHECK_FILE (fp, EOF);
- __libc_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
_IO_flockfile (fp);
if (_IO_sputn (fp, str, len) != len)
result = EOF;
else
result = 1;
- __libc_cleanup_region_end (1);
+ _IO_cleanup_region_end (1);
return result;
}
diff --git a/libio/iofread.c b/libio/iofread.c
index 8610b0c87c..5fed0d8d7d 100644
--- a/libio/iofread.c
+++ b/libio/iofread.c
@@ -36,10 +36,10 @@ _IO_fread (buf, size, count, fp)
CHECK_FILE (fp, 0);
if (bytes_requested == 0)
return 0;
- __libc_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
_IO_flockfile (fp);
bytes_read = _IO_sgetn (fp, (char *) buf, bytes_requested);
- __libc_cleanup_region_end (1);
+ _IO_cleanup_region_end (1);
return bytes_requested == bytes_read ? count : bytes_read / size;
}
weak_alias (_IO_fread, fread)
diff --git a/libio/iofsetpos.c b/libio/iofsetpos.c
index 52700f70bc..ec913e3e2f 100644
--- a/libio/iofsetpos.c
+++ b/libio/iofsetpos.c
@@ -32,7 +32,7 @@ _IO_fsetpos (fp, posp)
{
int result;
CHECK_FILE (fp, EOF);
- __libc_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
_IO_flockfile (fp);
if (_IO_seekpos (fp, *posp, _IOS_INPUT|_IOS_OUTPUT) == _IO_pos_BAD)
{
@@ -45,7 +45,7 @@ _IO_fsetpos (fp, posp)
}
else
result = 0;
- __libc_cleanup_region_end (1);
+ _IO_cleanup_region_end (1);
return result;
}
diff --git a/libio/ioftell.c b/libio/ioftell.c
index 1fc7c55a51..7fe18f890b 100644
--- a/libio/ioftell.c
+++ b/libio/ioftell.c
@@ -32,10 +32,10 @@ _IO_ftell (fp)
{
_IO_pos_t pos;
CHECK_FILE (fp, -1L);
- __libc_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
_IO_flockfile (fp);
pos = _IO_seekoff (fp, 0, _IO_seek_cur, 0);
- __libc_cleanup_region_end (1);
+ _IO_cleanup_region_end (1);
if (pos == _IO_pos_BAD)
{
#ifdef EIO
diff --git a/libio/iofwrite.c b/libio/iofwrite.c
index 7767a94e8a..542fa77f2e 100644
--- a/libio/iofwrite.c
+++ b/libio/iofwrite.c
@@ -36,10 +36,10 @@ _IO_fwrite (buf, size, count, fp)
CHECK_FILE (fp, 0);
if (request == 0)
return 0;
- __libc_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
_IO_flockfile (fp);
written = _IO_sputn (fp, (const char *) buf, request);
- __libc_cleanup_region_end (1);
+ _IO_cleanup_region_end (1);
/* Many traditional implementations return 0 if size==0 && count > 0,
but ANSI seems to require us to return count in this case. */
if (written == request)
diff --git a/libio/iogetdelim.c b/libio/iogetdelim.c
index d41bb6b2a9..b1662e4c90 100644
--- a/libio/iogetdelim.c
+++ b/libio/iogetdelim.c
@@ -52,7 +52,7 @@ _IO_getdelim (lineptr, n, delimiter, fp)
return -1;
}
CHECK_FILE (fp, -1);
- __libc_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
_IO_flockfile (fp);
if (_IO_ferror_unlocked (fp))
{
@@ -114,7 +114,7 @@ _IO_getdelim (lineptr, n, delimiter, fp)
result = cur_len;
unlock_return:
- __libc_cleanup_region_end (1);
+ _IO_cleanup_region_end (1);
return result;
}
diff --git a/libio/iogets.c b/libio/iogets.c
index b5611f29da..0e87504107 100644
--- a/libio/iogets.c
+++ b/libio/iogets.c
@@ -33,8 +33,8 @@ _IO_gets (buf)
int ch;
char *retval;
- __libc_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
- _IO_stdin);
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
+ _IO_stdin);
_IO_flockfile (_IO_stdin);