OLD | NEW |
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 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 return _strnicmp(s1, s2, n); | 44 return _strnicmp(s1, s2, n); |
45 } | 45 } |
46 | 46 |
47 #endif // _MSC_VER | 47 #endif // _MSC_VER |
48 | 48 |
49 | 49 |
50 // Extra functions for MinGW. Most of these are the _s functions which are in | 50 // Extra functions for MinGW. Most of these are the _s functions which are in |
51 // the Microsoft Visual Studio C++ CRT. | 51 // the Microsoft Visual Studio C++ CRT. |
52 #ifdef __MINGW32__ | 52 #ifdef __MINGW32__ |
53 | 53 |
| 54 |
| 55 #ifndef __MINGW64_VERSION_MAJOR |
| 56 |
| 57 #define _TRUNCATE 0 |
| 58 #define STRUNCATE 80 |
| 59 |
| 60 inline void MemoryBarrier() { |
| 61 int barrier = 0; |
| 62 __asm__ __volatile__("xchgl %%eax,%0 ":"=r" (barrier)); |
| 63 } |
| 64 |
| 65 #endif // __MINGW64_VERSION_MAJOR |
| 66 |
| 67 |
| 68 #ifndef MINGW_HAS_SECURE_API |
| 69 |
54 int localtime_s(tm* out_tm, const time_t* time) { | 70 int localtime_s(tm* out_tm, const time_t* time) { |
55 tm* posix_local_time_struct = localtime(time); | 71 tm* posix_local_time_struct = localtime(time); |
56 if (posix_local_time_struct == NULL) return 1; | 72 if (posix_local_time_struct == NULL) return 1; |
57 *out_tm = *posix_local_time_struct; | 73 *out_tm = *posix_local_time_struct; |
58 return 0; | 74 return 0; |
59 } | 75 } |
60 | 76 |
61 | 77 |
62 int fopen_s(FILE** pFile, const char* filename, const char* mode) { | 78 int fopen_s(FILE** pFile, const char* filename, const char* mode) { |
63 *pFile = fopen(filename, mode); | 79 *pFile = fopen(filename, mode); |
64 return *pFile != NULL ? 0 : 1; | 80 return *pFile != NULL ? 0 : 1; |
65 } | 81 } |
66 | 82 |
67 | |
68 #ifndef __MINGW64_VERSION_MAJOR | |
69 #define _TRUNCATE 0 | |
70 #define STRUNCATE 80 | |
71 #endif // __MINGW64_VERSION_MAJOR | |
72 | |
73 | |
74 int _vsnprintf_s(char* buffer, size_t sizeOfBuffer, size_t count, | 83 int _vsnprintf_s(char* buffer, size_t sizeOfBuffer, size_t count, |
75 const char* format, va_list argptr) { | 84 const char* format, va_list argptr) { |
76 ASSERT(count == _TRUNCATE); | 85 ASSERT(count == _TRUNCATE); |
77 return _vsnprintf(buffer, sizeOfBuffer, format, argptr); | 86 return _vsnprintf(buffer, sizeOfBuffer, format, argptr); |
78 } | 87 } |
79 | 88 |
80 | 89 |
81 int strncpy_s(char* dest, size_t dest_size, const char* source, size_t count) { | 90 int strncpy_s(char* dest, size_t dest_size, const char* source, size_t count) { |
82 CHECK(source != NULL); | 91 CHECK(source != NULL); |
83 CHECK(dest != NULL); | 92 CHECK(dest != NULL); |
(...skipping 13 matching lines...) Expand all Loading... |
97 *(dest++) = *(source++); | 106 *(dest++) = *(source++); |
98 --dest_size; | 107 --dest_size; |
99 --count; | 108 --count; |
100 } | 109 } |
101 } | 110 } |
102 CHECK_GT(dest_size, 0); | 111 CHECK_GT(dest_size, 0); |
103 *dest = 0; | 112 *dest = 0; |
104 return 0; | 113 return 0; |
105 } | 114 } |
106 | 115 |
107 | 116 #endif // MINGW_HAS_SECURE_API |
108 #ifndef __MINGW64_VERSION_MAJOR | |
109 | |
110 inline void MemoryBarrier() { | |
111 int barrier = 0; | |
112 __asm__ __volatile__("xchgl %%eax,%0 ":"=r" (barrier)); | |
113 } | |
114 | |
115 #endif // __MINGW64_VERSION_MAJOR | |
116 | |
117 | 117 |
118 #endif // __MINGW32__ | 118 #endif // __MINGW32__ |
119 | 119 |
120 // Generate a pseudo-random number in the range 0-2^31-1. Usually | 120 // Generate a pseudo-random number in the range 0-2^31-1. Usually |
121 // defined in stdlib.h. Missing in both Microsoft Visual Studio C++ and MinGW. | 121 // defined in stdlib.h. Missing in both Microsoft Visual Studio C++ and MinGW. |
122 int random() { | 122 int random() { |
123 return rand(); | 123 return rand(); |
124 } | 124 } |
125 | 125 |
126 | 126 |
(...skipping 1975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2102 | 2102 |
2103 | 2103 |
2104 void Sampler::Stop() { | 2104 void Sampler::Stop() { |
2105 ASSERT(IsActive()); | 2105 ASSERT(IsActive()); |
2106 SamplerThread::RemoveActiveSampler(this); | 2106 SamplerThread::RemoveActiveSampler(this); |
2107 SetActive(false); | 2107 SetActive(false); |
2108 } | 2108 } |
2109 | 2109 |
2110 | 2110 |
2111 } } // namespace v8::internal | 2111 } } // namespace v8::internal |
OLD | NEW |