Use bionic lock in pthread_internal_t.

It removes calling to pthread_mutex_lock() at the beginning of new
thread, which helps to support thread sanitizer.

Change-Id: Ia3601c476de7976a9177b792bd74bb200cee0e13
This commit is contained in:
Yabin Cui
2015-10-22 20:07:56 -07:00
parent 5edf077c5b
commit d26e780df6
3 changed files with 11 additions and 13 deletions

View File

@@ -31,6 +31,8 @@
#include <stdatomic.h>
#include "private/bionic_futex.h"
// Lock is used in places like pthread_rwlock_t, which can be initialized without calling
// an initialization function. So make sure Lock can be initialized by setting its memory to 0.
class Lock {
private:
enum LockState {
@@ -42,10 +44,6 @@ class Lock {
bool process_shared;
public:
Lock(bool process_shared = false) {
init(process_shared);
}
void init(bool process_shared) {
atomic_init(&state, Unlocked);
this->process_shared = process_shared;