[PATCH 09/11] widl: Handle LLP64 target same as LP64 one.

Kai Tietz ktietz70 at googlemail.com
Thu Aug 8 11:07:15 CDT 2013


Hi,

this thing here puzzles me most.  I reject this patch, but would like
to get here some discussion to find the actual intended meaning of
this xstrtoul function.
Right now its behalf is quite different on LP64/LLP64 and also
different on LP64/ILP32 architecturs.  Issue is that strtoul allows to
scan strings with leading '-'.  That means value gets errous marked as
"overflow".  At least under ILP32 (32-bit linux/windoof) this doesn't
happen, but for LLP64 it does.

Regards,
Kai

>From 40d0b3ba60c126f3d4f437473172faeb54739717 Mon Sep 17 00:00:00 2001
From: Kai Tietz <ktietz70 at googlemail.com>
Date: Thu, 8 Aug 2013 16:20:51 +0200
Subject: [PATCH 09/11] widl: Handle LLP64 target same as LP64 one.

---
 tools/widl/parser.l |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/tools/widl/parser.l b/tools/widl/parser.l
index fb61e21..c22b63e 100644
--- a/tools/widl/parser.l
+++ b/tools/widl/parser.l
@@ -88,6 +88,17 @@ int import_stack_ptr = 0;
  * on overflow */
 static unsigned int xstrtoul(const char *nptr, char **endptr, int base)
 {
+#if defined(__MINGW32__) || defined(_MSC_VER)
+  /* Long might be not wide enough for LLP64 target, so we want to use
+     double-precision here instead.  */
+  unsigned long long val;
+
+  errno = 0;
+  val = strtoull (nptr, endptr, base);
+  if ((val == ULONG_LONG_MAX && errno == ERANGE) || ((unsigned int)val != val))
+    error_loc("integer constant %s is too large\n", nptr);
+  return (unsigned int) val;
+#else
     unsigned long val;

     errno = 0;
@@ -95,6 +106,7 @@ static unsigned int xstrtoul(const char *nptr, char
**endptr, int base)
     if ((val == ULONG_MAX && errno == ERANGE) || ((unsigned int)val != val))
         error_loc("integer constant %s is too large\n", nptr);
     return val;
+#endif
 }

 UUID *parse_uuid(const char *u)
-- 
1.7.9



More information about the wine-patches mailing list