mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-12 21:30:45 +01:00
Revert "Remove criticalsection.cc dependency on platform_thread.cc."
This reverts commit 5af97ee3ad
.
Reason for revert: Breaks chrome compilation on Fuchsia, preventing rolls.
Sample failed bot run: https://ci.chromium.org/buildbot/tryserver.chromium.linux/fuchsia_arm64/59693
Sample compiler error:
In file included from ../../third_party/webrtc/rtc_base/platform_thread_types.cc:11:
../../third_party/webrtc/rtc_base/platform_thread_types.h:30:9: error: unknown type name 'pthread_t'
typedef pthread_t PlatformThreadRef;
^
../../third_party/webrtc/rtc_base/platform_thread_types.cc:47:10: error: use of undeclared identifier 'pthread_self'; did you mean 'zx_thread_self'?
return pthread_self();
^~~~~~~~~~~~
zx_thread_self
../../third_party/fuchsia-sdk/sysroot/aarch64-fuchsia/include/zircon/process.h:21:13: note: 'zx_thread_self' declared here
zx_handle_t zx_thread_self(void);
^
../../third_party/webrtc/rtc_base/platform_thread_types.cc:55:10: error: use of undeclared identifier 'pthread_equal'
return pthread_equal(a, b);
^
Original change's description:
> Remove criticalsection.cc dependency on platform_thread.cc.
>
> As part of this, I'm moving global thread related functions over to
> platform_thread_types.* and introducing platform_thread_types.cc
> for the implementation.
>
> Change-Id: I4624877fb379e77d215f4ecd60f20b06d8df3ce5
> Bug: webrtc:8893
> Reviewed-on: https://webrtc-review.googlesource.com/53940
> Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
> Commit-Queue: Tommi <tommi@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#22037}
TBR=danilchap@webrtc.org,tommi@webrtc.org
Change-Id: I73cca942eedf804a0f3ed5a10f01135fbc6f275b
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:8893
Reviewed-on: https://webrtc-review.googlesource.com/54340
Reviewed-by: Guido Urdaneta <guidou@webrtc.org>
Commit-Queue: Guido Urdaneta <guidou@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22048}
This commit is contained in:
parent
2a79f50a31
commit
08ff1733fb
6 changed files with 70 additions and 97 deletions
|
@ -217,7 +217,6 @@ rtc_source_set("rtc_base_approved_generic") {
|
|||
"platform_file.h",
|
||||
"platform_thread.cc",
|
||||
"platform_thread.h",
|
||||
"platform_thread_types.cc",
|
||||
"platform_thread_types.h",
|
||||
"ptr_util.h",
|
||||
"race_checker.cc",
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "rtc_base/criticalsection.h"
|
||||
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/platform_thread_types.h"
|
||||
#include "rtc_base/platform_thread.h"
|
||||
|
||||
// TODO(tommi): Split this file up to per-platform implementation files.
|
||||
|
||||
|
|
|
@ -25,6 +25,66 @@
|
|||
#endif
|
||||
|
||||
namespace rtc {
|
||||
|
||||
PlatformThreadId CurrentThreadId() {
|
||||
PlatformThreadId ret;
|
||||
#if defined(WEBRTC_WIN)
|
||||
ret = GetCurrentThreadId();
|
||||
#elif defined(WEBRTC_POSIX)
|
||||
#if defined(WEBRTC_MAC) || defined(WEBRTC_IOS)
|
||||
ret = pthread_mach_thread_np(pthread_self());
|
||||
#elif defined(WEBRTC_ANDROID)
|
||||
ret = gettid();
|
||||
#elif defined(WEBRTC_FUCHSIA)
|
||||
ret = zx_thread_self();
|
||||
#elif defined(WEBRTC_LINUX)
|
||||
ret = syscall(__NR_gettid);
|
||||
#else
|
||||
// Default implementation for nacl and solaris.
|
||||
ret = reinterpret_cast<pid_t>(pthread_self());
|
||||
#endif
|
||||
#endif // defined(WEBRTC_POSIX)
|
||||
RTC_DCHECK(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
PlatformThreadRef CurrentThreadRef() {
|
||||
#if defined(WEBRTC_WIN)
|
||||
return GetCurrentThreadId();
|
||||
#elif defined(WEBRTC_POSIX)
|
||||
return pthread_self();
|
||||
#endif
|
||||
}
|
||||
|
||||
bool IsThreadRefEqual(const PlatformThreadRef& a, const PlatformThreadRef& b) {
|
||||
#if defined(WEBRTC_WIN)
|
||||
return a == b;
|
||||
#elif defined(WEBRTC_POSIX)
|
||||
return pthread_equal(a, b);
|
||||
#endif
|
||||
}
|
||||
|
||||
void SetCurrentThreadName(const char* name) {
|
||||
#if defined(WEBRTC_WIN)
|
||||
struct {
|
||||
DWORD dwType;
|
||||
LPCSTR szName;
|
||||
DWORD dwThreadID;
|
||||
DWORD dwFlags;
|
||||
} threadname_info = {0x1000, name, static_cast<DWORD>(-1), 0};
|
||||
|
||||
__try {
|
||||
::RaiseException(0x406D1388, 0, sizeof(threadname_info) / sizeof(DWORD),
|
||||
reinterpret_cast<ULONG_PTR*>(&threadname_info));
|
||||
} __except (EXCEPTION_EXECUTE_HANDLER) {
|
||||
}
|
||||
#elif defined(WEBRTC_LINUX) || defined(WEBRTC_ANDROID)
|
||||
prctl(PR_SET_NAME, reinterpret_cast<unsigned long>(name));
|
||||
#elif defined(WEBRTC_MAC) || defined(WEBRTC_IOS)
|
||||
pthread_setname_np(name);
|
||||
#endif
|
||||
}
|
||||
|
||||
namespace {
|
||||
#if defined(WEBRTC_WIN)
|
||||
void CALLBACK RaiseFlag(ULONG_PTR param) {
|
||||
|
|
|
@ -20,6 +20,15 @@
|
|||
|
||||
namespace rtc {
|
||||
|
||||
PlatformThreadId CurrentThreadId();
|
||||
PlatformThreadRef CurrentThreadRef();
|
||||
|
||||
// Compares two thread identifiers for equality.
|
||||
bool IsThreadRefEqual(const PlatformThreadRef& a, const PlatformThreadRef& b);
|
||||
|
||||
// Sets the current thread name.
|
||||
void SetCurrentThreadName(const char* name);
|
||||
|
||||
// Callback function that the spawned thread will enter once spawned.
|
||||
// A return value of false is interpreted as that the function has no
|
||||
// more work to do and that the thread can be released.
|
||||
|
|
|
@ -1,80 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "rtc_base/platform_thread_types.h"
|
||||
|
||||
#if defined(WEBRTC_LINUX)
|
||||
#include <sys/prctl.h>
|
||||
#include <sys/syscall.h>
|
||||
#endif
|
||||
|
||||
#if defined(WEBRTC_FUCHSIA)
|
||||
#include <zircon/process.h>
|
||||
#endif
|
||||
|
||||
namespace rtc {
|
||||
|
||||
PlatformThreadId CurrentThreadId() {
|
||||
#if defined(WEBRTC_WIN)
|
||||
return GetCurrentThreadId();
|
||||
#elif defined(WEBRTC_POSIX)
|
||||
#if defined(WEBRTC_MAC) || defined(WEBRTC_IOS)
|
||||
return pthread_mach_thread_np(pthread_self());
|
||||
#elif defined(WEBRTC_ANDROID)
|
||||
return gettid();
|
||||
#elif defined(WEBRTC_FUCHSIA)
|
||||
return zx_thread_self();
|
||||
#elif defined(WEBRTC_LINUX)
|
||||
return syscall(__NR_gettid);
|
||||
#else
|
||||
// Default implementation for nacl and solaris.
|
||||
return reinterpret_cast<pid_t>(pthread_self());
|
||||
#endif
|
||||
#endif // defined(WEBRTC_POSIX)
|
||||
}
|
||||
|
||||
PlatformThreadRef CurrentThreadRef() {
|
||||
#if defined(WEBRTC_WIN)
|
||||
return GetCurrentThreadId();
|
||||
#elif defined(WEBRTC_POSIX)
|
||||
return pthread_self();
|
||||
#endif
|
||||
}
|
||||
|
||||
bool IsThreadRefEqual(const PlatformThreadRef& a, const PlatformThreadRef& b) {
|
||||
#if defined(WEBRTC_WIN)
|
||||
return a == b;
|
||||
#elif defined(WEBRTC_POSIX)
|
||||
return pthread_equal(a, b);
|
||||
#endif
|
||||
}
|
||||
|
||||
void SetCurrentThreadName(const char* name) {
|
||||
#if defined(WEBRTC_WIN)
|
||||
struct {
|
||||
DWORD dwType;
|
||||
LPCSTR szName;
|
||||
DWORD dwThreadID;
|
||||
DWORD dwFlags;
|
||||
} threadname_info = {0x1000, name, static_cast<DWORD>(-1), 0};
|
||||
|
||||
__try {
|
||||
::RaiseException(0x406D1388, 0, sizeof(threadname_info) / sizeof(DWORD),
|
||||
reinterpret_cast<ULONG_PTR*>(&threadname_info));
|
||||
} __except (EXCEPTION_EXECUTE_HANDLER) { // NOLINT
|
||||
}
|
||||
#elif defined(WEBRTC_LINUX) || defined(WEBRTC_ANDROID)
|
||||
prctl(PR_SET_NAME, reinterpret_cast<unsigned long>(name)); // NOLINT
|
||||
#elif defined(WEBRTC_MAC) || defined(WEBRTC_IOS)
|
||||
pthread_setname_np(name);
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace rtc
|
|
@ -32,21 +32,6 @@ typedef pthread_t PlatformThreadRef;
|
|||
typedef pid_t PlatformThreadId;
|
||||
typedef pthread_t PlatformThreadRef;
|
||||
#endif
|
||||
|
||||
// Retrieve the ID of the current thread.
|
||||
PlatformThreadId CurrentThreadId();
|
||||
|
||||
// Retrieves a reference to the current thread. On Windows, this is the same
|
||||
// as CurrentThreadId. On other platforms it's the pthread_t returned by
|
||||
// pthread_self().
|
||||
PlatformThreadRef CurrentThreadRef();
|
||||
|
||||
// Compares two thread identifiers for equality.
|
||||
bool IsThreadRefEqual(const PlatformThreadRef& a, const PlatformThreadRef& b);
|
||||
|
||||
// Sets the current thread name.
|
||||
void SetCurrentThreadName(const char* name);
|
||||
|
||||
} // namespace rtc
|
||||
|
||||
#endif // RTC_BASE_PLATFORM_THREAD_TYPES_H_
|
||||
|
|
Loading…
Reference in a new issue