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 <dlfcn.h> | |
10 #include <errno.h> | 9 #include <errno.h> |
11 #include <limits.h> | 10 #include <limits.h> |
12 #include <pthread.h> | 11 #include <pthread.h> |
13 #if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__) | 12 #if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__) |
14 #include <pthread_np.h> // for pthread_set_name_np | 13 #include <pthread_np.h> // for pthread_set_name_np |
15 #endif | 14 #endif |
16 #include <sched.h> // for sched_yield | 15 #include <sched.h> // for sched_yield |
17 #include <time.h> | 16 #include <time.h> |
18 #include <unistd.h> | 17 #include <unistd.h> |
19 | 18 |
20 #include <sys/mman.h> | 19 #include <sys/mman.h> |
21 #include <sys/resource.h> | 20 #include <sys/resource.h> |
22 #include <sys/stat.h> | 21 #include <sys/stat.h> |
| 22 #if !defined(__pnacl__) |
23 #include <sys/syscall.h> | 23 #include <sys/syscall.h> |
| 24 #endif |
24 #include <sys/time.h> | 25 #include <sys/time.h> |
25 #include <sys/types.h> | 26 #include <sys/types.h> |
26 #if defined(__linux__) | 27 #if defined(__linux__) && !defined(__pnacl__) |
27 #include <sys/prctl.h> // NOLINT, for prctl | 28 #include <sys/prctl.h> // NOLINT, for prctl |
28 #endif | 29 #endif |
29 #if defined(__APPLE__) || defined(__DragonFly__) || defined(__FreeBSD__) || \ | 30 #if defined(__APPLE__) || defined(__DragonFly__) || defined(__FreeBSD__) || \ |
30 defined(__NetBSD__) || defined(__OpenBSD__) | 31 defined(__NetBSD__) || defined(__OpenBSD__) |
31 #include <sys/sysctl.h> // NOLINT, for sysctl | 32 #include <sys/sysctl.h> // NOLINT, for sysctl |
32 #endif | 33 #endif |
33 | 34 |
34 #include <arpa/inet.h> | |
35 #include <netdb.h> | |
36 #include <netinet/in.h> | |
37 | |
38 #undef MAP_TYPE | 35 #undef MAP_TYPE |
39 | 36 |
40 #if defined(ANDROID) && !defined(V8_ANDROID_LOG_STDOUT) | 37 #if defined(ANDROID) && !defined(V8_ANDROID_LOG_STDOUT) |
41 #define LOG_TAG "v8" | 38 #define LOG_TAG "v8" |
42 #include <android/log.h> // NOLINT | 39 #include <android/log.h> // NOLINT |
43 #endif | 40 #endif |
44 | 41 |
45 #include <cmath> | 42 #include <cmath> |
46 #include <cstdlib> | 43 #include <cstdlib> |
47 | 44 |
48 #include "src/base/lazy-instance.h" | 45 #include "src/base/lazy-instance.h" |
49 #include "src/base/macros.h" | 46 #include "src/base/macros.h" |
50 #include "src/base/platform/platform.h" | 47 #include "src/base/platform/platform.h" |
51 #include "src/base/platform/time.h" | 48 #include "src/base/platform/time.h" |
52 #include "src/base/utils/random-number-generator.h" | 49 #include "src/base/utils/random-number-generator.h" |
53 | 50 |
54 #ifdef V8_FAST_TLS_SUPPORTED | 51 #ifdef V8_FAST_TLS_SUPPORTED |
55 #include "src/base/atomicops.h" | 52 #include "src/base/atomicops.h" |
56 #endif | 53 #endif |
57 | 54 |
| 55 #if V8_OS_MACOSX |
| 56 #include <dlfcn.h> |
| 57 #endif |
| 58 |
58 namespace v8 { | 59 namespace v8 { |
59 namespace base { | 60 namespace base { |
60 | 61 |
61 namespace { | 62 namespace { |
62 | 63 |
63 // 0 is never a valid thread id. | 64 // 0 is never a valid thread id. |
64 const pthread_t kNoThread = (pthread_t) 0; | 65 const pthread_t kNoThread = (pthread_t) 0; |
65 | 66 |
66 bool g_hard_abort = false; | 67 bool g_hard_abort = false; |
67 | 68 |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 | 246 |
246 | 247 |
247 int OS::GetCurrentProcessId() { | 248 int OS::GetCurrentProcessId() { |
248 return static_cast<int>(getpid()); | 249 return static_cast<int>(getpid()); |
249 } | 250 } |
250 | 251 |
251 | 252 |
252 int OS::GetCurrentThreadId() { | 253 int OS::GetCurrentThreadId() { |
253 #if defined(ANDROID) | 254 #if defined(ANDROID) |
254 return static_cast<int>(syscall(__NR_gettid)); | 255 return static_cast<int>(syscall(__NR_gettid)); |
| 256 #elif defined(SYS_gettid) |
| 257 return static_cast<int>(syscall(SYS_gettid)); |
255 #else | 258 #else |
256 return static_cast<int>(syscall(SYS_gettid)); | 259 // PNaCL doesn't have a way to get an integral thread ID, but it doesn't |
257 #endif // defined(ANDROID) | 260 // really matter, because we only need it in PerfJitLogger::LogRecordedBuffer. |
| 261 return 0; |
| 262 #endif |
258 } | 263 } |
259 | 264 |
260 | 265 |
261 // ---------------------------------------------------------------------------- | 266 // ---------------------------------------------------------------------------- |
262 // POSIX date/time support. | 267 // POSIX date/time support. |
263 // | 268 // |
264 | 269 |
265 int OS::GetUserTime(uint32_t* secs, uint32_t* usecs) { | 270 int OS::GetUserTime(uint32_t* secs, uint32_t* usecs) { |
266 struct rusage usage; | 271 struct rusage usage; |
267 | 272 |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
657 | 662 |
658 void Thread::SetThreadLocal(LocalStorageKey key, void* value) { | 663 void Thread::SetThreadLocal(LocalStorageKey key, void* value) { |
659 pthread_key_t pthread_key = LocalKeyToPthreadKey(key); | 664 pthread_key_t pthread_key = LocalKeyToPthreadKey(key); |
660 int result = pthread_setspecific(pthread_key, value); | 665 int result = pthread_setspecific(pthread_key, value); |
661 DCHECK_EQ(0, result); | 666 DCHECK_EQ(0, result); |
662 USE(result); | 667 USE(result); |
663 } | 668 } |
664 | 669 |
665 | 670 |
666 } } // namespace v8::base | 671 } } // namespace v8::base |
OLD | NEW |