Reimplement threading.Lock, RLock and Condition with libpthread