Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Fix using gnu print on mingw
@ 2021-10-25  7:52 Orgad Shaneh via Gdb-patches
  2021-10-25 15:04 ` Christian Biesinger via Gdb-patches
  0 siblings, 1 reply; 4+ messages in thread
From: Orgad Shaneh via Gdb-patches @ 2021-10-25  7:52 UTC (permalink / raw)
  To: gdb-patches; +Cc: Orgad Shaneh

---
 bfd/bfd-in.h                | 2 +-
 bfd/bfd-in2.h               | 2 +-
 gdbsupport/format.h         | 6 +++++-
 gnulib/import/inttypes.in.h | 8 ++++----
 4 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h
index 286afc607a3..6bb9622a514 100644
--- a/bfd/bfd-in.h
+++ b/bfd/bfd-in.h
@@ -131,7 +131,7 @@ typedef BFD_HOST_U_64_BIT symvalue;
 
 #if BFD_HOST_64BIT_LONG
 #define BFD_VMA_FMT "l"
-#elif defined (__MSVCRT__)
+#elif defined(__MSVCRT__) && !defined( __USE_MINGW_ANSI_STDIO)
 #define BFD_VMA_FMT "I64"
 #else
 #define BFD_VMA_FMT "ll"
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 669f250d0e5..dd74c4c8eb3 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -138,7 +138,7 @@ typedef BFD_HOST_U_64_BIT symvalue;
 
 #if BFD_HOST_64BIT_LONG
 #define BFD_VMA_FMT "l"
-#elif defined (__MSVCRT__)
+#elif defined (__MSVCRT__) && !defined(__USE_MINGW_ANSI_STDIO)
 #define BFD_VMA_FMT "I64"
 #else
 #define BFD_VMA_FMT "ll"
diff --git a/gdbsupport/format.h b/gdbsupport/format.h
index 921fca5e04d..75d12ae531a 100644
--- a/gdbsupport/format.h
+++ b/gdbsupport/format.h
@@ -23,7 +23,11 @@
 #include "gdbsupport/gdb_string_view.h"
 
 #if defined(__MINGW32__) && !defined(PRINTF_HAS_LONG_LONG)
-# define USE_PRINTF_I64 1
+# if !defined(__USE_MINGW_ANSI_STDIO)
+#  define USE_PRINTF_I64 1
+# else
+#  define USE_PRINTF_I64 0
+# endif
 # define PRINTF_HAS_LONG_LONG
 #else
 # define USE_PRINTF_I64 0
diff --git a/gnulib/import/inttypes.in.h b/gnulib/import/inttypes.in.h
index e9ee500e3e6..b1f1f7edd00 100644
--- a/gnulib/import/inttypes.in.h
+++ b/gnulib/import/inttypes.in.h
@@ -171,7 +171,7 @@
 #ifdef INT64_MAX
 # if (@APPLE_UNIVERSAL_BUILD@ ? defined _LP64 : @INT64_MAX_EQ_LONG_MAX@)
 #  define _PRI64_PREFIX "l"
-# elif defined _MSC_VER || defined __MINGW32__
+# elif (defined _MSC_VER || defined __MINGW32__) && !defined(__USE_MINGW_ANSI_STDIO)
 #  define _PRI64_PREFIX "I64"
 # elif LONG_MAX >> 30 == 1
 #  define _PRI64_PREFIX _LONG_LONG_FORMAT_PREFIX
@@ -186,7 +186,7 @@
 #ifdef UINT64_MAX
 # if (@APPLE_UNIVERSAL_BUILD@ ? defined _LP64 : @UINT64_MAX_EQ_ULONG_MAX@)
 #  define _PRIu64_PREFIX "l"
-# elif defined _MSC_VER || defined __MINGW32__
+# elif (defined _MSC_VER || defined __MINGW32__) && !defined(__USE_MINGW_ANSI_STDIO)
 #  define _PRIu64_PREFIX "I64"
 # elif ULONG_MAX >> 31 == 1
 #  define _PRIu64_PREFIX _LONG_LONG_FORMAT_PREFIX
@@ -583,7 +583,7 @@
 #ifdef INT64_MAX
 # if (@APPLE_UNIVERSAL_BUILD@ ? defined _LP64 : @INT64_MAX_EQ_LONG_MAX@)
 #  define _SCN64_PREFIX "l"
-# elif defined _MSC_VER || defined __MINGW32__
+# elif (defined _MSC_VER || defined __MINGW32__) && !defined(__USE_MINGW_ANSI_STDIO)
 #  define _SCN64_PREFIX "I64"
 # elif LONG_MAX >> 30 == 1
 #  define _SCN64_PREFIX _LONG_LONG_FORMAT_PREFIX
@@ -598,7 +598,7 @@
 #ifdef UINT64_MAX
 # if (@APPLE_UNIVERSAL_BUILD@ ? defined _LP64 : @UINT64_MAX_EQ_ULONG_MAX@)
 #  define _SCNu64_PREFIX "l"
-# elif defined _MSC_VER || defined __MINGW32__
+# elif (defined _MSC_VER || defined __MINGW32__) && !defined(__USE_MINGW_ANSI_STDIO)
 #  define _SCNu64_PREFIX "I64"
 # elif ULONG_MAX >> 31 == 1
 #  define _SCNu64_PREFIX _LONG_LONG_FORMAT_PREFIX
-- 
2.25.1


^ permalink raw reply	[flat|nested] 4+ messages in thread
* [PATCH] Fix using gnu print on mingw
@ 2021-10-25 15:42 Orgad Shaneh via Gdb-patches
  0 siblings, 0 replies; 4+ messages in thread
From: Orgad Shaneh via Gdb-patches @ 2021-10-25 15:42 UTC (permalink / raw)
  To: gdb-patches; +Cc: Orgad Shaneh

MinGW (both 32 and 64) uses (and defines) MSVCRT by default, but it has
2 working modes. If __USE_MINGW_ANSI_STDIO is defined as 1 (this is the
case for C++11, or when _GNU_SOURCE is defined, or some other defines),
then modifiers like %ll ARE supported. If it is 0, then they're not.
---
 bfd/bfd-in.h                | 2 +-
 bfd/bfd-in2.h               | 2 +-
 gdbsupport/format.h         | 6 +++++-
 gnulib/import/inttypes.in.h | 8 ++++----
 4 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h
index 286afc607a3..642e3918845 100644
--- a/bfd/bfd-in.h
+++ b/bfd/bfd-in.h
@@ -131,7 +131,7 @@ typedef BFD_HOST_U_64_BIT symvalue;
 
 #if BFD_HOST_64BIT_LONG
 #define BFD_VMA_FMT "l"
-#elif defined (__MSVCRT__)
+#elif defined(__MSVCRT__) && !__USE_MINGW_ANSI_STDIO
 #define BFD_VMA_FMT "I64"
 #else
 #define BFD_VMA_FMT "ll"
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 669f250d0e5..8fb2fafd1d1 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -138,7 +138,7 @@ typedef BFD_HOST_U_64_BIT symvalue;
 
 #if BFD_HOST_64BIT_LONG
 #define BFD_VMA_FMT "l"
-#elif defined (__MSVCRT__)
+#elif defined (__MSVCRT__) && !__USE_MINGW_ANSI_STDIO
 #define BFD_VMA_FMT "I64"
 #else
 #define BFD_VMA_FMT "ll"
diff --git a/gdbsupport/format.h b/gdbsupport/format.h
index 921fca5e04d..b7520fb63d6 100644
--- a/gdbsupport/format.h
+++ b/gdbsupport/format.h
@@ -23,7 +23,11 @@
 #include "gdbsupport/gdb_string_view.h"
 
 #if defined(__MINGW32__) && !defined(PRINTF_HAS_LONG_LONG)
-# define USE_PRINTF_I64 1
+# if !__USE_MINGW_ANSI_STDIO
+#  define USE_PRINTF_I64 1
+# else
+#  define USE_PRINTF_I64 0
+# endif
 # define PRINTF_HAS_LONG_LONG
 #else
 # define USE_PRINTF_I64 0
diff --git a/gnulib/import/inttypes.in.h b/gnulib/import/inttypes.in.h
index e9ee500e3e6..5fdf4663cc3 100644
--- a/gnulib/import/inttypes.in.h
+++ b/gnulib/import/inttypes.in.h
@@ -171,7 +171,7 @@
 #ifdef INT64_MAX
 # if (@APPLE_UNIVERSAL_BUILD@ ? defined _LP64 : @INT64_MAX_EQ_LONG_MAX@)
 #  define _PRI64_PREFIX "l"
-# elif defined _MSC_VER || defined __MINGW32__
+# elif (defined _MSC_VER || defined __MINGW32__) && !__USE_MINGW_ANSI_STDIO
 #  define _PRI64_PREFIX "I64"
 # elif LONG_MAX >> 30 == 1
 #  define _PRI64_PREFIX _LONG_LONG_FORMAT_PREFIX
@@ -186,7 +186,7 @@
 #ifdef UINT64_MAX
 # if (@APPLE_UNIVERSAL_BUILD@ ? defined _LP64 : @UINT64_MAX_EQ_ULONG_MAX@)
 #  define _PRIu64_PREFIX "l"
-# elif defined _MSC_VER || defined __MINGW32__
+# elif (defined _MSC_VER || defined __MINGW32__) && !__USE_MINGW_ANSI_STDIO
 #  define _PRIu64_PREFIX "I64"
 # elif ULONG_MAX >> 31 == 1
 #  define _PRIu64_PREFIX _LONG_LONG_FORMAT_PREFIX
@@ -583,7 +583,7 @@
 #ifdef INT64_MAX
 # if (@APPLE_UNIVERSAL_BUILD@ ? defined _LP64 : @INT64_MAX_EQ_LONG_MAX@)
 #  define _SCN64_PREFIX "l"
-# elif defined _MSC_VER || defined __MINGW32__
+# elif (defined _MSC_VER || defined __MINGW32__) && !__USE_MINGW_ANSI_STDIO
 #  define _SCN64_PREFIX "I64"
 # elif LONG_MAX >> 30 == 1
 #  define _SCN64_PREFIX _LONG_LONG_FORMAT_PREFIX
@@ -598,7 +598,7 @@
 #ifdef UINT64_MAX
 # if (@APPLE_UNIVERSAL_BUILD@ ? defined _LP64 : @UINT64_MAX_EQ_ULONG_MAX@)
 #  define _SCNu64_PREFIX "l"
-# elif defined _MSC_VER || defined __MINGW32__
+# elif (defined _MSC_VER || defined __MINGW32__) && !__USE_MINGW_ANSI_STDIO
 #  define _SCNu64_PREFIX "I64"
 # elif ULONG_MAX >> 31 == 1
 #  define _SCNu64_PREFIX _LONG_LONG_FORMAT_PREFIX
-- 
2.25.1


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

end of thread, other threads:[~2021-10-25 15:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-25  7:52 [PATCH] Fix using gnu print on mingw Orgad Shaneh via Gdb-patches
2021-10-25 15:04 ` Christian Biesinger via Gdb-patches
2021-10-25 15:14   ` Orgad Shaneh via Gdb-patches
2021-10-25 15:42 Orgad Shaneh via Gdb-patches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox