public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libfortran/42420]  New: libgfortran fails to open large files on MINGW32
@ 2009-12-18  0:24 jpr at csc dot fi
  2009-12-18  0:35 ` [Bug libfortran/42420] " jpr at csc dot fi
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: jpr at csc dot fi @ 2009-12-18  0:24 UTC (permalink / raw)
  To: gcc-bugs

Program bigfile
  open( 1,file='bigfile',position='append')
End program bigfile

fails if size of the bigfile is > 2GB. This is due to
the struct stat holding 32 bit st_size field in this
platform. The following fix worked for me
(libgfortran/io/...)

Index: unix.c
===================================================================
--- unix.c      (revision 155325)
+++ unix.c      (working copy)
@@ -781,7 +781,11 @@
 static stream *
 fd_to_stream (int fd, int prot)
 {
+#ifdef __MINGW32__
+  struct _stati64 statbuf;
+#else
   struct stat statbuf;
+#endif
   unix_stream *s;

   s = get_mem (sizeof (unix_stream));
@@ -795,7 +799,11 @@

   /* Get the current length of the file. */

+#ifdef __MINGW32__
   fstat (fd, &statbuf);
+#else
+  _fstati64 (fd, &statbuf);
+#endif

   if (lseek (fd, 0, SEEK_CUR) == (gfc_offset) -1)
     s->file_length = -1;

Juha


-- 
           Summary: libgfortran fails to open large files on MINGW32
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libfortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jpr at csc dot fi


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42420


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libfortran/42420] libgfortran fails to open large files on MINGW32
  2009-12-18  0:24 [Bug libfortran/42420] New: libgfortran fails to open large files on MINGW32 jpr at csc dot fi
@ 2009-12-18  0:35 ` jpr at csc dot fi
  2009-12-18  0:58 ` kargl at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jpr at csc dot fi @ 2009-12-18  0:35 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from jpr at csc dot fi  2009-12-18 00:35 -------
or rather this....


Index: unix.c
===================================================================
--- unix.c      (revision 155325)
+++ unix.c      (working copy)
@@ -781,7 +781,11 @@
 static stream *
 fd_to_stream (int fd, int prot)
 {
+#ifdef __MINGW32__
+  struct _stati64 statbuf;
+#else
   struct stat statbuf;
+#endif
   unix_stream *s;

   s = get_mem (sizeof (unix_stream));
@@ -795,7 +799,11 @@

   /* Get the current length of the file. */

+#ifdef __MINGW32__
+  _fstati64 (fd, &statbuf);
+#else
   fstat (fd, &statbuf);
+#endif

   if (lseek (fd, 0, SEEK_CUR) == (gfc_offset) -1)
     s->file_length = -1;


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42420


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libfortran/42420] libgfortran fails to open large files on MINGW32
  2009-12-18  0:24 [Bug libfortran/42420] New: libgfortran fails to open large files on MINGW32 jpr at csc dot fi
  2009-12-18  0:35 ` [Bug libfortran/42420] " jpr at csc dot fi
@ 2009-12-18  0:58 ` kargl at gcc dot gnu dot org
  2009-12-18  5:43 ` jpr at csc dot fi
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: kargl at gcc dot gnu dot org @ 2009-12-18  0:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from kargl at gcc dot gnu dot org  2009-12-18 00:57 -------
This should have already been fixed by

2009-12-04  Janne Blomqvist  <jb@gcc.gnu.org>

        PR libfortran/40812
        * libgfortran.h: typedef gfc_offset differently for MinGW.
        * io/unix.h (struct stream): Change function pointers to use
        gfc_offset instead of off_t.
        (sseek): Change prototype to use gfc_offset instead of off_t.
        (stell): Likewise.
        (struncate): Likewise.
        * io/unix.c: Redefine lseek() for mingw.
        (raw_seek): Use gfc_offset instead of off_t.
        (raw_tell): Likewise.
        (buf_seek): Likewise.
        (buf_tell): Likewise.
        (buf_truncate): Likewise.
        (mem_seek): Likewise.
        (mem_tell): Likewise.
        (mem_truncate): Likewise.
        (fd_to_stream): Likewise.
        (file_length): Likewise.
        (raw_truncate): Use gfc_offset instead of off_t, add large file
        capable implementation for MinGW.

Please update to a newer version of gfortran and see if it fixes
your problem.


-- 

kargl at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kargl at gcc dot gnu dot org
             Status|UNCONFIRMED                 |WAITING
           Priority|P3                          |P4


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42420


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libfortran/42420] libgfortran fails to open large files on MINGW32
  2009-12-18  0:24 [Bug libfortran/42420] New: libgfortran fails to open large files on MINGW32 jpr at csc dot fi
  2009-12-18  0:35 ` [Bug libfortran/42420] " jpr at csc dot fi
  2009-12-18  0:58 ` kargl at gcc dot gnu dot org
@ 2009-12-18  5:43 ` jpr at csc dot fi
  2009-12-18  6:43 ` kargl at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jpr at csc dot fi @ 2009-12-18  5:43 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from jpr at csc dot fi  2009-12-18 05:43 -------
No, 

this was the trunk from yesterday. Some wrinkeles seem to remain...

Juha


-- 

jpr at csc dot fi changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |UNCONFIRMED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42420


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libfortran/42420] libgfortran fails to open large files on MINGW32
  2009-12-18  0:24 [Bug libfortran/42420] New: libgfortran fails to open large files on MINGW32 jpr at csc dot fi
                   ` (2 preceding siblings ...)
  2009-12-18  5:43 ` jpr at csc dot fi
@ 2009-12-18  6:43 ` kargl at gcc dot gnu dot org
  2009-12-18  8:51 ` burnus at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: kargl at gcc dot gnu dot org @ 2009-12-18  6:43 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from kargl at gcc dot gnu dot org  2009-12-18 06:43 -------
(In reply to comment #3)
> No, 
> 
> this was the trunk from yesterday. Some wrinkeles seem to remain...
> 

You should have included this information in your
original bug report.  I won't have wasted my time
looking up Janne's commit message and replying to
your bug report.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42420


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libfortran/42420] libgfortran fails to open large files on MINGW32
  2009-12-18  0:24 [Bug libfortran/42420] New: libgfortran fails to open large files on MINGW32 jpr at csc dot fi
                   ` (3 preceding siblings ...)
  2009-12-18  6:43 ` kargl at gcc dot gnu dot org
@ 2009-12-18  8:51 ` burnus at gcc dot gnu dot org
  2009-12-20 10:23 ` jb at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-12-18  8:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from burnus at gcc dot gnu dot org  2009-12-18 08:51 -------
Confirm. The bug report looks valid and the patch sensible. Cf. for
fstat/fstati64 the page:
http://msdn.microsoft.com/en-us/library/aa246905%28VS.60%29.aspx

Kai agrees that the patch looks OK and he checked that _fstati64 exists both
for MinGW(.org) and MinGW64.


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jb at gcc dot gnu dot org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2009-12-18 08:51:37
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42420


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libfortran/42420] libgfortran fails to open large files on MINGW32
  2009-12-18  0:24 [Bug libfortran/42420] New: libgfortran fails to open large files on MINGW32 jpr at csc dot fi
                   ` (4 preceding siblings ...)
  2009-12-18  8:51 ` burnus at gcc dot gnu dot org
@ 2009-12-20 10:23 ` jb at gcc dot gnu dot org
  2010-01-02 21:39 ` jb at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jb at gcc dot gnu dot org @ 2009-12-20 10:23 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from jb at gcc dot gnu dot org  2009-12-20 10:23 -------
As such the patch seems ok, however I'd prefer to avoid cluttering up the logic
with ifdefs, and secondly, we should stick to one kind of stat struct
everywhere for consistency's sake. E.g. something like

diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c
index 07aa4d9..531f6ec 100644
--- a/libgfortran/io/unix.c
+++ b/libgfortran/io/unix.c
@@ -42,13 +42,17 @@ see the files COPYING3 and COPYING.RUNTIME respectively. 
If

 /* For mingw, we don't identify files by their inode number, but by a
    64-bit identifier created from a BY_HANDLE_FILE_INFORMATION. */
-#if defined(__MINGW32__) && !HAVE_WORKING_STAT
+#ifdef __MINGW32__

 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>

 #define lseek _lseeki64
+#define fstat _fstati64
+#define stat _stati64
+typedef struct _stati64 gfstat_t

+#ifndef HAVE_WORKING_STAT
 static uint64_t
 id_from_handle (HANDLE hFile)
 {
@@ -91,6 +95,9 @@ id_from_fd (const int fd)
 }

 #endif
+#else
+typedef struct stat gfstat_t
+#endif

 #ifndef PATH_MAX
 #define PATH_MAX 1024
@@ -781,7 +788,7 @@ open_internal (char *base, int length, gfc_offset offset)
 static stream *
 fd_to_stream (int fd, int prot)
 {
-  struct stat statbuf;
+  gfstat_t statbuf;
   unix_stream *s;

   s = get_mem (sizeof (unix_stream));
@@ -1220,9 +1227,9 @@ int
 compare_file_filename (gfc_unit *u, const char *name, int len)
 {
   char path[PATH_MAX + 1];
-  struct stat st1;
+  gfstat_t st1;
 #ifdef HAVE_WORKING_STAT
-  struct stat st2;
+  gfstat_t st2;
 #else
 # ifdef __MINGW32__
   uint64_t id1, id2;
@@ -1261,7 +1268,7 @@ compare_file_filename (gfc_unit *u, const char *name, int 


 #ifdef HAVE_WORKING_STAT
-# define FIND_FILE0_DECL struct stat *st
+# define FIND_FILE0_DECL gfstat_t *st
 # define FIND_FILE0_ARGS st
 #else
 # define FIND_FILE0_DECL uint64_t id, const char *file, gfc_charlen_type
file_l
@@ -1318,7 +1325,7 @@ gfc_unit *
 find_file (const char *file, gfc_charlen_type file_len)
 {
   char path[PATH_MAX + 1];
-  struct stat st[2];
+  gfstat_t st[2];
   gfc_unit *u;
 #if defined(__MINGW32__) && !HAVE_WORKING_STAT
   uint64_t id = 0ULL;
@@ -1455,7 +1462,7 @@ int
 file_exists (const char *file, gfc_charlen_type file_len)
 {
   char path[PATH_MAX + 1];
-  struct stat statbuf;
+  gfstat_t statbuf;

   if (unpack_filename (path, file, file_len))
     return 0;
@@ -1478,7 +1485,7 @@ const char *
 inquire_sequential (const char *string, int len)
 {
   char path[PATH_MAX + 1];
-  struct stat statbuf;
+  gfstat_t statbuf;

   if (string == NULL ||
       unpack_filename (path, string, len) || stat (path, &statbuf) < 0)
@@ -1502,7 +1509,7 @@ const char *
 inquire_direct (const char *string, int len)
 {
   char path[PATH_MAX + 1];
-  struct stat statbuf;
+  gfstat_t statbuf;

   if (string == NULL ||
       unpack_filename (path, string, len) || stat (path, &statbuf) < 0)
@@ -1526,7 +1533,7 @@ const char *
 inquire_formatted (const char *string, int len)
 {
   char path[PATH_MAX + 1];
-  struct stat statbuf;
+  gfstat_t statbuf;

   if (string == NULL ||
       unpack_filename (path, string, len) || stat (path, &statbuf) < 0)


This is completely untested.

And, as a general observation, if mingw is ever going to be a tier-1 target for
gfortran, we need one or more maintainers who use and care about gfortran on
windows. So far all the maintainers are, to the best of my knowledge, Linux or
FreeBSD users, and any mingw support is, at best, an afterthought. Same goes
for OS X, FWIW.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42420


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libfortran/42420] libgfortran fails to open large files on MINGW32
  2009-12-18  0:24 [Bug libfortran/42420] New: libgfortran fails to open large files on MINGW32 jpr at csc dot fi
                   ` (5 preceding siblings ...)
  2009-12-20 10:23 ` jb at gcc dot gnu dot org
@ 2010-01-02 21:39 ` jb at gcc dot gnu dot org
  2010-01-03 18:09 ` jb at gcc dot gnu dot org
  2010-01-05 19:14 ` jb at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: jb at gcc dot gnu dot org @ 2010-01-02 21:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from jb at gcc dot gnu dot org  2010-01-02 21:39 -------
Patch: http://gcc.gnu.org/ml/gcc-patches/2010-01/msg00083.html


-- 

jb at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |jb at gcc dot gnu dot org
                   |dot org                     |
                URL|                            |http://gcc.gnu.org/ml/gcc-
                   |                            |patches/2010-
                   |                            |01/msg00083.html
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2009-12-18 08:51:37         |2010-01-02 21:39:09
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42420


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libfortran/42420] libgfortran fails to open large files on MINGW32
  2009-12-18  0:24 [Bug libfortran/42420] New: libgfortran fails to open large files on MINGW32 jpr at csc dot fi
                   ` (6 preceding siblings ...)
  2010-01-02 21:39 ` jb at gcc dot gnu dot org
@ 2010-01-03 18:09 ` jb at gcc dot gnu dot org
  2010-01-05 19:14 ` jb at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: jb at gcc dot gnu dot org @ 2010-01-03 18:09 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from jb at gcc dot gnu dot org  2010-01-03 18:09 -------
Subject: Bug 42420

Author: jb
Date: Sun Jan  3 18:09:37 2010
New Revision: 155593

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=155593
Log:
PR libfortran/42420 Large file capable stat for MingW

Modified:
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/io/unix.c


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42420


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libfortran/42420] libgfortran fails to open large files on MINGW32
  2009-12-18  0:24 [Bug libfortran/42420] New: libgfortran fails to open large files on MINGW32 jpr at csc dot fi
                   ` (7 preceding siblings ...)
  2010-01-03 18:09 ` jb at gcc dot gnu dot org
@ 2010-01-05 19:14 ` jb at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: jb at gcc dot gnu dot org @ 2010-01-05 19:14 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from jb at gcc dot gnu dot org  2010-01-05 19:14 -------
Closing as fixed.


-- 

jb at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42420


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2010-01-05 19:14 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-18  0:24 [Bug libfortran/42420] New: libgfortran fails to open large files on MINGW32 jpr at csc dot fi
2009-12-18  0:35 ` [Bug libfortran/42420] " jpr at csc dot fi
2009-12-18  0:58 ` kargl at gcc dot gnu dot org
2009-12-18  5:43 ` jpr at csc dot fi
2009-12-18  6:43 ` kargl at gcc dot gnu dot org
2009-12-18  8:51 ` burnus at gcc dot gnu dot org
2009-12-20 10:23 ` jb at gcc dot gnu dot org
2010-01-02 21:39 ` jb at gcc dot gnu dot org
2010-01-03 18:09 ` jb at gcc dot gnu dot org
2010-01-05 19:14 ` jb at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).