| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium 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 #include "base/threading/platform_thread.h" | 5 #include "base/threading/platform_thread.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <sys/prctl.h> | 9 #include <sys/prctl.h> |
| 10 #include <sys/resource.h> | 10 #include <sys/resource.h> |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 // Set the name for the LWP (which gets truncated to 15 characters). | 77 // Set the name for the LWP (which gets truncated to 15 characters). |
| 78 int err = prctl(PR_SET_NAME, name.c_str()); | 78 int err = prctl(PR_SET_NAME, name.c_str()); |
| 79 if (err < 0 && errno != EPERM) | 79 if (err < 0 && errno != EPERM) |
| 80 DPLOG(ERROR) << "prctl(PR_SET_NAME)"; | 80 DPLOG(ERROR) << "prctl(PR_SET_NAME)"; |
| 81 } | 81 } |
| 82 | 82 |
| 83 | 83 |
| 84 void InitThreading() { | 84 void InitThreading() { |
| 85 } | 85 } |
| 86 | 86 |
| 87 void InitOnThread() { | |
| 88 // Threads on linux/android may inherit their priority from the thread | |
| 89 // where they were created. This sets all new threads to the default. | |
| 90 PlatformThread::SetCurrentThreadPriority(ThreadPriority::NORMAL); | |
| 91 } | |
| 92 | |
| 93 void TerminateOnThread() { | 87 void TerminateOnThread() { |
| 94 base::android::DetachFromVM(); | 88 base::android::DetachFromVM(); |
| 95 } | 89 } |
| 96 | 90 |
| 97 size_t GetDefaultThreadStackSize(const pthread_attr_t& attributes) { | 91 size_t GetDefaultThreadStackSize(const pthread_attr_t& attributes) { |
| 98 #if !defined(ADDRESS_SANITIZER) | 92 #if !defined(ADDRESS_SANITIZER) |
| 99 return 0; | 93 return 0; |
| 100 #else | 94 #else |
| 101 // AddressSanitizer bloats the stack approximately 2x. Default stack size of | 95 // AddressSanitizer bloats the stack approximately 2x. Default stack size of |
| 102 // 1Mb is not enough for some tests (see http://crbug.com/263749 for example). | 96 // 1Mb is not enough for some tests (see http://crbug.com/263749 for example). |
| 103 return 2 * (1 << 20); // 2Mb | 97 return 2 * (1 << 20); // 2Mb |
| 104 #endif | 98 #endif |
| 105 } | 99 } |
| 106 | 100 |
| 107 bool RegisterThreadUtils(JNIEnv* env) { | 101 bool RegisterThreadUtils(JNIEnv* env) { |
| 108 return RegisterNativesImpl(env); | 102 return RegisterNativesImpl(env); |
| 109 } | 103 } |
| 110 | 104 |
| 111 } // namespace base | 105 } // namespace base |
| OLD | NEW |