Bug 944444 - Fix js/ compilation on mingw. r=Waldo
authorJacek Caban <jacek@codeweavers.com>
Thu, 05 Dec 2013 10:56:22 +0100
changeset 158914 70d4fcbcd68afde3c93b2def392095d7c1438c61
parent 158913 06102544b4ca6d8ae27ba7c210b85a62ea9517a3
child 158915 05a8fa1c32abd40a09c7dc471dbea61a2544ff13
push id25767
push userryanvm@gmail.com
push dateThu, 05 Dec 2013 22:29:08 +0000
treeherdermozilla-central@ee425b3ccc29 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersWaldo
bugs944444
milestone28.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 944444 - Fix js/ compilation on mingw. r=Waldo
js/src/Makefile.in
js/src/builtin/Profilers.h
js/src/jsmath.cpp
js/xpconnect/loader/mozJSComponentLoader.cpp
js/xpconnect/loader/mozJSSubScriptLoader.cpp
js/xpconnect/src/XPCLocale.cpp
js/xpconnect/tests/components/native/xpctest_params.cpp
js/xpconnect/wrappers/XrayWrapper.cpp
--- a/js/src/Makefile.in
+++ b/js/src/Makefile.in
@@ -356,16 +356,21 @@ DIST_GARBAGE = config.cache config.log c
    backend.RecursiveMakeBackend backend.RecursiveMakeBackend.pp \
    devtools/rootAnalysis/Makefile
 
 distclean::
 	$(RM) $(DIST_GARBAGE)
 
 INCLUDES	+= -I$(srcdir)
 
+ifneq (,$(filter WINNT,$(OS_ARCH)))
+# _CRT_RAND_S must be #defined before #including stdlib.h to get rand_s()
+DEFINES         += -D_CRT_RAND_S
+endif
+
 ifneq ($(findstring -L,$(NSPR_LIBS)),)
 NSPR_STATIC_PATH = $(subst -L,,$(findstring -L,$(NSPR_LIBS)))
 else
 NSPR_STATIC_PATH = $(DIST)/lib
 endif
 
 ifdef MOZ_ETW
 # This will get the ETW provider resources into the library mozjs.dll
--- a/js/src/builtin/Profilers.h
+++ b/js/src/builtin/Profilers.h
@@ -8,17 +8,17 @@
  * Functions for controlling profilers from within JS: Valgrind, Perf,
  * Shark, etc.
  */
 #ifndef builtin_Profilers_h
 #define builtin_Profilers_h
 
 #include "jstypes.h"
 
-#ifdef XP_WIN
+#ifdef _MSC_VER
 typedef int pid_t;
 #else
 #include <unistd.h>
 #endif
 
 /**
  * Start any profilers that are available and have been configured on for this
  * platform. This is NOT thread safe.
--- a/js/src/jsmath.cpp
+++ b/js/src/jsmath.cpp
@@ -3,21 +3,16 @@
  * 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/. */
 
 /*
  * JS math package.
  */
 
-#if defined(XP_WIN)
-/* _CRT_RAND_S must be #defined before #including stdlib.h to get rand_s(). */
-#define _CRT_RAND_S
-#endif
-
 #include "jsmath.h"
 
 #include "mozilla/Constants.h"
 #include "mozilla/FloatingPoint.h"
 #include "mozilla/MathAlgorithms.h"
 #include "mozilla/MemoryReporting.h"
 
 #include <algorithm>  // for std::max
--- a/js/xpconnect/loader/mozJSComponentLoader.cpp
+++ b/js/xpconnect/loader/mozJSComponentLoader.cpp
@@ -122,17 +122,17 @@ Dump(JSContext *cx, unsigned argc, Value
         return false;
 
     NS_ConvertUTF16toUTF8 utf8str(reinterpret_cast<const PRUnichar*>(chars));
 #ifdef ANDROID
     __android_log_print(ANDROID_LOG_INFO, "Gecko", "%s", utf8str.get());
 #endif
 #ifdef XP_WIN
     if (IsDebuggerPresent()) {
-      OutputDebugStringW(reinterpret_cast<const PRUnichar*>(chars));
+      OutputDebugStringW(reinterpret_cast<const wchar_t*>(chars));
     }
 #endif
     fputs(utf8str.get(), stdout);
     fflush(stdout);
     return true;
 }
 
 static bool
--- a/js/xpconnect/loader/mozJSSubScriptLoader.cpp
+++ b/js/xpconnect/loader/mozJSSubScriptLoader.cpp
@@ -150,22 +150,22 @@ mozJSSubScriptLoader::ReadScript(nsIURI 
                                             charset, nullptr, script);
 
         if (NS_FAILED(rv)) {
             return ReportError(cx, LOAD_ERROR_BADCHARSET);
         }
 
         if (!reuseGlobal) {
             *scriptp = JS::Compile(cx, target_obj, options,
-                                   reinterpret_cast<const jschar*>(script.get()),
+                                   script.get(),
                                    script.Length());
         } else {
             *functionp = JS::CompileFunction(cx, target_obj, options,
                                              nullptr, 0, nullptr,
-                                             reinterpret_cast<const jschar*>(script.get()),
+                                             script.get(),
                                              script.Length());
         }
     } else {
         // We only use LAZY_SOURCE when no special encoding is specified because
         // the lazy source loader doesn't know the encoding.
         if (!reuseGlobal) {
             options.setSourcePolicy(JS::CompileOptions::LAZY_SOURCE);
             *scriptp = JS::Compile(cx, target_obj, options, buf.get(), len);
--- a/js/xpconnect/src/XPCLocale.cpp
+++ b/js/xpconnect/src/XPCLocale.cpp
@@ -105,17 +105,17 @@ private:
     if (!depStr.init(cx, src)) {
       return false;
     }
 
     nsAutoString result;
     changeCaseFnc(depStr, result);
 
     JSString *ucstr =
-      JS_NewUCStringCopyN(cx, (jschar*)result.get(), result.Length());
+      JS_NewUCStringCopyN(cx, result.get(), result.Length());
     if (!ucstr) {
       return false;
     }
 
     rval.set(STRING_TO_JSVAL(ucstr));
     return true;
   }
 
--- a/js/xpconnect/tests/components/native/xpctest_params.cpp
+++ b/js/xpconnect/tests/components/native/xpctest_params.cpp
@@ -162,17 +162,17 @@ NS_IMETHODIMP nsXPCTestParams::TestWstri
 {
     nsDependentString aprime(a);
     nsDependentString bprime(*b);
     *_retval = ToNewUnicode(bprime);
     *b = ToNewUnicode(aprime);
 
     // XPCOM ownership rules dictate that overwritten inout params must be callee-freed.
     // See https://developer.mozilla.org/en/XPIDL
-    NS_Free(const_cast<PRUnichar*>(bprime.get()));
+    NS_Free((void*)bprime.get());
 
     return NS_OK;
 }
 
 /* DOMString testDOMString (in DOMString a, inout DOMString b); */
 NS_IMETHODIMP nsXPCTestParams::TestDOMString(const nsAString & a, nsAString & b, nsAString & _retval)
 {
     STRING_METHOD_IMPL;
--- a/js/xpconnect/wrappers/XrayWrapper.cpp
+++ b/js/xpconnect/wrappers/XrayWrapper.cpp
@@ -1292,18 +1292,17 @@ XrayToString(JSContext *cx, unsigned arg
         JS_ReportOutOfMemory(cx);
         return false;
     }
     result.AppendASCII(wrapperStr);
     JS_smprintf_free(wrapperStr);
 
     result.AppendASCII(end);
 
-    JSString *str = JS_NewUCStringCopyN(cx, reinterpret_cast<const jschar *>(result.get()),
-                                        result.Length());
+    JSString *str = JS_NewUCStringCopyN(cx, result.get(), result.Length());
     if (!str)
         return false;
 
     args.rval().setString(str);
     return true;
 }
 
 #ifdef DEBUG