Commit 5133e4b9 by Thomas Koenig Committed by Thomas Koenig

io/unix.c: Add member special_file to type unix_stream.

2005-07-12  Thomas Koenig  <Thomas.Koenig@online.de>

	io/unix.c:  Add member special_file to type unix_stream.
	(fd_truncate):  Don't call ftruncate or chsize if
	s refers to a special file.
	(fd_to_stream):  initialize s->special_file.

2005-07-12  Thomas Koenig  <Thomas.Koenig@online.de>

	gfortran.dg/dev_null.f90:  Remove targets.

From-SVN: r101937
parent 04be5ce5
2005-07-11 Thomas Koenig <Thomas.Koenig@online.de>
gfortran.dg/dev_null.f90: Remove targets.
2005-07-12 Andrew Pinski <pinskia@physics.uc.edu> 2005-07-12 Andrew Pinski <pinskia@physics.uc.edu>
PR tree-opt/22335 PR tree-opt/22335
......
! { dg-do run { target *-*-linux* *-*-solaris* } } ! { dg-do run }
! This test currently only runs on systems where using ftruncate on ! This test currently only runs on systems where using ftruncate on
! /dev/null fails (errno set to EINVAL). See PR 21593 for details. ! /dev/null fails (errno set to EINVAL). See PR 21593 for details.
! !
......
2005-07-12 Thomas Koenig <Thomas.Koenig@online.de>
io/unix.c: Add member special_file to type unix_stream.
(fd_truncate): Don't call ftruncate or chsize if
s refers to a special file.
(fd_to_stream): initialize s->special_file.
2005-07-11 David Edelsohn <edelsohn@gnu.org> 2005-07-11 David Edelsohn <edelsohn@gnu.org>
PR libgfortran/22412 PR libgfortran/22412
......
...@@ -138,6 +138,8 @@ typedef struct ...@@ -138,6 +138,8 @@ typedef struct
int prot; int prot;
int ndirty; /* Dirty bytes starting at dirty_offset */ int ndirty; /* Dirty bytes starting at dirty_offset */
int special_file; /* =1 if the fd refers to a special file */
unsigned unbuffered:1, mmaped:1; unsigned unbuffered:1, mmaped:1;
char small_buffer[BUFFER_SIZE]; char small_buffer[BUFFER_SIZE];
...@@ -509,13 +511,14 @@ fd_truncate (unix_stream * s) ...@@ -509,13 +511,14 @@ fd_truncate (unix_stream * s)
return FAILURE; return FAILURE;
/* non-seekable files, like terminals and fifo's fail the lseek. /* non-seekable files, like terminals and fifo's fail the lseek.
the fd is a regular file at this point */ Using ftruncate on a seekable special file (like /dev/null)
is undefined, so we treat it as if the ftruncate failed.
*/
#ifdef HAVE_FTRUNCATE #ifdef HAVE_FTRUNCATE
if (ftruncate (s->fd, s->logical_offset)) if (s->special_file || ftruncate (s->fd, s->logical_offset))
#else #else
#ifdef HAVE_CHSIZE #ifdef HAVE_CHSIZE
if (chsize (s->fd, s->logical_offset)) if (s->special_file || chsize (s->fd, s->logical_offset))
#endif #endif
#endif #endif
{ {
...@@ -915,6 +918,7 @@ fd_to_stream (int fd, int prot, int avoid_mmap) ...@@ -915,6 +918,7 @@ fd_to_stream (int fd, int prot, int avoid_mmap)
fstat (fd, &statbuf); fstat (fd, &statbuf);
s->file_length = S_ISREG (statbuf.st_mode) ? statbuf.st_size : -1; s->file_length = S_ISREG (statbuf.st_mode) ? statbuf.st_size : -1;
s->special_file = !S_ISREG (statbuf.st_mode);
#if HAVE_MMAP #if HAVE_MMAP
if (avoid_mmap) if (avoid_mmap)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment