Skip to contentSkip to conversation

fix 32 bit compilation on MinGW-w64

PATCH In review Andrey Borzenkov 2 participants 6 messages Dec 29, 2013 – Jan 18, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix 32 bit compilation on MinGW-w64

Use _FILE_OFFSET_BITS macro to distinguish between native MinGW and 32 bit under MinGW-64. The latter does not require fseeko/ftello redefinition which it already does in case of _FILE_OFFSET_BITS=64.

---
 include/grub/osdep/hostfile_windows.h | 3 +++
 1 file changed, 3 insertions(+)
include/grub/osdep/hostfile_windows.h +3 -0
index 36615b2..79efcfa 100644
@@ -69,8 +69,11 @@ enum grub_util_fd_open_flags_t
 
 #if defined (__MINGW32__) && !defined (__MINGW64__)
 
+/* 32 bit on MinGW-64 already redefines them if _FILE_OFFSET_BITS=64 */
+#if !defined(_FILE_OFFSET_BITS)
 #define fseeko fseeko64
 #define ftello ftello64
+#endif
 
 #endif
 
Signature · 1 line
tg: (093dec7..) u/mingw/fseeko (depends on: master)
#1 lore raw

Go ahead

Quoted 25 lines · Andrey Borzenkov

Use _FILE_OFFSET_BITS macro to distinguish between native MinGW and 32 bit under MinGW-64. The latter does not require fseeko/ftello redefinition which it already does in case of _FILE_OFFSET_BITS=64.

---
 include/grub/osdep/hostfile_windows.h | 3 +++
 1 file changed, 3 insertions(+)
include/grub/osdep/hostfile_windows.h +3 -0
index 36615b2..79efcfa 100644
@@ -69,8 +69,11 @@ enum grub_util_fd_open_flags_t
 
 #if defined (__MINGW32__) && !defined (__MINGW64__)
 
+/* 32 bit on MinGW-64 already redefines them if _FILE_OFFSET_BITS=64 */
+#if !defined(_FILE_OFFSET_BITS)
 #define fseeko fseeko64
 #define ftello ftello64
+#endif
 
 #endif
 
#2 lore raw

PATCH 1/1 Use _W64 to detect MinGW W64-32 instead of _FILE_OFFSET_BITS

In reply to Andrey Borzenkov

In 94cee4a4c201bb506377b2c26e072eee8cb19d6f I overlooked that config.h unconditionally sets _FILE_OFFSET_BITS, so it cannot be used to detect MinGW W64 environment. It looks like Emacs folks already found solution; instead of _FILE_OFFSET_BITS use _W64 as suggested in
http://lists.gnu.org/archive/html/emacs-devel/2013-03/msg00723.html

---
 include/grub/osdep/hostfile_windows.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/grub/osdep/hostfile_windows.h +2 -2
index 79efcfa..bf6451b 100644
@@ -69,8 +69,8 @@ enum grub_util_fd_open_flags_t
 
 #if defined (__MINGW32__) && !defined (__MINGW64__)
 
-/* 32 bit on MinGW-64 already redefines them if _FILE_OFFSET_BITS=64 */
-#if !defined(_FILE_OFFSET_BITS)
+/* 32 bit on Mingw-w64 already redefines them if _FILE_OFFSET_BITS=64 */
+#ifndef _W64
 #define fseeko fseeko64
 #define ftello ftello64
 #endif
Signature · 1 line
tg: (0776112..) u/mingw/use-_w64-for-mingw-w64 (depends on: master)
#3 lore raw

Re: [PATCH] Use _W64 to detect MinGW W64-32 instead of _FILE_OFFSET_BITS

Quoted 1 line · Andrey Borzenkov

+/* 32 bit on Mingw-w64 already redefines them if _FILE_OFFSET_BITS=64 */

Do you mean 64-bit ?

#4 lore raw

Re: [PATCH] Use _W64 to detect MinGW W64-32 instead of _FILE_OFFSET_BITS

В Sat, 18 Jan 2014 16:22:21 +0100
Vladimir 'φ-coder/phcoder' Serbinenko <[email protected]> пишет:

Quoted 4 lines · Andrey Borzenkov
Quoted 1 line

+/* 32 bit on Mingw-w64 already redefines them if _FILE_OFFSET_BITS=64 */

Do you mean 64-bit ?

No, I mean exactly 32 bit. 'Mingw w64" is project (toolchain) name; it can produce both 32 bit and 64 bit programs. 64 bit is already covered by __MINGW64__, but in 32 bit case we need to differentiate between native MinGW and Mingw w64 building for 32 bit.

#5 lore raw

Re: [PATCH] Use _W64 to detect MinGW W64-32 instead of _FILE_OFFSET_BITS

Quoted 4 lines · Andrey Borzenkov

В Sat, 18 Jan 2014 16:22:21 +0100
Vladimir 'φ-coder/phcoder' Serbinenko <[email protected]> пишет:

Quoted 1 line · Andrey Borzenkov
Quoted 9 lines
Quoted 3 lines
Quoted 1 line

+/* 32 bit on Mingw-w64 already redefines them if _FILE_OFFSET_BITS=64 */

Do you mean 64-bit ?

No, I mean exactly 32 bit. 'Mingw w64" is project (toolchain) name; it can produce both 32 bit and 64 bit programs. 64 bit is already covered by __MINGW64__, but in 32 bit case we need to differentiate between native MinGW and Mingw w64 building for 32 bit.

I see.
Go ahead.

Quoted 7 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel