Blocking mutex currently only performs tid validation checks
in the mac and windows implementations. Add these checks to the
linux implementation as well.
Also add analogous validation checks to rw mutex. In order to
access the current tid, this requires moving the implementation
of rw mutex out of the sanitizer mutex header file.
"state == kReadLock" must be "state >= kReadLock" because kReadLock is a counter.
Checking state != kUnlocked when owner_ == GetTid() is pointless because state is always kWriteLock when owner_ == GetTid().
This should be:
CHECK(state >= kReadLock || owner_ == GetTid());
Also note the reversed order of conditions -- syscall is slower than a check of local variable.