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

Side by Side Diff: src/platform-win32.cc

Issue 12210033: Simplify secure API functions workaround for MinGW (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 7 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution. 11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its 12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived 13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission. 14 // from this software without specific prior written permission.
15 // 15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 // Platform specific code for Win32. 28 // Platform specific code for Win32.
29 29
30 // Secure API functions are not available using MinGW with msvcrt.dll
31 // on Windows XP. Make sure MINGW_HAS_SECURE_API is not defined to
32 // disable definition of secure API functions in standard headers that
33 // would conflict with our own implementation.
34 #ifdef __MINGW32__
35 #include <_mingw.h>
36 #ifdef MINGW_HAS_SECURE_API
37 #undef MINGW_HAS_SECURE_API
38 #endif // MINGW_HAS_SECURE_API
39 #endif // __MINGW32__
40
30 #define V8_WIN32_HEADERS_FULL 41 #define V8_WIN32_HEADERS_FULL
31 #include "win32-headers.h" 42 #include "win32-headers.h"
32 43
33 #include "v8.h" 44 #include "v8.h"
34 45
35 #include "codegen.h" 46 #include "codegen.h"
36 #include "platform.h" 47 #include "platform.h"
37 #include "vm-state-inl.h" 48 #include "vm-state-inl.h"
38 49
39 #ifdef _MSC_VER 50 #ifdef _MSC_VER
(...skipping 18 matching lines...) Expand all
58 #define STRUNCATE 80 69 #define STRUNCATE 80
59 70
60 inline void MemoryBarrier() { 71 inline void MemoryBarrier() {
61 int barrier = 0; 72 int barrier = 0;
62 __asm__ __volatile__("xchgl %%eax,%0 ":"=r" (barrier)); 73 __asm__ __volatile__("xchgl %%eax,%0 ":"=r" (barrier));
63 } 74 }
64 75
65 #endif // __MINGW64_VERSION_MAJOR 76 #endif // __MINGW64_VERSION_MAJOR
66 77
67 78
68 #ifdef MINGW_HAS_SECURE_API
69 #define localtime_s v8_localtime_s
70 #define fopen_s v8_fopen_s
71 #define _vsnprintf_s v8_vsnprintf_s
72 #define strncpy_s v8_strncpy_s
73 #endif // MINGW_HAS_SECURE_API
74
75
76 int localtime_s(tm* out_tm, const time_t* time) { 79 int localtime_s(tm* out_tm, const time_t* time) {
77 tm* posix_local_time_struct = localtime(time); 80 tm* posix_local_time_struct = localtime(time);
78 if (posix_local_time_struct == NULL) return 1; 81 if (posix_local_time_struct == NULL) return 1;
79 *out_tm = *posix_local_time_struct; 82 *out_tm = *posix_local_time_struct;
80 return 0; 83 return 0;
81 } 84 }
82 85
83 86
84 int fopen_s(FILE** pFile, const char* filename, const char* mode) { 87 int fopen_s(FILE** pFile, const char* filename, const char* mode) {
85 *pFile = fopen(filename, mode); 88 *pFile = fopen(filename, mode);
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 if (n + 1 > buffer_size) // count for trailing '\0' 814 if (n + 1 > buffer_size) // count for trailing '\0'
812 n = _TRUNCATE; 815 n = _TRUNCATE;
813 int result = strncpy_s(dest.start(), dest.length(), src, n); 816 int result = strncpy_s(dest.start(), dest.length(), src, n);
814 USE(result); 817 USE(result);
815 ASSERT(result == 0 || (n == _TRUNCATE && result == STRUNCATE)); 818 ASSERT(result == 0 || (n == _TRUNCATE && result == STRUNCATE));
816 } 819 }
817 820
818 821
819 #undef _TRUNCATE 822 #undef _TRUNCATE
820 #undef STRUNCATE 823 #undef STRUNCATE
821 #undef localtime_s
822 #undef fopen_s
823 #undef _vsnprintf_s
824 #undef strncpy_s
825 824
826 // We keep the lowest and highest addresses mapped as a quick way of 825 // We keep the lowest and highest addresses mapped as a quick way of
827 // determining that pointers are outside the heap (used mostly in assertions 826 // determining that pointers are outside the heap (used mostly in assertions
828 // and verification). The estimate is conservative, i.e., not all addresses in 827 // and verification). The estimate is conservative, i.e., not all addresses in
829 // 'allocated' space are actually allocated to our heap. The range is 828 // 'allocated' space are actually allocated to our heap. The range is
830 // [lowest, highest), inclusive on the low and and exclusive on the high end. 829 // [lowest, highest), inclusive on the low and and exclusive on the high end.
831 static void* lowest_ever_allocated = reinterpret_cast<void*>(-1); 830 static void* lowest_ever_allocated = reinterpret_cast<void*>(-1);
832 static void* highest_ever_allocated = reinterpret_cast<void*>(0); 831 static void* highest_ever_allocated = reinterpret_cast<void*>(0);
833 832
834 833
(...skipping 1306 matching lines...) Expand 10 before | Expand all | Expand 10 after
2141 2140
2142 2141
2143 void Sampler::Stop() { 2142 void Sampler::Stop() {
2144 ASSERT(IsActive()); 2143 ASSERT(IsActive());
2145 SamplerThread::RemoveActiveSampler(this); 2144 SamplerThread::RemoveActiveSampler(this);
2146 SetActive(false); 2145 SetActive(false);
2147 } 2146 }
2148 2147
2149 2148
2150 } } // namespace v8::internal 2149 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698