},
'gcc': {
'all': {
- 'DIALECTFLAGS': ['-ansi'],
'CCFLAGS': ['$DIALECTFLAGS', '$WARNINGFLAGS'],
'CXXFLAGS': ['$CCFLAGS', '-fno-rtti', '-fno-exceptions'],
- 'LIBS': ['pthread']
},
'mode:debug': {
'CCFLAGS': ['-g', '-O0'],
'mode:release': {
'CCFLAGS': ['-O3', '-fomit-frame-pointer', '-fdata-sections', '-ffunction-sections']
},
+ 'os:linux': {
+ 'CCFLAGS': ['-ansi'],
+ },
+ 'os:macos': {
+ 'CCFLAGS': ['-ansi'],
+ },
'os:freebsd': {
- 'LIBS': ['execinfo']
+ 'CCFLAGS': ['-ansi'],
+ },
+ 'os:win32': {
+ 'CCFLAGS': ['-DWIN32'],
+ 'CXXFLAGS': ['-DWIN32'],
},
'wordsize:64': {
'CCFLAGS': ['-m32'],
'arch:arm': {
'CPPDEFINES': ['ARM']
},
+ 'os:win32': {
+ 'WARNINGFLAGS': ['-Wno-long-long']
+ },
'disassembler:on': {
'CPPDEFINES': ['ENABLE_DISASSEMBLER']
}
'all': {
'LIBPATH': [abspath('.')]
},
+ 'os:linux': {
+ 'LIBS': ['pthread'],
+ },
+ 'os:macos': {
+ 'LIBS': ['pthread'],
+ },
+ 'os:freebsd': {
+ 'LIBS': ['execinfo', 'pthread']
+ },
+ 'os:win32': {
+ 'LIBS': ['winmm']
+ },
'wordsize:64': {
'CCFLAGS': ['-m32'],
'LINKFLAGS': ['-m32']
},
'msvc': {
'all': {
- 'CPPDEFINES': ['_HAS_EXCEPTIONS=0']
+ 'CPPDEFINES': ['_HAS_EXCEPTIONS=0'],
+ 'LIBS': ['winmm']
},
'library:shared': {
'CPPDEFINES': ['USING_V8_SHARED']
},
'gcc': {
'all': {
- 'LIBS': ['pthread'],
'LIBPATH': ['.']
},
+ 'os:linux': {
+ 'LIBS': ['pthread'],
+ },
+ 'os:macos': {
+ 'LIBS': ['pthread'],
+ },
'os:freebsd': {
- 'LIBS': ['execinfo']
+ 'LIBS': ['execinfo', 'pthread']
+ },
+ 'os:win32': {
+ 'LIBS': ['winmm']
},
'wordsize:64': {
'CCFLAGS': ['-m32'],
'all': {
'CCFLAGS': ['/nologo'],
'LINKFLAGS': ['/nologo'],
+ 'LIBS': ['winmm']
},
'library:shared': {
'CPPDEFINES': ['USING_V8_SHARED']
'gcc': {
'console:readline': {
'LIBS': ['readline']
- }
+ },
+ 'os:linux': {
+ 'LIBS': ['pthread'],
+ },
+ 'os:macos': {
+ 'LIBS': ['pthread'],
+ },
+ 'os:freebsd': {
+ 'LIBS': ['pthread'],
+ },
+ 'os:win32': {
+ 'LIBS': ['winmm'],
+ },
},
+ 'msvc': {
+ 'all': {
+ 'LIBS': ['winmm']
+ }
+ }
}
void CPU::DebugBreak() {
-#ifdef WIN32
+#ifdef _MSC_VER
// To avoid Visual Studio runtime support the following code can be used
// instead
// __asm { int 3 }
#include "stdlib.h"
#endif
+/* For MinGW, turn on __NO_ISOCEXT so that its strtod doesn't get added */
+#ifdef __MINGW32__
+#define __NO_ISOCEXT
+#endif /* __MINGW32__ */
+
/* Make sure we use the David M. Gay version of strtod(). On Linux, we
* cannot use the same name (maybe the function does not have weak
* linkage?). */
// -----------------------------------------------------------------------------
// Types
-// Windows is missing the stdint.h header file. Instead we define standard
-// integer types for Windows here.
+// Visual Studio C++ is missing the stdint.h header file. Instead we define
+// standard integer types for Windows here.
-#ifdef WIN32
+#ifdef _MSC_VER
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef short int16_t; // NOLINT
typedef unsigned int uint32_t;
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
-#else
+#else // _MSC_VER
#include <stdint.h> // for intptr_t
-#endif
+#endif // _MSC_VER
namespace v8 { namespace internal {
#define TRACK_MEMORY(name)
#endif
-// define used for helping GCC to make better inlining.
-#ifdef __GNUC__
+// define used for helping GCC to make better inlining. Don't bother for debug
+// builds. On GCC 3.4.5 using __attribute__((always_inline)) causes compilation
+// errors in debug build.
+#if defined(__GNUC__) && !defined(DEBUG)
#if (__GNUC__ >= 4)
#define INLINE(header) inline header __attribute__((always_inline))
#else
#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
#include <process.h> // for _beginthreadex()
#include <stdlib.h>
-#pragma comment(lib, "winmm.lib") // force linkage with winmm.
-
#undef VOID
#undef DELETE
#undef IN
#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);
}
}
-// Generate a pseudo-random number in the range 0-2^31-1. Usually
-// defined in stdlib.h
-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);
}
+#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* out_tm, const time_t* time) {
+ tm* posix_local_time_struct = localtime(time);
+ if (posix_local_time_struct == NULL) return 1;
+ *out_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. Missing in both Microsoft Visual Studio C++ and MinGW.
+int random() {
+ return rand();
+}
+
+
namespace v8 { namespace internal {
double ceiling(double x) {
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;
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();
void OS::DebugBreak() {
+#ifdef _MSC_VER
__debugbreak();
+#else
+ ::DebugBreak();
+#endif
}
#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,
// 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
}
bool VirtualMemory::Uncommit(void* address, size_t size) {
ASSERT(IsReserved());
- return VirtualFree(address, size, MEM_DECOMMIT) != NULL;
+ return VirtualFree(address, size, MEM_DECOMMIT) != FALSE;
}
#ifndef V8_PLATFORM_H_
#define V8_PLATFORM_H_
+// Windows specific stuff.
#ifdef WIN32
+// Microsoft Visual C++ specific stuff.
+#ifdef _MSC_VER
+
enum {
FP_NAN,
FP_INFINITE,
int fpclassify(double x);
int signbit(double x);
+int strncasecmp(const char* s1, const char* s2, int n);
+
+#endif // _MSC_VER
+
+// MinGW specific stuff.
+#ifdef __MINGW32__
+
+// Needed for va_list.
+#include <stdarg.h>
+
+#endif // __MINGW32__
+
+// Random is missing on both Visual Studio and MinGW.
int random();
-int strncasecmp(const char* s1, const char* s2, int n);
+#endif // WIN32
-#else
+// GCC specific stuff
+#ifdef __GNUC__
+#define __GNUC_VERSION__ (__GNUC__ * 10000 + __GNUC_MINOR__ * 100)
// Unfortunately, the INFINITY macro cannot be used with the '-pedantic'
// warning flag and certain versions of GCC due to a bug:
// For now, we use the more involved template-based version from <limits>, but
// only when compiling with GCC versions affected by the bug (2.96.x - 4.0.x)
// __GNUC_PREREQ is not defined in GCC for Mac OS X, so we define our own macro
-#if defined(__GNUC__)
-#define __GNUC_VERSION__ (__GNUC__ * 10000 + __GNUC_MINOR__ * 100)
-#endif
-
#if __GNUC_VERSION__ >= 29600 && __GNUC_VERSION__ < 40100
#include <limits>
#undef INFINITY
#define INFINITY std::numeric_limits<double>::infinity()
#endif
-#endif // WIN32
+#endif // __GNUC__
namespace v8 { namespace internal {
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
- Version="8,00"
+ Version="8.00"
Name="d8"
ProjectGUID="{7E4C7D2D-A4B9-40B9-8192-22654E626F6C}"
RootNamespace="d8"
/>
<Tool
Name="VCLinkerTool"
+ AdditionalDependencies="winmm.lib"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCLinkerTool"
+ AdditionalDependencies="winmm.lib"
/>
<Tool
Name="VCALinkTool"
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
- Version="8,00"
+ Version="8.00"
Name="v8_cctest"
ProjectGUID="{97ECC711-7430-4FC4-90FD-004DA880E72A}"
RootNamespace="v8_cctest"
/>
<Tool
Name="VCLinkerTool"
+ AdditionalDependencies="winmm.lib"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCLinkerTool"
+ AdditionalDependencies="winmm.lib"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCLinkerTool"
+ AdditionalDependencies="winmm.lib"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCLinkerTool"
+ AdditionalDependencies="winmm.lib"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCLinkerTool"
+ AdditionalDependencies="winmm.lib"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCLinkerTool"
+ AdditionalDependencies="winmm.lib"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCLinkerTool"
+ AdditionalDependencies="winmm.lib"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCLinkerTool"
+ AdditionalDependencies="winmm.lib"
/>
<Tool
Name="VCALinkTool"