/* Lock a read-write lock object for writing within specific time. 
See IEEE 1003.1  */
int pthread_rwlock_timedwrlock(pthread_rwlock_t *rwlock, const struct timespec *abstime)
/* Lock a read-write lock object for writing within specific time. 
See IEEE 1003.1  */
int pthread_rwlock_timedwrlock(pthread_rwlock_t *rwlock, const struct timespec *abstime)
{
	int32_t timeout;
	uint32_t ret = 0U;
	struct posix_rwlock *rwl;
	if (abstime->tv_nsec < 0 || abstime->tv_nsec > NSEC_PER_SEC) {
		return EINVAL;
	}
	timeout = (int32_t) timespec_to_timeoutms(abstime);
	rwl = get_posix_rwlock(*rwlock);
	if (rwl == NULL) {
		return EINVAL;
	}
	if (write_lock_acquire(rwl, timeout) != 0U) {
		ret = ETIMEDOUT;
	}
	return ret;
}