Make pthread_*_destroy() more standards compliant
Function pthread_{mutex,cond,rwlock}_destroy() returned EINVAL when the
mutex/cond/rwlock was initialized statically via one of the
PTHREAD_*_INITIALIZER macros and not being used before destruction. We now
return success (0) instead, as it would have been the case when the *_init()
function were used for initialization. This is also the behaviour Linux
exhibits.
Note that we now can no longer detect multiple calls to *_destroy(). Multiple
calls will do no harm, but return success.
While there, fix some potential null pointer derefs in cond and rwlock.
Fixes: #2763