From e44361abefdf544380b198bfa0fd5f28e6d1163f Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Thu, 28 Apr 2011 11:36:38 +0000 Subject: [PATCH] Bug 651861 - ipc/chromium compilation broken on mingw r=jones.chris.g --- ipc/chromium/Makefile.in | 8 +++++++- ipc/chromium/chromium-config.mk | 5 ++++- ipc/chromium/src/base/atomicops.h | 2 +- ipc/chromium/src/base/atomicops_internals_x86_msvc.h | 2 +- ipc/chromium/src/base/debug_on_start.h | 4 ++-- ipc/chromium/src/base/file_path.cc | 12 ++++++++++++ ipc/chromium/src/base/file_path.h | 3 +++ ipc/chromium/src/base/file_util.cc | 8 ++++---- ipc/chromium/src/base/message_loop.cc | 4 ++-- ipc/chromium/src/base/platform_thread_win.cc | 4 ++-- ipc/chromium/src/base/third_party/nspr/prtime.cc | 2 +- ipc/chromium/src/base/time_win.cc | 2 +- ipc/chromium/src/base/win_util.cc | 2 +- 13 files changed, 41 insertions(+), 17 deletions(-) diff --git a/ipc/chromium/Makefile.in b/ipc/chromium/Makefile.in index 65ecaadfece..cdd2b61d81a 100644 --- a/ipc/chromium/Makefile.in +++ b/ipc/chromium/Makefile.in @@ -139,7 +139,6 @@ 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 \ @@ -173,6 +172,13 @@ CPPSRCS += \ endif # } OS_WIN +ifdef _MSC_VER # { + +CPPSRCS += \ + debug_on_start.cc + +endif # } + ifdef OS_POSIX # { CPPSRCS += \ diff --git a/ipc/chromium/chromium-config.mk b/ipc/chromium/chromium-config.mk index 09fc3db2287..784fb3f7a6c 100644 --- a/ipc/chromium/chromium-config.mk +++ b/ipc/chromium/chromium-config.mk @@ -82,7 +82,6 @@ DEFINES += \ -D_SECURE_ATL \ -DCHROMIUM_BUILD \ -DU_STATIC_IMPLEMENTATION \ - -DCOMPILER_MSVC \ -DOS_WIN=1 \ -DWIN32 \ -D_WIN32 \ @@ -90,6 +89,10 @@ DEFINES += \ -DWIN32_LEAN_AND_MEAN \ $(NULL) +ifdef _MSC_VER +DEFINES += -DCOMPILER_MSVC +endif + else # } { OS_LINUX = 1 diff --git a/ipc/chromium/src/base/atomicops.h b/ipc/chromium/src/base/atomicops.h index a31c0822ce7..c78873c4b68 100644 --- a/ipc/chromium/src/base/atomicops.h +++ b/ipc/chromium/src/base/atomicops.h @@ -124,7 +124,7 @@ Atomic64 Release_Load(volatile const Atomic64* ptr); } // 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" diff --git a/ipc/chromium/src/base/atomicops_internals_x86_msvc.h b/ipc/chromium/src/base/atomicops_internals_x86_msvc.h index 4d14a775778..e44cf16ef42 100644 --- a/ipc/chromium/src/base/atomicops_internals_x86_msvc.h +++ b/ipc/chromium/src/base/atomicops_internals_x86_msvc.h @@ -42,7 +42,7 @@ inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr, 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() { diff --git a/ipc/chromium/src/base/debug_on_start.h b/ipc/chromium/src/base/debug_on_start.h index ab823cf0e4e..42f39b2f1f7 100644 --- a/ipc/chromium/src/base/debug_on_start.h +++ b/ipc/chromium/src/base/debug_on_start.h @@ -11,8 +11,8 @@ #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) diff --git a/ipc/chromium/src/base/file_path.cc b/ipc/chromium/src/base/file_path.cc index b1bf6873820..9af670f018c 100644 --- a/ipc/chromium/src/base/file_path.cc +++ b/ipc/chromium/src/base/file_path.cc @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include + #include "base/file_path.h" #include "base/logging.h" @@ -288,6 +290,16 @@ std::wstring FilePath::ToWStringHack() const { } #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(); diff --git a/ipc/chromium/src/base/file_path.h b/ipc/chromium/src/base/file_path.h index e47f1294c0e..99cbc9d2d43 100644 --- a/ipc/chromium/src/base/file_path.h +++ b/ipc/chromium/src/base/file_path.h @@ -211,6 +211,9 @@ class FilePath { // 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. diff --git a/ipc/chromium/src/base/file_util.cc b/ipc/chromium/src/base/file_util.cc index b79a7b6fdad..1154fedf487 100644 --- a/ipc/chromium/src/base/file_util.cc +++ b/ipc/chromium/src/base/file_util.cc @@ -144,10 +144,10 @@ 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". diff --git a/ipc/chromium/src/base/message_loop.cc b/ipc/chromium/src/base/message_loop.cc index f259a0dda7e..96629936ac7 100644 --- a/ipc/chromium/src/base/message_loop.cc +++ b/ipc/chromium/src/base/message_loop.cc @@ -191,9 +191,9 @@ 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; } diff --git a/ipc/chromium/src/base/platform_thread_win.cc b/ipc/chromium/src/base/platform_thread_win.cc index 2dd325e9f48..627e1b150ee 100644 --- a/ipc/chromium/src/base/platform_thread_win.cc +++ b/ipc/chromium/src/base/platform_thread_win.cc @@ -57,10 +57,10 @@ void PlatformThread::SetName(const char* name) { info.dwThreadID = CurrentId(); info.dwFlags = 0; - __try { + MOZ_SEH_TRY { RaiseException(kVCThreadNameException, 0, sizeof(info)/sizeof(DWORD), reinterpret_cast(&info)); - } __except(EXCEPTION_CONTINUE_EXECUTION) { + } MOZ_SEH_EXCEPT(EXCEPTION_CONTINUE_EXECUTION) { } } diff --git a/ipc/chromium/src/base/third_party/nspr/prtime.cc b/ipc/chromium/src/base/third_party/nspr/prtime.cc index e6176aae328..e87e08cc392 100644 --- a/ipc/chromium/src/base/third_party/nspr/prtime.cc +++ b/ipc/chromium/src/base/third_party/nspr/prtime.cc @@ -143,7 +143,7 @@ PR_ImplodeTime(const PRExplodedTime *exploded) // Convert from Windows epoch to NSPR epoch, and 100-nanoseconds units // to microsecond units. PRTime result = - static_cast((uli.QuadPart / 10) - 11644473600000000i64); + static_cast((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; diff --git a/ipc/chromium/src/base/time_win.cc b/ipc/chromium/src/base/time_win.cc index fa2486882c1..2f9adcb3cd7 100644 --- a/ipc/chromium/src/base/time_win.cc +++ b/ipc/chromium/src/base/time_win.cc @@ -251,7 +251,7 @@ class NowSingleton : public base::SystemMonitor::PowerObserver { // 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_; } diff --git a/ipc/chromium/src/base/win_util.cc b/ipc/chromium/src/base/win_util.cc index e15f87a957a..f6094ed4a50 100644 --- a/ipc/chromium/src/base/win_util.cc +++ b/ipc/chromium/src/base/win_util.cc @@ -283,7 +283,7 @@ bool Subclass(HWND window, WNDPROC subclass_proc) { reinterpret_cast(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;