OLD | NEW |
---|---|
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
136 return mktime(timeptr); | 136 return mktime(timeptr); |
137 } | 137 } |
138 | 138 |
139 | 139 |
140 int fopen_s(FILE** pFile, const char* filename, const char* mode) { | 140 int fopen_s(FILE** pFile, const char* filename, const char* mode) { |
141 *pFile = fopen(filename, mode); | 141 *pFile = fopen(filename, mode); |
142 return *pFile != NULL ? 0 : 1; | 142 return *pFile != NULL ? 0 : 1; |
143 } | 143 } |
144 | 144 |
145 | 145 |
146 #define _TRUNCATE 0 | |
147 #define STRUNCATE 80 | |
148 | |
146 int _vsnprintf_s(char* buffer, size_t sizeOfBuffer, size_t count, | 149 int _vsnprintf_s(char* buffer, size_t sizeOfBuffer, size_t count, |
147 const char* format, va_list argptr) { | 150 const char* format, va_list argptr) { |
151 ASSERT(count == _TRUNCATE); | |
148 return _vsnprintf(buffer, sizeOfBuffer, format, argptr); | 152 return _vsnprintf(buffer, sizeOfBuffer, format, argptr); |
149 } | 153 } |
150 #define _TRUNCATE 0 | |
151 | |
152 | |
153 int strncpy_s(char* strDest, size_t numberOfElements, | |
154 const char* strSource, size_t count) { | |
155 strncpy(strDest, strSource, count); | |
156 return 0; | |
157 } | |
158 | 154 |
159 | 155 |
156 int strncpy_s(char* dest, size_t dest_size, const char* source, size_t count) { | |
157 CHECK(source != NULL); | |
158 CHECK(dest != NULL); | |
159 CHECK(dest_size > 0); | |
160 | |
161 if (count == _TRUNCATE) { | |
162 while (dest_size && *source != 0) { | |
Vyacheslav Egorov (Chromium)
2011/07/06 12:10:33
Google Style Guide disallows implicit int to boole
| |
163 *(dest++) = *(source++); | |
164 --dest_size; | |
165 } | |
166 if (dest_size == 0) { | |
167 *(dest - 1) = 0; | |
168 return STRUNCATE; | |
169 } | |
170 *dest = 0; | |
171 return 0; | |
172 | |
173 } else { | |
174 while (dest_size && count && *source != 0) { | |
Vyacheslav Egorov (Chromium)
2011/07/06 12:10:33
Ditto.
| |
175 *(dest++) = *(source++); | |
176 --dest_size; | |
177 --count; | |
178 } | |
179 CHECK(dest_size > 0); | |
180 *dest = 0; | |
181 return 0; | |
182 } | |
183 } | |
184 | |
185 | |
160 inline void MemoryBarrier() { | 186 inline void MemoryBarrier() { |
161 int barrier = 0; | 187 int barrier = 0; |
162 __asm__ __volatile__("xchgl %%eax,%0 ":"=r" (barrier)); | 188 __asm__ __volatile__("xchgl %%eax,%0 ":"=r" (barrier)); |
163 } | 189 } |
164 | 190 |
165 #endif // __MINGW32__ | 191 #endif // __MINGW32__ |
166 | 192 |
167 // Generate a pseudo-random number in the range 0-2^31-1. Usually | 193 // Generate a pseudo-random number in the range 0-2^31-1. Usually |
168 // defined in stdlib.h. Missing in both Microsoft Visual Studio C++ and MinGW. | 194 // defined in stdlib.h. Missing in both Microsoft Visual Studio C++ and MinGW. |
169 int random() { | 195 int random() { |
(...skipping 1838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2008 | 2034 |
2009 void Sampler::Stop() { | 2035 void Sampler::Stop() { |
2010 ASSERT(IsActive()); | 2036 ASSERT(IsActive()); |
2011 SamplerThread::RemoveActiveSampler(this); | 2037 SamplerThread::RemoveActiveSampler(this); |
2012 SetActive(false); | 2038 SetActive(false); |
2013 } | 2039 } |
2014 | 2040 |
2015 #endif // ENABLE_LOGGING_AND_PROFILING | 2041 #endif // ENABLE_LOGGING_AND_PROFILING |
2016 | 2042 |
2017 } } // namespace v8::internal | 2043 } } // namespace v8::internal |
OLD | NEW |