OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Platform-specific code for POSIX goes here. This is not a platform on its | 5 // Platform-specific code for POSIX goes here. This is not a platform on its |
6 // own, but contains the parts which are the same across the POSIX platforms | 6 // own, but contains the parts which are the same across the POSIX platforms |
7 // Linux, MacOS, FreeBSD, OpenBSD, NetBSD and QNX. | 7 // Linux, MacOS, FreeBSD, OpenBSD, NetBSD and QNX. |
8 | 8 |
9 #include <errno.h> | 9 #include <errno.h> |
10 #include <limits.h> | 10 #include <limits.h> |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 asm("int $3"); | 242 asm("int $3"); |
243 #endif // V8_OS_NACL | 243 #endif // V8_OS_NACL |
244 #elif V8_HOST_ARCH_X64 | 244 #elif V8_HOST_ARCH_X64 |
245 asm("int $3"); | 245 asm("int $3"); |
246 #else | 246 #else |
247 #error Unsupported host architecture. | 247 #error Unsupported host architecture. |
248 #endif | 248 #endif |
249 } | 249 } |
250 | 250 |
251 | 251 |
252 // ---------------------------------------------------------------------------- | |
253 // Math functions | |
254 | |
255 double OS::nan_value() { | |
256 // NAN from math.h is defined in C99 and not in POSIX. | |
257 return NAN; | |
258 } | |
259 | |
260 | |
261 int OS::GetCurrentProcessId() { | 252 int OS::GetCurrentProcessId() { |
262 return static_cast<int>(getpid()); | 253 return static_cast<int>(getpid()); |
263 } | 254 } |
264 | 255 |
265 | 256 |
266 int OS::GetCurrentThreadId() { | 257 int OS::GetCurrentThreadId() { |
267 #if V8_OS_MACOSX || (V8_OS_ANDROID && defined(__APPLE__)) | 258 #if V8_OS_MACOSX || (V8_OS_ANDROID && defined(__APPLE__)) |
268 return static_cast<int>(pthread_mach_thread_np(pthread_self())); | 259 return static_cast<int>(pthread_mach_thread_np(pthread_self())); |
269 #elif V8_OS_LINUX | 260 #elif V8_OS_LINUX |
270 return static_cast<int>(syscall(__NR_gettid)); | 261 return static_cast<int>(syscall(__NR_gettid)); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 DCHECK(cache == NULL); | 303 DCHECK(cache == NULL); |
313 } | 304 } |
314 | 305 |
315 | 306 |
316 void OS::ClearTimezoneCache(TimezoneCache* cache) { | 307 void OS::ClearTimezoneCache(TimezoneCache* cache) { |
317 DCHECK(cache == NULL); | 308 DCHECK(cache == NULL); |
318 } | 309 } |
319 | 310 |
320 | 311 |
321 double OS::DaylightSavingsOffset(double time, TimezoneCache*) { | 312 double OS::DaylightSavingsOffset(double time, TimezoneCache*) { |
322 if (std::isnan(time)) return nan_value(); | 313 if (std::isnan(time)) return std::numeric_limits<double>::quiet_NaN(); |
323 time_t tv = static_cast<time_t>(std::floor(time/msPerSecond)); | 314 time_t tv = static_cast<time_t>(std::floor(time/msPerSecond)); |
324 struct tm* t = localtime(&tv); | 315 struct tm* t = localtime(&tv); |
325 if (NULL == t) return nan_value(); | 316 if (NULL == t) return std::numeric_limits<double>::quiet_NaN(); |
326 return t->tm_isdst > 0 ? 3600 * msPerSecond : 0; | 317 return t->tm_isdst > 0 ? 3600 * msPerSecond : 0; |
327 } | 318 } |
328 | 319 |
329 | 320 |
330 int OS::GetLastError() { | 321 int OS::GetLastError() { |
331 return errno; | 322 return errno; |
332 } | 323 } |
333 | 324 |
334 | 325 |
335 // ---------------------------------------------------------------------------- | 326 // ---------------------------------------------------------------------------- |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
680 | 671 |
681 void Thread::SetThreadLocal(LocalStorageKey key, void* value) { | 672 void Thread::SetThreadLocal(LocalStorageKey key, void* value) { |
682 pthread_key_t pthread_key = LocalKeyToPthreadKey(key); | 673 pthread_key_t pthread_key = LocalKeyToPthreadKey(key); |
683 int result = pthread_setspecific(pthread_key, value); | 674 int result = pthread_setspecific(pthread_key, value); |
684 DCHECK_EQ(0, result); | 675 DCHECK_EQ(0, result); |
685 USE(result); | 676 USE(result); |
686 } | 677 } |
687 | 678 |
688 | 679 |
689 } } // namespace v8::base | 680 } } // namespace v8::base |
OLD | NEW |