summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-02-28 21:07:19 +0000
committerNick Mathewson <nickm@torproject.org>2007-02-28 21:07:19 +0000
commite2b1a77c3e03a8a8142dc033f74d9ba9f394f8ed (patch)
tree0a392bf000431c3bc1165be3bf5962485fa271b9
parentb78f67dbf5964d5c8f9d67d0f40fc999fbee150c (diff)
downloadtor-e2b1a77c3e03a8a8142dc033f74d9ba9f394f8ed.tar.gz
tor-e2b1a77c3e03a8a8142dc033f74d9ba9f394f8ed.zip
r12006@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. svn:r9691
-rw-r--r--ChangeLog5
-rw-r--r--src/common/compat.h8
2 files changed, 11 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index d8ea601e24..183a01b9f7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -24,6 +24,11 @@ Changes in version 0.1.2.9-??? - 2007-??-??
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
diff --git a/src/common/compat.h b/src/common/compat.h
index c516f8d651..f578c128f8 100644
--- a/src/common/compat.h
+++ b/src/common/compat.h
@@ -123,15 +123,19 @@ size_t strlcpy(char *dst, const char *src, size_t siz) ATTR_NONNULL((1,2));
#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 {