Bug 945029 - Fix up Android's broken [u]intptr_t inttype macros. r=Waldo
authorChris Peterson <cpeterson@mozilla.com>
Mon, 12 May 2014 22:27:14 -0700
changeset 207357 d089350aff818ac688847038226fb4ec6071dca0
parent 207356 c303feddaea218d37d5ce6b2f202cc28f2a7bb24
child 207358 257269554ad9c047f5b8f2d26420c137d7d5b3bd
push id494
push userraliiev@mozilla.com
push dateMon, 25 Aug 2014 18:42:16 +0000
treeherdermozilla-release@a3cc3e46b571 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersWaldo
bugs945029
milestone32.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 945029 - Fix up Android's broken [u]intptr_t inttype macros. r=Waldo
content/base/src/moz.build
content/xml/content/src/moz.build
mfbt/IntegerPrintfMacros.h
mfbt/tests/TestTypeTraits.cpp
view/src/moz.build
xpcom/base/moz.build
--- a/content/base/src/moz.build
+++ b/content/base/src/moz.build
@@ -238,12 +238,8 @@ LOCAL_INCLUDES += [
     '/layout/base',
     '/layout/generic',
     '/layout/style',
     '/layout/svg',
     '/layout/xul',
     '/netwerk/base/src',
     '/xpcom/ds',
 ]
-
-if CONFIG['GNU_CC'] and CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
-    # Work around bug 986928
-    CXXFLAGS += ['-Wno-error=format']
--- a/content/xml/content/src/moz.build
+++ b/content/xml/content/src/moz.build
@@ -25,12 +25,8 @@ MSVC_ENABLE_PGO = True
 FINAL_LIBRARY = 'gklayout'
 LOCAL_INCLUDES += [
     '/content/base/src',
 ]
 
 RESOURCE_FILES.dtd += [
     'htmlmathml-f.ent',
 ]
-
-if CONFIG['GNU_CC'] and CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
-    # Work around bug 986928
-    CXXFLAGS += ['-Wno-error=format']
--- a/mfbt/IntegerPrintfMacros.h
+++ b/mfbt/IntegerPrintfMacros.h
@@ -32,9 +32,30 @@
 #if defined(MOZ_CUSTOM_INTTYPES_H)
 #  include MOZ_CUSTOM_INTTYPES_H
 #elif defined(_MSC_VER)
 #  include "mozilla/MSIntTypes.h"
 #else
 #  include <inttypes.h>
 #endif
 
+/*
+ * Fix up Android's broken [u]intptr_t inttype macros. Android's PRI*PTR
+ * macros are defined as "ld", but sizeof(long) is 8 and sizeof(intptr_t)
+ * is 4 on 32-bit Android. TestTypeTraits.cpp asserts that these new macro
+ * definitions match the actual type sizes seen at compile time.
+ */
+#if defined(ANDROID) && !defined(__LP64__)
+#  undef  PRIdPTR      /* intptr_t  */
+#  define PRIdPTR "d"  /* intptr_t  */
+#  undef  PRIiPTR      /* intptr_t  */
+#  define PRIiPTR "i"  /* intptr_t  */
+#  undef  PRIoPTR      /* uintptr_t */
+#  define PRIoPTR "o"  /* uintptr_t */
+#  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
+
 #endif  /* mozilla_IntegerPrintfMacros_h_ */
--- a/mfbt/tests/TestTypeTraits.cpp
+++ b/mfbt/tests/TestTypeTraits.cpp
@@ -287,15 +287,29 @@ static_assert(IsSame<MakeUnsigned<unsign
 
 static_assert(IsSame<MakeUnsigned<char>::Type, unsigned char>::value,
               "char won't unsignify correctly");
 static_assert(IsSame<MakeUnsigned<volatile char>::Type, volatile unsigned char>::value,
               "volatile char won't unsignify correctly");
 static_assert(IsSame<MakeUnsigned<const char>::Type, const unsigned char>::value,
               "const char won't unsignify correctly");
 
+/*
+ * Android's broken [u]intptr_t inttype macros are broken because its PRI*PTR
+ * macros are defined as "ld", but sizeof(long) is 8 and sizeof(intptr_t)
+ * is 4 on 32-bit Android. We redefine Android's PRI*PTR macros in
+ * IntegerPrintfMacros.h and assert here that our new definitions match the
+ * actual type sizes seen at compile time.
+ */
+#if defined(ANDROID) && !defined(__LP64__)
+static_assert(mozilla::IsSame<int, intptr_t>::value,
+              "emulated PRI[di]PTR definitions will be wrong");
+static_assert(mozilla::IsSame<unsigned int, uintptr_t>::value,
+              "emulated PRI[ouxX]PTR definitions will be wrong");
+#endif
+
 int
 main()
 {
   CPlusPlus11IsBaseOf::StandardIsBaseOfTests();
   TestIsBaseOf();
   TestIsConvertible();
 }
--- a/view/src/moz.build
+++ b/view/src/moz.build
@@ -10,12 +10,8 @@ SOURCES += [
     'nsViewManager.cpp',
 ]
 
 FAIL_ON_WARNINGS = True
 
 MSVC_ENABLE_PGO = True
 
 FINAL_LIBRARY = 'gklayout'
-
-if CONFIG['GNU_CC'] and CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
-    # Work around bug 986928
-    CXXFLAGS += ['-Wno-error=format']
--- a/xpcom/base/moz.build
+++ b/xpcom/base/moz.build
@@ -151,12 +151,8 @@ FINAL_LIBRARY = 'xpcom_core'
 
 LOCAL_INCLUDES += [
     '../build',
     '/xpcom/ds',
 ]
 
 if CONFIG['MOZ_OPTIMIZE']:
     DEFINES['MOZ_OPTIMIZE'] = True
-
-if CONFIG['GNU_CC'] and CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
-    # Work around bug 986928
-    CXXFLAGS += ['-Wno-error=format']