Bug 895047 - Make char16_t available everywhere and use that to define PRUnichar and jschar; r=jcranmer,jorendorff,glandium
authorEhsan Akhgari <ehsan@mozilla.com>
Thu, 17 Oct 2013 00:36:13 -0400
changeset 164921 30d9e30f0c8cdb2d3ef48029662a9dab066b1f28
parent 164920 cdf9d97ed9cd196c977f12728f91c4aa780bf079
child 164922 855da6d8a327c277e9653911b3244c3229134363
child 164923 afb6450f58cd429c92db622096433ddfdf40e252
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjcranmer, jorendorff, glandium
bugs895047
milestone27.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 895047 - Make char16_t available everywhere and use that to define PRUnichar and jschar; r=jcranmer,jorendorff,glandium
CLOBBER
build/unix/elfhack/Makefile.in
build/unix/elfhack/inject/Makefile.in
config/Makefile.in
js/public/TypeDecls.h
js/src/js-confdefs.h.in
mfbt/Char16.h
mozilla-config.h.in
xpcom/base/nscore.h
--- a/CLOBBER
+++ b/CLOBBER
@@ -13,9 +13,9 @@
 #          |               |
 #          O <-- Clobber   O  <-- Clobber
 #
 # Note: The description below will be part of the error message shown to users.
 #
 # Modifying this file will now automatically clobber the buildbot machines \o/
 #
 
-Bug 872934 - Clobber needed for webidl updates for style sheet change events. Again and again.
\ No newline at end of file
+Bug 895047 - Clobber needed for touching js/src/js-confdefs.h.in
--- a/build/unix/elfhack/Makefile.in
+++ b/build/unix/elfhack/Makefile.in
@@ -11,16 +11,18 @@ NO_PROFILE_GUIDED_OPTIMIZE = 1
 VPATH += $(topsrcdir)/build
 
 OS_CXXFLAGS := $(filter-out -fno-exceptions,$(OS_CXXFLAGS)) -fexceptions
 
 WRAP_LDFLAGS=
 
 include $(topsrcdir)/config/rules.mk
 
+DEFINES += -DELFHACK_BUILD
+
 test-array$(DLL_SUFFIX) test-ctors$(DLL_SUFFIX): %$(DLL_SUFFIX): %.$(OBJ_SUFFIX) elfhack $(filter inject/%,$(CSRCS:.c=.$(OBJ_SUFFIX)))
 	$(MKSHLIB) $(LDFLAGS) $< -nostartfiles
 	@echo ===
 	@echo === If you get failures below, please file a bug describing the error
 	@echo === and your environment \(compiler and linker versions\), and use
 	@echo === --disable-elf-hack until this is fixed.
 	@echo ===
 	# Fail if the library doesn't have $(DT_TYPE) .dynamic info
--- a/build/unix/elfhack/inject/Makefile.in
+++ b/build/unix/elfhack/inject/Makefile.in
@@ -25,10 +25,12 @@ include $(topsrcdir)/config/rules.mk
 
 export:: $(CSRCS:.c=.$(OBJ_SUFFIX))
 
 $(CSRCS): %.c: ../inject.c
 	cp $< $@
 
 GARBAGE += $(CSRCS)
 
+DEFINES += -DELFHACK_BUILD
+
 CFLAGS := -O2 -fno-stack-protector $(filter -m% -I%,$(CFLAGS))
 $(CPU)-noinit.$(OBJ_SUFFIX): DEFINES += -DNOINIT
--- a/config/Makefile.in
+++ b/config/Makefile.in
@@ -123,17 +123,17 @@ install::
 	$(SYSINSTALL) $(IFLAGS1) $(DEPTH)/mozilla-config.h $(DESTDIR)$(includedir)
 
 GARBAGE += \
   $(FINAL_LINK_COMPS) $(FINAL_LINK_LIBS) $(FINAL_LINK_COMP_NAMES) buildid $(srcdir)/*.pyc *.pyc
 
 ifndef CROSS_COMPILE
 ifdef USE_ELF_DYNSTR_GC
 elf-dynstr-gc: elf-dynstr-gc.c $(GLOBAL_DEPS) $(call mkdir_deps,$(MDDEPDIR))
-	$(CC) $(COMPILE_CFLAGS) $(GLIB_CFLAGS) -o $@ $< $(LDFLAGS) $(GLIB_LIBS)
+	$(CC) $(COMPILE_CFLAGS) $(GLIB_CFLAGS) -DELFDYNSTRGC_BUILD -o $@ $< $(LDFLAGS) $(GLIB_LIBS)
 endif
 endif
 
 FORCE:
 
 check-preqs = \
   check-jar-mn \
   check-makefiles \
--- a/js/public/TypeDecls.h
+++ b/js/public/TypeDecls.h
@@ -45,21 +45,17 @@ class JSString;
 #endif
 
 #ifdef JS_USE_JSID_STRUCT_TYPES
 struct jsid;
 #else
 typedef ptrdiff_t jsid;
 #endif
 
-#ifdef WIN32
-typedef wchar_t  jschar;
-#else
-typedef uint16_t jschar;
-#endif
+typedef char16_t jschar;
 
 namespace JS {
 
 class Value;
 template <typename T> class Handle;
 template <typename T> class MutableHandle;
 
 typedef Handle<JSFunction*> HandleFunction;
--- a/js/src/js-confdefs.h.in
+++ b/js/src/js-confdefs.h.in
@@ -5,9 +5,11 @@
 
 #ifndef js_confdefs_h
 #define js_confdefs_h
 
 @ALLDEFINES@
 
 #include "js/RequiredDefines.h"
 
+#include "mozilla/Char16.h"
+
 #endif /* js_confdefs_h */
--- a/mfbt/Char16.h
+++ b/mfbt/Char16.h
@@ -9,19 +9,16 @@
 #ifndef mozilla_Char16_h
 #define mozilla_Char16_h
 
 /*
  * C11 and C++11 introduce a char16_t type and support for UTF-16 string and
  * character literals. C++11's char16_t is a distinct builtin type. C11's
  * char16_t is a typedef for uint_least16_t. Technically, char16_t is a 16-bit
  * code unit of a Unicode code point, not a "character".
- *
- * For now, Char16.h only supports C++ because we don't want mix different C
- * and C++ definitions of char16_t in the same code base.
  */
 
 #ifdef _MSC_VER
    /*
     * C++11 says char16_t is a distinct builtin type, but Windows's yvals.h
     * typedefs char16_t as an unsigned short. We would like to alias char16_t
     * to Windows's 16-bit wchar_t so we can declare UTF-16 literals as constant
     * expressions (and pass char16_t pointers to Windows APIs). We #define our
@@ -34,28 +31,47 @@
       (__cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__))
    /* C++11 has a builtin char16_t type. */
 #  define MOZ_UTF16_HELPER(s) u##s
    /**
     * This macro is used to distinguish when char16_t would be a distinct
     * typedef from wchar_t.
     */
 #  define MOZ_CHAR16_IS_NOT_WCHAR
+#elif !defined(__cplusplus)
+#  if defined(WIN32)
+#    include <yvals.h>
+     typedef wchar_t char16_t;
+#  else
+     /**
+      * We can't use the stdint.h uint16_t type here because including
+      * stdint.h will break building some of our C libraries, such as
+      * sqlite.
+      */
+     typedef unsigned short char16_t;
+#  endif
 #else
 #  error "Char16.h requires C++11 (or something like it) for UTF-16 support."
 #endif
 
+/* This is a temporary hack until bug 927728 is fixed. */
+#define __PRUNICHAR__
+typedef char16_t PRUnichar;
+
 /*
  * Macro arguments used in concatenation or stringification won't be expanded.
  * Therefore, in order for |MOZ_UTF16(FOO)| to work as expected (which is to
  * expand |FOO| before doing whatever |MOZ_UTF16| needs to do to it) a helper
  * macro, |MOZ_UTF16_HELPER| needs to be inserted in between to allow the macro
  * argument to expand. See "3.10.6 Separate Expansion of Macro Arguments" of the
  * CPP manual for a more accurate and precise explanation.
  */
 #define MOZ_UTF16(s) MOZ_UTF16_HELPER(s)
 
+#if defined(__cplusplus) && \
+    (__cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__))
 static_assert(sizeof(char16_t) == 2, "Is char16_t type 16 bits?");
 static_assert(char16_t(-1) > char16_t(0), "Is char16_t type unsigned?");
 static_assert(sizeof(MOZ_UTF16('A')) == 2, "Is char literal 16 bits?");
 static_assert(sizeof(MOZ_UTF16("")[0]) == 2, "Is string char 16 bits?");
+#endif
 
 #endif /* mozilla_Char16_h */
--- a/mozilla-config.h.in
+++ b/mozilla-config.h.in
@@ -21,16 +21,29 @@
  */
 #define __STDC_LIMIT_MACROS
 #define __STDC_CONSTANT_MACROS
 #if !defined(__STDC_FORMAT_MACROS)
 #define __STDC_FORMAT_MACROS
 #endif
 
 /*
+ * Force-include Char16.h in order to define PRUnichar as char16_t everywhere.
+ * Note that this should be the first #include to make sure that prtypes.h does
+ * not attempt to define PRUnichar.  This includes the following hunspell-specific
+ * includes.
+ *
+ * We don't use this to build elfhack and elf-dynstr-gc since those builds happen
+ * during the export tier.  Also, disable this when building assembly files too.
+ */
+#if !defined(ELFHACK_BUILD) && !defined(ELFDYNSTRGC_BUILD) && !defined(__ASSEMBLER__)
+#include "mozilla/Char16.h"
+#endif
+
+/*
  * Force-include hunspell_alloc_hooks.h and hunspell_fopen_hooks.h for hunspell,
  * so that we don't need to modify them directly.
  *
  * HUNSPELL_STATIC is defined in extensions/spellcheck/hunspell/src/Makefile.in,
  * unless --enable-system-hunspell is defined.
  */
 #if defined(HUNSPELL_STATIC)
 #include "hunspell_alloc_hooks.h"
--- a/xpcom/base/nscore.h
+++ b/xpcom/base/nscore.h
@@ -320,28 +320,16 @@
  * IUnknown.
  */
 #ifdef XP_WIN
 typedef unsigned long nsrefcnt;
 #else
 typedef uint32_t nsrefcnt;
 #endif
 
-/* ------------------------------------------------------------------------ */
-/* Casting macros for hiding C++ features from older compilers */
-
-#ifndef __PRUNICHAR__
-#define __PRUNICHAR__
-  #if defined(WIN32)
-    typedef wchar_t PRUnichar;
-  #else
-    typedef uint16_t PRUnichar;
-  #endif
-#endif
-
 /*
  * Use these macros to do 64bit safe pointer conversions.
  */
 
 #define NS_PTR_TO_INT32(x)  ((int32_t)  (intptr_t) (x))
 #define NS_PTR_TO_UINT32(x) ((uint32_t) (intptr_t) (x))
 #define NS_INT32_TO_PTR(x)  ((void *)   (intptr_t) (x))