Bug 651861 - ipc/chromium compilation broken on mingw
authorJacek Caban <jacek@codeweavers.com>
Thu, 28 Apr 2011 11:36:38 +0000
changeset 68707 c447a4e42b62c13f01ba4bbedb8cff50bb33352a
parent 68706 79d0e9e782a0edaf04b7b4b30944db687d79a982
child 68708 e4ffaa64e1fbadacad5984beec8fd00806a92f7b
push id19712
push userjacek@codeweavers.com
push dateThu, 28 Apr 2011 10:27:45 +0000
treeherdermozilla-central@c447a4e42b62 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs651861
milestone6.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 651861 - ipc/chromium compilation broken on mingw r=jones.chris.g
ipc/chromium/Makefile.in
ipc/chromium/chromium-config.mk
ipc/chromium/src/base/atomicops.h
ipc/chromium/src/base/atomicops_internals_x86_msvc.h
ipc/chromium/src/base/debug_on_start.h
ipc/chromium/src/base/file_path.cc
ipc/chromium/src/base/file_path.h
ipc/chromium/src/base/file_util.cc
ipc/chromium/src/base/message_loop.cc
ipc/chromium/src/base/platform_thread_win.cc
ipc/chromium/src/base/third_party/nspr/prtime.cc
ipc/chromium/src/base/time_win.cc
ipc/chromium/src/base/win_util.cc
--- a/ipc/chromium/Makefile.in
+++ b/ipc/chromium/Makefile.in
@@ -134,17 +134,16 @@ CPPSRCS += \
   $(NULL)
 
 ifdef OS_WIN # {
 
 CPPSRCS += \
   base_paths_win.cc \
   cpu.cc \
   condition_variable_win.cc \
-  debug_on_start.cc \
   debug_util_win.cc \
   event_recorder.cc \
   file_util_win.cc \
   file_version_info.cc \
   lock_impl_win.cc \
   idle_timer.cc \
   message_pump_win.cc \
   object_watcher.cc \
@@ -168,16 +167,23 @@ CPPSRCS += \
   chrome_constants.cc \
   ipc_channel_win.cc \
   process_watcher_win.cc \
   transport_dib_win.cc \
   $(NULL)
 
 endif # } OS_WIN
 
+ifdef _MSC_VER # {
+
+CPPSRCS += \
+  debug_on_start.cc
+
+endif # }
+
 ifdef OS_POSIX # {
 
 CPPSRCS += \
   condition_variable_posix.cc \
   debug_util_posix.cc \
   event_recorder_stubs.cc \
   file_descriptor_shuffle.cc \
   file_util_posix.cc \
--- a/ipc/chromium/chromium-config.mk
+++ b/ipc/chromium/chromium-config.mk
@@ -77,24 +77,27 @@ DEFINES += \
   -DUNICODE \
   -D_UNICODE \
   -DNOMINMAX \
   -D_CRT_RAND_S \
   -DCERT_CHAIN_PARA_HAS_EXTRA_FIELDS \
   -D_SECURE_ATL \
   -DCHROMIUM_BUILD \
   -DU_STATIC_IMPLEMENTATION \
-  -DCOMPILER_MSVC \
   -DOS_WIN=1 \
   -DWIN32 \
   -D_WIN32 \
   -D_WINDOWS \
   -DWIN32_LEAN_AND_MEAN \
   $(NULL)
 
+ifdef _MSC_VER
+DEFINES += -DCOMPILER_MSVC
+endif
+
 else # } {
 
 OS_LINUX = 1
 OS_POSIX = 1
 
 DEFINES += \
   -DOS_LINUX=1 \
   -DOS_POSIX=1 \
--- a/ipc/chromium/src/base/atomicops.h
+++ b/ipc/chromium/src/base/atomicops.h
@@ -119,17 +119,17 @@ Atomic64 NoBarrier_Load(volatile const A
 Atomic64 Acquire_Load(volatile const Atomic64* ptr);
 Atomic64 Release_Load(volatile const Atomic64* ptr);
 #endif  // CPU_ARCH_64_BITS
 
 }  // namespace base::subtle
 }  // namespace base
 
 // Include our platform specific implementation.
-#if defined(OS_WIN) && defined(COMPILER_MSVC) && defined(ARCH_CPU_X86_FAMILY)
+#if defined(OS_WIN) && defined(ARCH_CPU_X86_FAMILY)
 #include "base/atomicops_internals_x86_msvc.h"
 #elif defined(OS_MACOSX) && defined(ARCH_CPU_X86_FAMILY)
 #include "base/atomicops_internals_x86_macosx.h"
 #elif defined(COMPILER_GCC) && defined(ARCH_CPU_X86_FAMILY)
 #include "base/atomicops_internals_x86_gcc.h"
 #elif defined(COMPILER_GCC) && defined(ARCH_CPU_ARM_FAMILY)
 #include "base/atomicops_internals_arm_gcc.h"
 #else
--- a/ipc/chromium/src/base/atomicops_internals_x86_msvc.h
+++ b/ipc/chromium/src/base/atomicops_internals_x86_msvc.h
@@ -37,17 +37,17 @@ inline Atomic32 Barrier_AtomicIncrement(
       static_cast<LONG>(increment)) + increment;
 }
 
 inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr,
                                           Atomic32 increment) {
   return Barrier_AtomicIncrement(ptr, increment);
 }
 
-#if !(defined(_MSC_VER) && _MSC_VER >= 1400)
+#if defined(_MSC_VER) && (_MSC_VER < 1400)
 #error "We require at least vs2005 for MemoryBarrier"
 #endif
 inline void MemoryBarrier() {
   // We use MemoryBarrier from WinNT.h
   ::MemoryBarrier();
 }
 
 inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
--- a/ipc/chromium/src/base/debug_on_start.h
+++ b/ipc/chromium/src/base/debug_on_start.h
@@ -6,18 +6,18 @@
 // line argument. When the command line argument is detected, it invokes the
 // debugger, if no system-wide debugger is registered, a debug break is done.
 
 #ifndef BASE_DEBUG_ON_START_H_
 #define BASE_DEBUG_ON_START_H_
 
 #include "base/basictypes.h"
 
-// This only works on Windows.
-#if defined(OS_WIN)
+// This only works on MSVC.
+#if defined(COMPILER_MSVC)
 
 #ifndef DECLSPEC_SELECTANY
 #define DECLSPEC_SELECTANY  __declspec(selectany)
 #endif
 
 // Debug on start functions and data.
 class DebugOnStart {
  public:
--- a/ipc/chromium/src/base/file_path.cc
+++ b/ipc/chromium/src/base/file_path.cc
@@ -1,12 +1,14 @@
 // Copyright (c) 2008 The Chromium Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include <fstream>
+
 #include "base/file_path.h"
 #include "base/logging.h"
 
 // These includes are just for the *Hack functions, and should be removed
 // when those functions are removed.
 #include "base/string_piece.h"
 #include "base/string_util.h"
 #include "base/sys_string_conversions.h"
@@ -283,16 +285,26 @@ std::wstring FilePath::ToWStringHack() c
 FilePath FilePath::FromWStringHack(const std::wstring& wstring) {
   return FilePath(wstring);
 }
 std::wstring FilePath::ToWStringHack() const {
   return path_;
 }
 #endif
 
+void FilePath::OpenInputStream(std::ifstream& stream) const {
+  stream.open(
+#ifndef __MINGW32__
+              path_.c_str(),
+#else
+              base::SysWideToNativeMB(path_).c_str(),
+#endif
+              std::ios::in | std::ios::binary);
+}
+
 FilePath FilePath::StripTrailingSeparators() const {
   FilePath new_path(path_);
   new_path.StripTrailingSeparatorsInternal();
 
   return new_path;
 }
 
 void FilePath::StripTrailingSeparatorsInternal() {
--- a/ipc/chromium/src/base/file_path.h
+++ b/ipc/chromium/src/base/file_path.h
@@ -206,16 +206,19 @@ class FilePath {
   // a separator character, or with two separator characters.  On POSIX
   // platforms, an absolute path begins with a separator character.
   bool IsAbsolute() const;
 
   // Returns a copy of this FilePath that does not end with a trailing
   // separator.
   FilePath StripTrailingSeparators() const;
 
+  // Calls open on given ifstream instance
+  void OpenInputStream(std::ifstream &stream) const;
+
   // Older Chromium code assumes that paths are always wstrings.
   // This function converts a wstring to a FilePath, and is useful to smooth
   // porting that old code to the FilePath API.
   // It has "Hack" in its name so people feel bad about using it.
   // TODO(port): remove these functions.
   static FilePath FromWStringHack(const std::wstring& wstring);
 
   // Older Chromium code assumes that paths are always wstrings.
--- a/ipc/chromium/src/base/file_util.cc
+++ b/ipc/chromium/src/base/file_util.cc
@@ -139,20 +139,20 @@ void ReplaceExtension(FilePath* path, co
 
   value.append(clean_extension);
 }
 
 bool ContentsEqual(const FilePath& filename1, const FilePath& filename2) {
   // We open the file in binary format even if they are text files because
   // we are just comparing that bytes are exactly same in both files and not
   // doing anything smart with text formatting.
-  std::ifstream file1(filename1.value().c_str(),
-                      std::ios::in | std::ios::binary);
-  std::ifstream file2(filename2.value().c_str(),
-                      std::ios::in | std::ios::binary);
+  std::ifstream file1, file2;
+
+  filename1.OpenInputStream(file1);
+  filename2.OpenInputStream(file2);
 
   // Even if both files aren't openable (and thus, in some sense, "equal"),
   // any unusable file yields a result of "false".
   if (!file1.is_open() || !file2.is_open())
     return false;
 
   const int BUFFER_SIZE = 2056;
   char buffer1[BUFFER_SIZE], buffer2[BUFFER_SIZE];
--- a/ipc/chromium/src/base/message_loop.cc
+++ b/ipc/chromium/src/base/message_loop.cc
@@ -186,19 +186,19 @@ void MessageLoop::RunAllPending() {
 // enable_SEH_restoration_ = false : any unhandled exception goes to the last
 // one that calls SetUnhandledExceptionFilter().
 // enable_SEH_restoration_ = true : any unhandled exception goes to the filter
 // that was existed before the loop was run.
 void MessageLoop::RunHandler() {
 #if defined(OS_WIN)
   if (exception_restoration_) {
     LPTOP_LEVEL_EXCEPTION_FILTER current_filter = GetTopSEHFilter();
-    __try {
+    MOZ_SEH_TRY {
       RunInternal();
-    } __except(SEHFilter(current_filter)) {
+    } MOZ_SEH_EXCEPT(SEHFilter(current_filter)) {
     }
     return;
   }
 #endif
 
   RunInternal();
 }
 
--- a/ipc/chromium/src/base/platform_thread_win.cc
+++ b/ipc/chromium/src/base/platform_thread_win.cc
@@ -52,20 +52,20 @@ void PlatformThread::SetName(const char*
     return;
 
   THREADNAME_INFO info;
   info.dwType = 0x1000;
   info.szName = name;
   info.dwThreadID = CurrentId();
   info.dwFlags = 0;
 
-  __try {
+  MOZ_SEH_TRY {
     RaiseException(kVCThreadNameException, 0, sizeof(info)/sizeof(DWORD),
                    reinterpret_cast<DWORD_PTR*>(&info));
-  } __except(EXCEPTION_CONTINUE_EXECUTION) {
+  } MOZ_SEH_EXCEPT(EXCEPTION_CONTINUE_EXECUTION) {
   }
 }
 
 // static
 bool PlatformThread::Create(size_t stack_size, Delegate* delegate,
                             PlatformThreadHandle* thread_handle) {
   unsigned int flags = 0;
   if (stack_size > 0 && win_util::GetWinVersion() >= win_util::WINVERSION_XP) {
--- a/ipc/chromium/src/base/third_party/nspr/prtime.cc
+++ b/ipc/chromium/src/base/third_party/nspr/prtime.cc
@@ -138,17 +138,17 @@ PR_ImplodeTime(const PRExplodedTime *exp
       return 0;
     }
     // Apply offsets.
     uli.LowPart = ft.dwLowDateTime;
     uli.HighPart = ft.dwHighDateTime;
     // Convert from Windows epoch to NSPR epoch, and 100-nanoseconds units
     // to microsecond units.
     PRTime result =
-        static_cast<PRTime>((uli.QuadPart / 10) - 11644473600000000i64);
+        static_cast<PRTime>((uli.QuadPart / 10) - GG_LONGLONG(11644473600000000));
     // Adjust for time zone and dst.  Convert from seconds to microseconds.
     result -= (exploded->tm_params.tp_gmt_offset +
                exploded->tm_params.tp_dst_offset) * kSecondsToMicroseconds;
     return result;
 #elif defined(OS_MACOSX)
     // Create the system struct representing our exploded time.
     CFGregorianDate gregorian_date;
     gregorian_date.year = exploded->tm_year;
--- a/ipc/chromium/src/base/time_win.cc
+++ b/ipc/chromium/src/base/time_win.cc
@@ -246,17 +246,17 @@ class NowSingleton : public base::System
   }
 
   TimeDelta Now() {
     AutoLock locked(lock_);
     // We should hold the lock while calling tick_function to make sure that
     // we keep our last_seen_ stay correctly in sync.
     DWORD now = tick_function();
     if (now < last_seen_)
-      rollover_ += TimeDelta::FromMilliseconds(0x100000000I64);  // ~49.7 days.
+      rollover_ += TimeDelta::FromMilliseconds(GG_LONGLONG(0x100000000));  // ~49.7 days.
     last_seen_ = now;
     return TimeDelta::FromMilliseconds(now) + rollover_;
   }
 
   // Interfaces for monitoring Power changes.
   void OnPowerStateChange(base::SystemMonitor* system) {
     UseHiResClock(!system->BatteryPower());
   }
--- a/ipc/chromium/src/base/win_util.cc
+++ b/ipc/chromium/src/base/win_util.cc
@@ -278,17 +278,17 @@ bool IsSubclassed(HWND window, WNDPROC s
   return original_handler == subclass_proc;
 }
 
 bool Subclass(HWND window, WNDPROC subclass_proc) {
   WNDPROC original_handler =
       reinterpret_cast<WNDPROC>(GetWindowLongPtr(window, GWLP_WNDPROC));
   if (original_handler != subclass_proc) {
     win_util::SetWindowProc(window, subclass_proc);
-    SetProp(window, kHandlerKey, original_handler);
+    SetProp(window, kHandlerKey, (void*)original_handler);
     return true;
   }
   return false;
 }
 
 bool Unsubclass(HWND window, WNDPROC subclass_proc) {
   WNDPROC current_handler =
       reinterpret_cast<WNDPROC>(GetWindowLongPtr(window, GWLP_WNDPROC));