Bug 1114724 - Define PRIuSIZE format specifiers for size_t. r=Waldo
authorChris Peterson <cpeterson@mozilla.com>
Sun, 21 Dec 2014 23:30:06 -0800
changeset 221302 687012e14ec9fd24c81d48b1e2e076e96e23d1ce
parent 221301 2acb12da981391c0fdd9fe38b5089a0f20d5c43e
child 221303 18dad6d2e7cc7983d6d6e1db4015444f65e60b84
push id53315
push usercpeterson@mozilla.com
push dateThu, 25 Dec 2014 00:52:34 +0000
treeherdermozilla-inbound@687012e14ec9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersWaldo
bugs1114724
milestone37.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1114724 - Define PRIuSIZE format specifiers for size_t. r=Waldo
ipc/glue/MessageChannel.cpp
mfbt/IntegerPrintfMacros.h
mfbt/SizePrintfMacros.h
mfbt/moz.build
--- a/ipc/glue/MessageChannel.cpp
+++ b/ipc/glue/MessageChannel.cpp
@@ -8,16 +8,17 @@
 #include "mozilla/ipc/MessageChannel.h"
 #include "mozilla/ipc/ProtocolUtils.h"
 
 #include "mozilla/dom/ScriptSettings.h"
 
 #include "mozilla/Assertions.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/Move.h"
+#include "mozilla/SizePrintfMacros.h"
 #include "nsDebug.h"
 #include "nsISupportsImpl.h"
 #include "nsContentUtils.h"
 
 #include "prprf.h"
 
 // Undo the damage done by mozzconf.h
 #undef compress
@@ -110,17 +111,16 @@ const int32_t MessageChannel::kNoTimeout
 bool MessageChannel::sIsPumpingMessages = false;
 
 enum Direction
 {
     IN_MESSAGE,
     OUT_MESSAGE
 };
 
-
 class MessageChannel::InterruptFrame
 {
 private:
     enum Semantics
     {
         INTR_SEMS,
         SYNC_SEMS,
         ASYNC_SEMS
--- a/mfbt/IntegerPrintfMacros.h
+++ b/mfbt/IntegerPrintfMacros.h
@@ -54,14 +54,9 @@
 #  undef  PRIuPTR      /* uintptr_t */
 #  define PRIuPTR "u"  /* uintptr_t */
 #  undef  PRIxPTR      /* uintptr_t */
 #  define PRIxPTR "x"  /* uintptr_t */
 #  undef  PRIXPTR      /* uintptr_t */
 #  define PRIXPTR "X"  /* uintptr_t */
 #endif
 
-/**
- * For printing size_t.
- */
-#define PRIuSIZE PRIuPTR
-
 #endif  /* mozilla_IntegerPrintfMacros_h_ */
new file mode 100644
--- /dev/null
+++ b/mfbt/SizePrintfMacros.h
@@ -0,0 +1,33 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* Implements (nonstandard) PRI{ouxX}SIZE format macros for size_t types. */
+
+#ifndef mozilla_SizePrintfMacros_h_
+#define mozilla_SizePrintfMacros_h_
+
+/*
+ * MSVC's libc does not support C99's %z format length modifier for size_t
+ * types. Instead, we use Microsoft's nonstandard %I modifier for size_t, which
+ * is unsigned __int32 on 32-bit platforms and unsigned __int64 on 64-bit
+ * platforms:
+ *
+ * http://msdn.microsoft.com/en-us/library/tcxf1dw6.aspx
+ */
+
+#if defined(XP_WIN)
+#  define PRIoSIZE  "Io"
+#  define PRIuSIZE  "Iu"
+#  define PRIxSIZE  "Ix"
+#  define PRIXSIZE  "IX"
+#else
+#  define PRIoSIZE  "zo"
+#  define PRIuSIZE  "zu"
+#  define PRIxSIZE  "zx"
+#  define PRIXSIZE  "zX"
+#endif
+
+#endif  /* mozilla_SizePrintfMacros_h_ */
--- a/mfbt/moz.build
+++ b/mfbt/moz.build
@@ -58,16 +58,17 @@ EXPORTS.mozilla = [
     'RangedPtr.h',
     'RefCountType.h',
     'ReentrancyGuard.h',
     'RefPtr.h',
     'RollingMean.h',
     'Scoped.h',
     'SegmentedVector.h',
     'SHA1.h',
+    'SizePrintfMacros.h',
     'SplayTree.h',
     'TaggedAnonymousMemory.h',
     'TemplateLib.h',
     'ThreadLocal.h',
     'ToString.h',
     'TypedEnum.h',
     'TypedEnumBits.h',
     'TypedEnumInternal.h',