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> | 9 #include <dlfcn.h> |
10 #include <errno.h> | 10 #include <errno.h> |
11 #include <limits.h> | 11 #include <limits.h> |
12 #include <pthread.h> | 12 #include <pthread.h> |
13 #if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__) | 13 #if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__) |
14 #include <pthread_np.h> // for pthread_set_name_np | 14 #include <pthread_np.h> // for pthread_set_name_np |
15 #endif | 15 #endif |
16 #include <sched.h> // for sched_yield | 16 #include <sched.h> // for sched_yield |
17 #include <time.h> | 17 #include <time.h> |
18 #include <unistd.h> | 18 #include <unistd.h> |
19 | 19 |
20 #include <sys/mman.h> | 20 #include <sys/mman.h> |
21 #include <sys/resource.h> | 21 #include <sys/resource.h> |
22 #include <sys/stat.h> | 22 #include <sys/stat.h> |
23 #include <sys/syscall.h> | |
24 #include <sys/time.h> | 23 #include <sys/time.h> |
25 #include <sys/types.h> | 24 #include <sys/types.h> |
| 25 |
26 #if defined(__linux__) | 26 #if defined(__linux__) |
27 #include <sys/prctl.h> // NOLINT, for prctl | 27 #include <sys/prctl.h> // NOLINT, for prctl |
28 #endif | 28 #endif |
29 #if defined(__APPLE__) || defined(__DragonFly__) || defined(__FreeBSD__) || \ | 29 #if defined(__APPLE__) || defined(__DragonFly__) || defined(__FreeBSD__) || \ |
30 defined(__NetBSD__) || defined(__OpenBSD__) | 30 defined(__NetBSD__) || defined(__OpenBSD__) |
31 #include <sys/sysctl.h> // NOLINT, for sysctl | 31 #include <sys/sysctl.h> // NOLINT, for sysctl |
32 #endif | 32 #endif |
33 | 33 |
34 #include <arpa/inet.h> | 34 #include <arpa/inet.h> |
35 #include <netdb.h> | 35 #include <netdb.h> |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 // NAN from math.h is defined in C99 and not in POSIX. | 311 // NAN from math.h is defined in C99 and not in POSIX. |
312 return NAN; | 312 return NAN; |
313 } | 313 } |
314 | 314 |
315 | 315 |
316 int OS::GetCurrentProcessId() { | 316 int OS::GetCurrentProcessId() { |
317 return static_cast<int>(getpid()); | 317 return static_cast<int>(getpid()); |
318 } | 318 } |
319 | 319 |
320 | 320 |
321 int OS::GetCurrentThreadId() { | |
322 return static_cast<int>(syscall(SYS_gettid)); | |
323 } | |
324 | |
325 | |
326 // ---------------------------------------------------------------------------- | 321 // ---------------------------------------------------------------------------- |
327 // POSIX date/time support. | 322 // POSIX date/time support. |
328 // | 323 // |
329 | 324 |
330 int OS::GetUserTime(uint32_t* secs, uint32_t* usecs) { | 325 int OS::GetUserTime(uint32_t* secs, uint32_t* usecs) { |
331 struct rusage usage; | 326 struct rusage usage; |
332 | 327 |
333 if (getrusage(RUSAGE_SELF, &usage) < 0) return -1; | 328 if (getrusage(RUSAGE_SELF, &usage) < 0) return -1; |
334 *secs = usage.ru_utime.tv_sec; | 329 *secs = usage.ru_utime.tv_sec; |
335 *usecs = usage.ru_utime.tv_usec; | 330 *usecs = usage.ru_utime.tv_usec; |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
722 | 717 |
723 void Thread::SetThreadLocal(LocalStorageKey key, void* value) { | 718 void Thread::SetThreadLocal(LocalStorageKey key, void* value) { |
724 pthread_key_t pthread_key = LocalKeyToPthreadKey(key); | 719 pthread_key_t pthread_key = LocalKeyToPthreadKey(key); |
725 int result = pthread_setspecific(pthread_key, value); | 720 int result = pthread_setspecific(pthread_key, value); |
726 ASSERT_EQ(0, result); | 721 ASSERT_EQ(0, result); |
727 USE(result); | 722 USE(result); |
728 } | 723 } |
729 | 724 |
730 | 725 |
731 } } // namespace v8::base | 726 } } // namespace v8::base |
OLD | NEW |