Commit c26b3c29 authored by yangguo@chromium.org's avatar yangguo@chromium.org

Do not rely on secure API functions when using MinGW-w64

Windows XP does not provide secure API functions in msvcrt.dll but
newer versions of Windows do. Avoid using secure API functions for
compatibility with msvcrt.dll on Windows XP.

Contributed by net147@gmail.com

BUGS=
TEST=

Review URL: https://chromiumcodereview.appspot.com/12189010
Patch from Jonathan Liu <net147@gmail.com>.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13603 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent d6622203
......@@ -65,7 +65,13 @@ inline void MemoryBarrier() {
#endif // __MINGW64_VERSION_MAJOR
#ifndef MINGW_HAS_SECURE_API
#ifdef MINGW_HAS_SECURE_API
#define localtime_s v8_localtime_s
#define fopen_s v8_fopen_s
#define _vsnprintf_s v8_vsnprintf_s
#define strncpy_s v8_strncpy_s
#endif // MINGW_HAS_SECURE_API
int localtime_s(tm* out_tm, const time_t* time) {
tm* posix_local_time_struct = localtime(time);
......@@ -113,8 +119,6 @@ int strncpy_s(char* dest, size_t dest_size, const char* source, size_t count) {
return 0;
}
#endif // MINGW_HAS_SECURE_API
#endif // __MINGW32__
// Generate a pseudo-random number in the range 0-2^31-1. Usually
......@@ -202,7 +206,7 @@ UNARY_MATH_FUNCTION(log, CreateTranscendentalFunction(TranscendentalCache::LOG))
UNARY_MATH_FUNCTION(exp, CreateExpFunction())
UNARY_MATH_FUNCTION(sqrt, CreateSqrtFunction())
#undef MATH_FUNCTION
#undef UNARY_MATH_FUNCTION
void lazily_initialize_fast_exp() {
......@@ -812,6 +816,13 @@ void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) {
}
#undef _TRUNCATE
#undef STRUNCATE
#undef localtime_s
#undef fopen_s
#undef _vsnprintf_s
#undef strncpy_s
// We keep the lowest and highest addresses mapped as a quick way of
// determining that pointers are outside the heap (used mostly in assertions
// and verification). The estimate is conservative, i.e., not all addresses in
......@@ -1218,6 +1229,11 @@ TLHELP32_FUNCTION_LIST(DLL_FUNC_LOADED)
// application is closed.
}
#undef DBGHELP_FUNCTION_LIST
#undef TLHELP32_FUNCTION_LIST
#undef DLL_FUNC_VAR
#undef DLL_FUNC_TYPE
// Load the symbols for generating stack traces.
static bool LoadSymbols(HANDLE process_handle) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment