public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, libgFortran] Fix MinGW64 compile warning
@ 2011-03-25 17:14 Tobias Burnus
  2011-03-26  9:27 ` Janne Blomqvist
  0 siblings, 1 reply; 4+ messages in thread
From: Tobias Burnus @ 2011-03-25 17:14 UTC (permalink / raw)
  To: gcc patches, gfortran

[-- Attachment #1: Type: text/plain, Size: 502 bytes --]

The attached patch fixes a compiler warning on MinGW64

../../../../../build/gcc/src/libgfortran/io/unix.c:51:0: warning: 
"lseek" redefined [enabled by default]

which is due to MinGW64 now supporting LFS. (Seemingly, using a similar 
define as libgfortran.) The following patch should fix the issue.

Thanks for Kai for suggestions and testing the patch on MinGW64. The 
goal is that it also works with older MinGW64 and with 32bit MinGW, but 
that has not been tested ...

OK for the trunk?

Tobias

[-- Attachment #2: win-lfs.diff --]
[-- Type: text/x-patch, Size: 690 bytes --]

2011-03-25  Tobias Burnus  <burnus@net-b.de>

	* unix.c: Adapt stat defines now that MinGW64 supports LFS.

Index: libgfortran/io/unix.c
===================================================================
--- libgfortran/io/unix.c	(Revision 171454)
+++ libgfortran/io/unix.c	(Arbeitskopie)
@@ -48,11 +48,17 @@
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 
+#if !defined(_FILE_OFFSET_BITS) || _FILE_OFFSET_BITS != 64
+#undef lseek
 #define lseek _lseeki64
+#undef fstat
 #define fstat _fstati64
+#undef stat
 #define stat _stati64
-typedef struct _stati64 gfstat_t;
+#endif
 
+typedef struct stat gfstat_t;
+
 #ifndef HAVE_WORKING_STAT
 static uint64_t
 id_from_handle (HANDLE hFile)

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

* Re: [Patch, libgFortran] Fix MinGW64 compile warning
  2011-03-25 17:14 [Patch, libgFortran] Fix MinGW64 compile warning Tobias Burnus
@ 2011-03-26  9:27 ` Janne Blomqvist
  2011-04-03 15:11   ` Tobias Burnus
  0 siblings, 1 reply; 4+ messages in thread
From: Janne Blomqvist @ 2011-03-26  9:27 UTC (permalink / raw)
  To: Tobias Burnus; +Cc: gcc patches, gfortran

On Fri, Mar 25, 2011 at 19:10, Tobias Burnus <burnus@net-b.de> wrote:
> The attached patch fixes a compiler warning on MinGW64
>
> ../../../../../build/gcc/src/libgfortran/io/unix.c:51:0: warning: "lseek"
> redefined [enabled by default]
>
> which is due to MinGW64 now supporting LFS. (Seemingly, using a similar
> define as libgfortran.) The following patch should fix the issue.
>
> Thanks for Kai for suggestions and testing the patch on MinGW64. The goal is
> that it also works with older MinGW64 and with 32bit MinGW, but that has not
> been tested ...
>
> OK for the trunk?

Since the reason for adding the gfstat_t typedef was that on mingw we
needed to use struct _stati64 instead of struct stat, and that
justification now seems to be gone with this patch, please also remove
gfstat_t and just use struct stat everywhere.

Otherwise Ok.

-- 
Janne Blomqvist

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

* Re: [Patch, libgFortran] Fix MinGW64 compile warning
  2011-03-26  9:27 ` Janne Blomqvist
@ 2011-04-03 15:11   ` Tobias Burnus
  2011-04-03 15:26     ` Janne Blomqvist
  0 siblings, 1 reply; 4+ messages in thread
From: Tobias Burnus @ 2011-04-03 15:11 UTC (permalink / raw)
  To: Janne Blomqvist; +Cc: gcc patches, gfortran

[-- Attachment #1: Type: text/plain, Size: 357 bytes --]

Janne Blomqvist wrote:
> Since the reason for adding the gfstat_t typedef was that on mingw we
> needed to use struct _stati64 instead of struct stat, and that
> justification now seems to be gone with this patch, please also remove
> gfstat_t and just use struct stat everywhere.

How about the attached patch? (Build & regtested on x86-64-linux.)

Tobias

[-- Attachment #2: win-lfs-2.diff --]
[-- Type: text/x-patch, Size: 3146 bytes --]

2011-04-04  Tobias Burnus  <burnus@net-b.de>

	* unix.c: Adapt stat DEFINEs since MinGW64 supports LFS.
	(fallback_access, open_internal4, compare_file_filename,
	find_file, file_size, inquire_sequential, inquire_direct,
	inquire_formatted): Use "struct stat" instead of gfstat_t.

diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c
index edccdd6..d14d2b4 100644
--- a/libgfortran/io/unix.c
+++ b/libgfortran/io/unix.c
@@ -48,10 +48,14 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 
+#if !defined(_FILE_OFFSET_BITS) || _FILE_OFFSET_BITS != 64
+#undef lseek
 #define lseek _lseeki64
+#undef fstat
 #define fstat _fstati64
+#undef stat
 #define stat _stati64
-typedef struct _stati64 gfstat_t;
+#endif
 
 #ifndef HAVE_WORKING_STAT
 static uint64_t
@@ -96,9 +100,6 @@ id_from_fd (const int fd)
 }
 
 #endif
-
-#else
-typedef struct stat gfstat_t;
 #endif
 
 #ifndef PATH_MAX
@@ -156,7 +157,7 @@ fallback_access (const char *path, int mode)
 
   if (mode == F_OK)
     {
-      gfstat_t st;
+      struct stat st;
       return stat (path, &st);
     }
 
@@ -924,7 +925,7 @@ open_internal4 (char *base, int length, gfc_offset offset)
 static stream *
 fd_to_stream (int fd)
 {
-  gfstat_t statbuf;
+  struct stat statbuf;
   unix_stream *s;
 
   s = get_mem (sizeof (unix_stream));
@@ -1405,7 +1406,7 @@ int
 compare_file_filename (gfc_unit *u, const char *name, int len)
 {
   char path[PATH_MAX + 1];
-  gfstat_t st;
+  struct stat st;
 #ifdef HAVE_WORKING_STAT
   unix_stream *s;
 #else
@@ -1446,7 +1447,7 @@ compare_file_filename (gfc_unit *u, const char *name, int len)
 
 
 #ifdef HAVE_WORKING_STAT
-# define FIND_FILE0_DECL gfstat_t *st
+# define FIND_FILE0_DECL struct stat *st
 # define FIND_FILE0_ARGS st
 #else
 # define FIND_FILE0_DECL uint64_t id, const char *file, gfc_charlen_type file_len
@@ -1505,7 +1506,7 @@ gfc_unit *
 find_file (const char *file, gfc_charlen_type file_len)
 {
   char path[PATH_MAX + 1];
-  gfstat_t st[1];
+  struct stat st[1];
   gfc_unit *u;
 #if defined(__MINGW32__) && !HAVE_WORKING_STAT
   uint64_t id = 0ULL;
@@ -1656,7 +1657,7 @@ GFC_IO_INT
 file_size (const char *file, gfc_charlen_type file_len)
 {
   char path[PATH_MAX + 1];
-  gfstat_t statbuf;
+  struct stat statbuf;
 
   if (unpack_filename (path, file, file_len))
     return -1;
@@ -1677,7 +1678,7 @@ const char *
 inquire_sequential (const char *string, int len)
 {
   char path[PATH_MAX + 1];
-  gfstat_t statbuf;
+  struct stat statbuf;
 
   if (string == NULL ||
       unpack_filename (path, string, len) || stat (path, &statbuf) < 0)
@@ -1701,7 +1702,7 @@ const char *
 inquire_direct (const char *string, int len)
 {
   char path[PATH_MAX + 1];
-  gfstat_t statbuf;
+  struct stat statbuf;
 
   if (string == NULL ||
       unpack_filename (path, string, len) || stat (path, &statbuf) < 0)
@@ -1725,7 +1726,7 @@ const char *
 inquire_formatted (const char *string, int len)
 {
   char path[PATH_MAX + 1];
-  gfstat_t statbuf;
+  struct stat statbuf;
 
   if (string == NULL ||
       unpack_filename (path, string, len) || stat (path, &statbuf) < 0)

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

* Re: [Patch, libgFortran] Fix MinGW64 compile warning
  2011-04-03 15:11   ` Tobias Burnus
@ 2011-04-03 15:26     ` Janne Blomqvist
  0 siblings, 0 replies; 4+ messages in thread
From: Janne Blomqvist @ 2011-04-03 15:26 UTC (permalink / raw)
  To: Tobias Burnus; +Cc: gcc patches, gfortran

On Sun, Apr 3, 2011 at 18:11, Tobias Burnus <burnus@net-b.de> wrote:
> Janne Blomqvist wrote:
>>
>> Since the reason for adding the gfstat_t typedef was that on mingw we
>> needed to use struct _stati64 instead of struct stat, and that
>> justification now seems to be gone with this patch, please also remove
>> gfstat_t and just use struct stat everywhere.
>
> How about the attached patch? (Build & regtested on x86-64-linux.)

Looks fine; ok for trunk. Thanks for fixing this.




-- 
Janne Blomqvist

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

end of thread, other threads:[~2011-04-03 15:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-25 17:14 [Patch, libgFortran] Fix MinGW64 compile warning Tobias Burnus
2011-03-26  9:27 ` Janne Blomqvist
2011-04-03 15:11   ` Tobias Burnus
2011-04-03 15:26     ` Janne Blomqvist

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).