From c77fc8a32c8af421c7e0d5fe81eccfb62329dff2 Mon Sep 17 00:00:00 2001 From: "ted.mielczarek" Date: Tue, 11 Jan 2011 20:27:29 +0000 Subject: [PATCH] Make some parts of the processor compile on Win32/MSVC R=mark at http://breakpad.appspot.com/250001 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@751 4c0a9323-5329-0410-9bdc-e9ce6186880e --- src/google_breakpad/processor/minidump.h | 2 ++ src/processor/logging.cc | 8 ++++++++ src/processor/logging.h | 9 +++++++++ src/processor/minidump.cc | 15 ++++++++++----- 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/google_breakpad/processor/minidump.h b/src/google_breakpad/processor/minidump.h index a80a5efd..f3f77677 100644 --- a/src/google_breakpad/processor/minidump.h +++ b/src/google_breakpad/processor/minidump.h @@ -79,7 +79,9 @@ #ifndef GOOGLE_BREAKPAD_PROCESSOR_MINIDUMP_H__ #define GOOGLE_BREAKPAD_PROCESSOR_MINIDUMP_H__ +#ifndef _WIN32 #include +#endif #include #include diff --git a/src/processor/logging.cc b/src/processor/logging.cc index 8842df35..c58fb8dd 100644 --- a/src/processor/logging.cc +++ b/src/processor/logging.cc @@ -44,13 +44,21 @@ namespace google_breakpad { +#ifdef _WIN32 +#define snprintf _snprintf +#endif + LogStream::LogStream(std::ostream &stream, Severity severity, const char *file, int line) : stream_(stream) { time_t clock; time(&clock); struct tm tm_struct; +#ifdef _WIN32 + localtime_s(&tm_struct, &clock); +#else localtime_r(&clock, &tm_struct); +#endif char time_string[20]; strftime(time_string, sizeof(time_string), "%Y-%m-%d %H:%M:%S", &tm_struct); diff --git a/src/processor/logging.h b/src/processor/logging.h index b638ff58..642506d5 100644 --- a/src/processor/logging.h +++ b/src/processor/logging.h @@ -68,6 +68,15 @@ namespace google_breakpad { +// These are defined in Microsoft headers. +#ifdef SEVERITY_ERROR +#undef SEVERITY_ERROR +#endif + +#ifdef ERROR +#undef ERROR +#endif + class LogStream { public: enum Severity { diff --git a/src/processor/minidump.cc b/src/processor/minidump.cc index 41e7cea6..3d42c428 100644 --- a/src/processor/minidump.cc +++ b/src/processor/minidump.cc @@ -40,14 +40,15 @@ #include #include #include -#include + #ifdef _WIN32 #include typedef SSIZE_T ssize_t; -#define open _open -#define read _read -#define lseek _lseek +#define PRIx64 "llx" +#define PRIx32 "lx" +#define snprintf _snprintf #else // _WIN32 +#include #define O_BINARY 0 #endif // _WIN32 @@ -1101,7 +1102,7 @@ void MinidumpMemoryRegion::SetDescriptor(MDMemoryDescriptor* descriptor) { descriptor_ = descriptor; valid_ = descriptor && descriptor_->memory.data_size <= - numeric_limits::max() - + numeric_limits::max() - descriptor_->start_of_memory_range; } @@ -3694,7 +3695,11 @@ void Minidump::Print() { printf(" stream_directory_rva = 0x%x\n", header_.stream_directory_rva); printf(" checksum = 0x%x\n", header_.checksum); struct tm timestruct; +#ifdef _WIN32 + gmtime_s(×truct, reinterpret_cast(&header_.time_date_stamp)); +#else gmtime_r(reinterpret_cast(&header_.time_date_stamp), ×truct); +#endif char timestr[20]; strftime(timestr, 20, "%Y-%m-%d %H:%M:%S", ×truct); printf(" time_date_stamp = 0x%x %s\n", header_.time_date_stamp,