Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Unified Diff: src/platform-win32.cc

Issue 18309: Support for building V8 with MinGW. This patch is from gdschaefer. In additio... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/platform.h ('k') | tools/presubmit.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/platform-win32.cc
===================================================================
--- src/platform-win32.cc (revision 1090)
+++ src/platform-win32.cc (working copy)
@@ -58,7 +58,10 @@
#include <time.h> // For LocalOffset() implementation.
#include <mmsystem.h> // For timeGetTime().
+#ifndef __MINGW32__
#include <dbghelp.h> // For SymLoadModule64 and al.
+#endif // __MINGW32__
+#include <limits.h> // For INT_MAX and al.
#include <tlhelp32.h> // For Module32First and al.
// These additional WIN32 includes have to be right here as the #undef's below
@@ -67,8 +70,6 @@
#include <process.h> // for _beginthreadex()
#include <stdlib.h>
-#pragma comment(lib, "winmm.lib") // force linkage with winmm.
-
#undef VOID
#undef DELETE
#undef IN
@@ -83,15 +84,16 @@
#include "platform.h"
-// Extra POSIX/ANSI routines for Win32. Please refer to The Open Group Base
-// Specification for specification of the correct semantics for these
-// functions.
+// Extra POSIX/ANSI routines for Win32 when when using Visual Studio C++. Please
+// refer to The Open Group Base Specification for specification of the correct
+// semantics for these functions.
// (http://www.opengroup.org/onlinepubs/000095399/)
+#ifdef _MSC_VER
-// Test for finite value - usually defined in math.h
namespace v8 {
namespace internal {
+// Test for finite value - usually defined in math.h
int isfinite(double x) {
return _finite(x);
}
@@ -152,19 +154,61 @@
}
+// Case-insensitive bounded string comparisons. Use stricmp() on Win32. Usually
+// defined in strings.h.
+int strncasecmp(const char* s1, const char* s2, int n) {
+ return _strnicmp(s1, s2, n);
+}
+
+#endif // _MSC_VER
+
+
+// Extra functions for MinGW. Most of these are the _s functions which are in
+// the Microsoft Visual Studio C++ CRT.
+#ifdef __MINGW32__
+
+int localtime_s(tm* _tm, const time_t* time) {
+ tm * posix_local_time_struct = localtime(time);
+ if (posix_local_time_struct == NULL) return 1;
+ *_tm = *posix_local_time_struct;
+ return 0;
+}
+
+
+// Not sure this the correct interpretation of _mkgmtime
+time_t _mkgmtime(tm* timeptr) {
+ return mktime(timeptr);
+}
+
+
+int fopen_s(FILE** pFile, const char* filename, const char* mode) {
+ *pFile = fopen(filename, mode);
+ return *pFile != NULL ? 0 : 1;
+}
+
+
+int _vsnprintf_s(char* buffer, size_t sizeOfBuffer, size_t count,
+ const char* format, va_list argptr) {
+ return _vsnprintf(buffer, sizeOfBuffer, format, argptr);
+}
+#define _TRUNCATE 0
+
+
+int strncpy_s(char* strDest, size_t numberOfElements,
+ const char* strSource, size_t count) {
+ strncpy(strDest, strSource, count);
+ return 0;
+}
+
+#endif // __MINGW32__
+
// Generate a pseudo-random number in the range 0-2^31-1. Usually
-// defined in stdlib.h
+// defined in stdlib.h. Missing in both Microsoft Visual Studio C++ and MinGW.
int random() {
return rand();
}
-// Case-insensitive bounded string comparisons. Use stricmp() on Win32. Usually
-// defined in strings.h.
-int strncasecmp(const char* s1, const char* s2, int n) {
- return _strnicmp(s1, s2, n);
-}
-
namespace v8 { namespace internal {
double ceiling(double x) {
@@ -206,7 +250,7 @@
private:
// Constants for time conversion.
- static const int64_t kTimeEpoc = 116444736000000000;
+ static const int64_t kTimeEpoc = 116444736000000000LL;
static const int64_t kTimeScaler = 10000;
static const int64_t kMsPerMinute = 60000;
@@ -805,9 +849,11 @@
void OS::Abort() {
if (!IsDebuggerPresent()) {
+#ifdef _MSC_VER
// Make the MSVCRT do a silent abort.
_set_abort_behavior(0, _WRITE_ABORT_MSG);
_set_abort_behavior(0, _CALL_REPORTFAULT);
+#endif // _MSC_VER
abort();
} else {
DebugBreak();
@@ -816,7 +862,11 @@
void OS::DebugBreak() {
+#ifdef _MSC_VER
__debugbreak();
+#else
+ ::DebugBreak();
+#endif
}
@@ -899,6 +949,8 @@
#define VOID void
#endif
+// DbgHelp isn't supported on MinGW yet
+#ifndef __MINGW32__
// DbgHelp.h functions.
typedef BOOL (__stdcall *DLL_FUNC_TYPE(SymInitialize))(IN HANDLE hProcess,
IN PSTR UserSearchPath,
@@ -1221,10 +1273,19 @@
// Restore warnings to previous settings.
#pragma warning(pop)
+#else // __MINGW32__
+void OS::LogSharedLibraryAddresses() { }
+int OS::StackWalk(OS::StackFrame* frames, int frames_size) { return 0; }
+#endif // __MINGW32__
+
double OS::nan_value() {
+#ifdef _MSC_VER
static const __int64 nanval = 0xfff8000000000000;
return *reinterpret_cast<const double*>(&nanval);
+#else // _MSC_VER
+ return NAN;
+#endif // _MSC_VER
}
@@ -1265,7 +1326,7 @@
bool VirtualMemory::Uncommit(void* address, size_t size) {
ASSERT(IsReserved());
- return VirtualFree(address, size, MEM_DECOMMIT) != NULL;
+ return VirtualFree(address, size, MEM_DECOMMIT) != FALSE;
}
« no previous file with comments | « src/platform.h ('k') | tools/presubmit.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698