| @@ -1,51 +1,82 @@ | | | @@ -1,51 +1,82 @@ |
1 | $NetBSD: patch-deps_v8_src_base_platform_platform-posix.cc,v 1.9 2022/05/05 07:08:06 adam Exp $ | | 1 | $NetBSD: patch-deps_v8_src_base_platform_platform-posix.cc,v 1.10 2022/08/17 21:15:27 tnn Exp $ |
2 | | | 2 | |
3 | Use sysconf(_SC_THREAD_STACK_MIN) instead of PTHREAD_STACK_MIN. | | 3 | Use sysconf(_SC_THREAD_STACK_MIN) instead of PTHREAD_STACK_MIN. |
4 | Cast explicitly. | | 4 | Cast explicitly. |
| | | 5 | Remove legacy madvise(2) prototypes, prefer posix_madvise(2) if available. |
5 | | | 6 | |
6 | Avoid using a random hint, some low numbers cause spurious ENOMEM on netbsd | | 7 | Avoid using a random hint, some low numbers cause spurious ENOMEM on netbsd |
7 | (PR port-arm/55533) | | 8 | (PR port-arm/55533) |
8 | | | 9 | |
9 | --- deps/v8/src/base/platform/platform-posix.cc.orig 2022-05-03 08:18:09.000000000 +0000 | | 10 | --- deps/v8/src/base/platform/platform-posix.cc.orig 2022-07-26 14:30:08.000000000 +0000 |
10 | +++ deps/v8/src/base/platform/platform-posix.cc | | 11 | +++ deps/v8/src/base/platform/platform-posix.cc |
11 | @@ -384,6 +384,10 @@ void* OS::GetRandomMmapAddr() { | | 12 | @@ -72,14 +72,6 @@ |
| | | 13 | #define MAP_ANONYMOUS MAP_ANON |
| | | 14 | #endif |
| | | 15 | |
| | | 16 | -#if defined(V8_OS_SOLARIS) |
| | | 17 | -#if (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE > 2) || defined(__EXTENSIONS__) |
| | | 18 | -extern "C" int madvise(caddr_t, size_t, int); |
| | | 19 | -#else |
| | | 20 | -extern int madvise(caddr_t, size_t, int); |
| | | 21 | -#endif |
| | | 22 | -#endif |
| | | 23 | - |
| | | 24 | #ifndef MADV_FREE |
| | | 25 | #define MADV_FREE MADV_DONTNEED |
| | | 26 | #endif |
| | | 27 | @@ -384,6 +376,10 @@ void* OS::GetRandomMmapAddr() { |
12 | #endif | | 28 | #endif |
13 | #endif | | 29 | #endif |
14 | #endif | | 30 | #endif |
15 | + | | 31 | + |
16 | +#if V8_OS_NETBSD | | 32 | +#if V8_OS_NETBSD |
17 | + raw_addr = 0; | | 33 | + raw_addr = 0; |
18 | +#endif | | 34 | +#endif |
19 | return reinterpret_cast<void*>(raw_addr); | | 35 | return reinterpret_cast<void*>(raw_addr); |
20 | } | | 36 | } |
21 | | | 37 | |
22 | @@ -733,6 +737,8 @@ int OS::GetCurrentThreadId() { | | 38 | @@ -515,12 +511,10 @@ bool OS::DiscardSystemPages(void* addres |
| | | 39 | // MADV_FREE_REUSABLE sometimes fails, so fall back to MADV_DONTNEED. |
| | | 40 | ret = madvise(address, size, MADV_DONTNEED); |
| | | 41 | } |
| | | 42 | -#elif defined(_AIX) || defined(V8_OS_SOLARIS) |
| | | 43 | - int ret = madvise(reinterpret_cast<caddr_t>(address), size, MADV_FREE); |
| | | 44 | +#elif defined(POSIX_MADV_DONTNEED) |
| | | 45 | + int ret = posix_madvise(address, size, POSIX_MADV_DONTNEED); |
| | | 46 | if (ret != 0 && errno == ENOSYS) |
| | | 47 | return true; // madvise is not available on all systems. |
| | | 48 | - if (ret != 0 && errno == EINVAL) |
| | | 49 | - ret = madvise(reinterpret_cast<caddr_t>(address), size, MADV_DONTNEED); |
| | | 50 | #else |
| | | 51 | int ret = madvise(address, size, MADV_DONTNEED); |
| | | 52 | #endif |
| | | 53 | @@ -733,6 +727,8 @@ int OS::GetCurrentThreadId() { |
23 | return static_cast<int>(syscall(__NR_gettid)); | | 54 | return static_cast<int>(syscall(__NR_gettid)); |
24 | #elif V8_OS_ANDROID | | 55 | #elif V8_OS_ANDROID |
25 | return static_cast<int>(gettid()); | | 56 | return static_cast<int>(gettid()); |
26 | +#elif V8_OS_NETBSD || V8_OS_FREEBSD | | 57 | +#elif V8_OS_NETBSD || V8_OS_FREEBSD |
27 | + return static_cast<int>(reinterpret_cast<intptr_t>(pthread_self())); | | 58 | + return static_cast<int>(reinterpret_cast<intptr_t>(pthread_self())); |
28 | #elif V8_OS_AIX | | 59 | #elif V8_OS_AIX |
29 | return static_cast<int>(thread_self()); | | 60 | return static_cast<int>(thread_self()); |
30 | #elif V8_OS_FUCHSIA | | 61 | #elif V8_OS_FUCHSIA |
31 | @@ -1000,7 +1006,11 @@ Thread::Thread(const Options& options) | | 62 | @@ -1000,7 +996,11 @@ Thread::Thread(const Options& options) |
32 | : data_(new PlatformData), | | 63 | : data_(new PlatformData), |
33 | stack_size_(options.stack_size()), | | 64 | stack_size_(options.stack_size()), |
34 | start_semaphore_(nullptr) { | | 65 | start_semaphore_(nullptr) { |
35 | +#if V8_OS_NETBSD | | 66 | +#if V8_OS_NETBSD |
36 | + const int min_stack_size = sysconf(_SC_THREAD_STACK_MIN); | | 67 | + const int min_stack_size = sysconf(_SC_THREAD_STACK_MIN); |
37 | +#else | | 68 | +#else |
38 | const int min_stack_size = static_cast<int>(PTHREAD_STACK_MIN); | | 69 | const int min_stack_size = static_cast<int>(PTHREAD_STACK_MIN); |
39 | +#endif | | 70 | +#endif |
40 | if (stack_size_ > 0) stack_size_ = std::max(stack_size_, min_stack_size); | | 71 | if (stack_size_ > 0) stack_size_ = std::max(stack_size_, min_stack_size); |
41 | set_name(options.name()); | | 72 | set_name(options.name()); |
42 | } | | 73 | } |
43 | @@ -1016,7 +1026,7 @@ static void SetThreadName(const char* na | | 74 | @@ -1016,7 +1016,7 @@ static void SetThreadName(const char* na |
44 | pthread_set_name_np(pthread_self(), name); | | 75 | pthread_set_name_np(pthread_self(), name); |
45 | #elif V8_OS_NETBSD | | 76 | #elif V8_OS_NETBSD |
46 | STATIC_ASSERT(Thread::kMaxThreadNameLength <= PTHREAD_MAX_NAMELEN_NP); | | 77 | STATIC_ASSERT(Thread::kMaxThreadNameLength <= PTHREAD_MAX_NAMELEN_NP); |
47 | - pthread_setname_np(pthread_self(), "%s", name); | | 78 | - pthread_setname_np(pthread_self(), "%s", name); |
48 | + pthread_setname_np(pthread_self(), "%s", (void *)name); | | 79 | + pthread_setname_np(pthread_self(), "%s", (void *)name); |
49 | #elif V8_OS_DARWIN | | 80 | #elif V8_OS_DARWIN |
50 | // pthread_setname_np is only available in 10.6 or later, so test | | 81 | // pthread_setname_np is only available in 10.6 or later, so test |
51 | // for it at runtime. | | 82 | // for it at runtime. |