Bug 1372890, Define PRInt8 as 'char' on Solaris, when compiling as C++, to ensure it matches type int8_t, r=jld, r=kaie NSPR_4_16_BETA1
authorPetr Sumbera <petr.sumbera@oracle.com>
Thu, 22 Jun 2017 23:51:03 +0200
changeset 4741 3b44b3fccb50
parent 4740 e65ff8a9b3b4
child 4742 9d0a36f8a7e3
push id259
push userkaie@kuix.de
push date2017-06-22 21:51 +0000
reviewersjld, kaie
bugs1372890
Bug 1372890, Define PRInt8 as 'char' on Solaris, when compiling as C++, to ensure it matches type int8_t, r=jld, r=kaie
pr/include/prtypes.h
--- a/pr/include/prtypes.h
+++ b/pr/include/prtypes.h
@@ -240,26 +240,34 @@ PR_BEGIN_EXTERN_C
 **              PRInt8
 ** DESCRIPTION:
 **  The int8 types are known to be 8 bits each. There is no type that
 **      is equivalent to a plain "char".
 ************************************************************************/
 #if PR_BYTES_PER_BYTE == 1
 typedef unsigned char PRUint8;
 /*
+** There are two scenarios that require us to define PRInt8 as type 'char'.
+** (1)
 ** Some cfront-based C++ compilers do not like 'signed char' and
 ** issue the warning message:
 **     warning: "signed" not implemented (ignored)
 ** For these compilers, we have to define PRInt8 as plain 'char'.
 ** Make sure that plain 'char' is indeed signed under these compilers.
+** (2)
+** Mozilla C++ code expects the PRInt{N} and int{N}_t types to match (see bug
+** 634793). If a platform defines int8_t as 'char', but NSPR defines it as
+** 'signed char', it results in a type mismatch.
+** On such platforms we define PRInt8 as 'char' to avoid the mismatch. 
 */
-#if (defined(HPUX) && defined(__cplusplus) \
+#if (defined(HPUX) && defined(__cplusplus) /* reason 1*/ \
         && !defined(__GNUC__) && __cplusplus < 199707L) \
-    || (defined(SCO) && defined(__cplusplus) \
-        && !defined(__GNUC__) && __cplusplus == 1L)
+    || (defined(SCO) && defined(__cplusplus) /* reason 1 */ \
+        && !defined(__GNUC__) && __cplusplus == 1L) \
+    || (defined(__sun) && defined(__cplusplus)) /* reason 2 */
 typedef char PRInt8;
 #else
 typedef signed char PRInt8;
 #endif
 #else
 #error No suitable type for PRInt8/PRUint8
 #endif