introduce wrapper functions for pthread_rwlock

Currently, we don't check the return values of pthread_rwlock_rdlock()
and pthread_rwlock_wrlock().  When they returns an error, we can call
pthread_rwlock_unlock() even if another thread has the lock.  This can
lead to a bug which is difficult to find.

Those functions can actually return error.  For example, when
pthread_rwlock_rdlock() is called when a write lock is already owned,
it returns EDEADLK without locking.  It is difficult to make sure that
we don't have this kind of deadlock, so checking the return values
strictly is important to ensure our codes is correct.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>