[or-cvs] r9691: On mingw, use "%I64u" to printf/scanf 64-bit integers, inste (in tor/trunk: . src/common)

nickm at seul.org nickm at seul.org
Wed Feb 28 21:07:20 UTC 2007


Author: nickm
Date: 2007-02-28 16:07:19 -0500 (Wed, 28 Feb 2007)
New Revision: 9691

Modified:
   tor/trunk/
   tor/trunk/ChangeLog
   tor/trunk/src/common/compat.h
Log:
 r12006 at catbus:  nickm | 2007-02-28 16:06:24 -0500
 On mingw, use "%I64u" to printf/scanf 64-bit integers, instead of the usual GCC "%llu".  This prevents a bug when saving 64-bit int configuration values on mingw; the high-order 32 bits would get truncated.  If the value was then reloaded, disaster would occur. (Fixes bug 400 and maybe also bug 397.)  Backport candidate.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r12006] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2007-02-28 21:06:05 UTC (rev 9690)
+++ tor/trunk/ChangeLog	2007-02-28 21:07:19 UTC (rev 9691)
@@ -24,6 +24,11 @@
       of 2 as indicating that the server is completely bad; it sometimes
       means that the server is just bad for the request in question. (may fix
       the last of bug 326.)
+    - On mingw, use "%I64u" to printf/scanf 64-bit integers, instead of the
+      usual GCC "%llu".  This prevents a bug when saving 64-bit int
+      configuration values on mingw; the high-order 32 bits would get
+      truncated.  If the value was then reloaded, disaster would
+      occur. (Fixes bug 400 and maybe also bug 397.)
 
 
 Changes in version 0.1.2.8-beta - 2007-02-26

Modified: tor/trunk/src/common/compat.h
===================================================================
--- tor/trunk/src/common/compat.h	2007-02-28 21:06:05 UTC (rev 9690)
+++ tor/trunk/src/common/compat.h	2007-02-28 21:07:19 UTC (rev 9691)
@@ -123,15 +123,19 @@
 #ifdef _MSC_VER
 #define U64_PRINTF_ARG(a) (a)
 #define U64_SCANF_ARG(a) (a)
-#define U64_FORMAT "%I64u"
 #define U64_LITERAL(n) (n ## ui64)
 #else
 #define U64_PRINTF_ARG(a) ((long long unsigned int)(a))
 #define U64_SCANF_ARG(a) ((long long unsigned int*)(a))
-#define U64_FORMAT "%llu"
 #define U64_LITERAL(n) (n ## llu)
 #endif
 
+#if defined(_MSC_VER) || defined(__MINGW32__) || defined(__MINGW64__)
+#define U64_FORMAT "%I64u"
+#else
+#define U64_FORMAT "%llu"
+#endif
+
 /** Represents an mmaped file. Allocated via tor_mmap_file; freed with
  * tor_munmap_file. */
 typedef struct tor_mmap_t {



More information about the tor-commits mailing list