isc__rwlock_init(*rwl, rq, wq); \
}
#define isc_rwlock_lock(rwl, type) isc__rwlock_lock(*rwl, type)
-#define isc_rwlock_trylock(rwl, type) isc___rwlock_trylock(*rwl, type)
+#define isc_rwlock_trylock(rwl, type) isc__rwlock_trylock(*rwl, type)
#define isc_rwlock_unlock(rwl, type) isc__rwlock_unlock(*rwl, type)
-#define isc_rwlock_tryupgrade(rwl) isc___rwlock_tryupgrade(*rwl)
-#define isc_rwlock_destroy(rwl) \
- { \
- isc___rwlock_destroy(*rwl); \
- free(*rwl); \
+#define isc_rwlock_tryupgrade(rwl) isc__rwlock_tryupgrade(*rwl)
+#define isc_rwlock_destroy(rwl) \
+ { \
+ isc__rwlock_destroy(*rwl); \
+ free(*rwl); \
}
#else /* ISC_TRACK_PTHREADS_OBJECTS */
#define isc_rwlock_init(rwl, rq, wq) isc__rwlock_init(rwl, rq, wq)
#define isc_rwlock_lock(rwl, type) isc__rwlock_lock(rwl, type)
-#define isc_rwlock_trylock(rwl, type) isc___rwlock_trylock(rwl, type)
+#define isc_rwlock_trylock(rwl, type) isc__rwlock_trylock(rwl, type)
#define isc_rwlock_unlock(rwl, type) isc__rwlock_unlock(rwl, type)
-#define isc_rwlock_tryupgrade(rwl) isc___rwlock_tryupgrade(rwl)
+#define isc_rwlock_tryupgrade(rwl) isc__rwlock_tryupgrade(rwl)
#define isc_rwlock_destroy(rwl) isc__rwlock_destroy(rwl)
#endif /* ISC_TRACK_PTHREADS_OBJECTS */
#define isc_rwlock_init(rwl, rq, wq) isc__rwlock_init(rwl, rq, wq)
#define isc_rwlock_lock(rwl, type) isc__rwlock_lock(rwl, type)
-#define isc_rwlock_trylock(rwl, type) isc___rwlock_trylock(rwl, type)
+#define isc_rwlock_trylock(rwl, type) isc__rwlock_trylock(rwl, type)
#define isc_rwlock_unlock(rwl, type) isc__rwlock_unlock(rwl, type)
-#define isc_rwlock_tryupgrade(rwl) isc___rwlock_tryupgrade(rwl)
+#define isc_rwlock_tryupgrade(rwl) isc__rwlock_tryupgrade(rwl)
#define isc_rwlock_destroy(rwl) isc__rwlock_destroy(rwl)
#endif /* USE_PTHREAD_RWLOCK */
-#define isc__rwlock_init(rwl, rq, wq) \
- { \
- int _ret = isc___rwlock_init(rwl, rq, wq); \
- PTHREADS_RUNTIME_CHECK(isc___rwlock_init, _ret); \
- }
-
-#define isc__rwlock_lock(rwl, type) \
- { \
- int _ret = isc___rwlock_lock(rwl, type); \
- PTHREADS_RUNTIME_CHECK(isc___rwlock_lock, _ret); \
- }
-
-#define isc__rwlock_unlock(rwl, type) \
- { \
- int _ret = isc___rwlock_unlock(rwl, type); \
- PTHREADS_RUNTIME_CHECK(isc___rwlock_unlock, _ret); \
- }
-
-#define isc__rwlock_destroy(rwl) \
- { \
- int _ret = isc___rwlock_destroy(rwl); \
- PTHREADS_RUNTIME_CHECK(isc___rwlock_destroy, _ret); \
- }
-
-int
-isc___rwlock_init(isc__rwlock_t *rwl, unsigned int read_quota,
- unsigned int write_quota);
+void
+isc__rwlock_init(isc__rwlock_t *rwl, unsigned int read_quota,
+ unsigned int write_quota);
-int
-isc___rwlock_lock(isc__rwlock_t *rwl, isc_rwlocktype_t type);
+void
+isc__rwlock_lock(isc__rwlock_t *rwl, isc_rwlocktype_t type);
isc_result_t
-isc___rwlock_trylock(isc__rwlock_t *rwl, isc_rwlocktype_t type);
+isc__rwlock_trylock(isc__rwlock_t *rwl, isc_rwlocktype_t type);
-int
-isc___rwlock_unlock(isc__rwlock_t *rwl, isc_rwlocktype_t type);
+void
+isc__rwlock_unlock(isc__rwlock_t *rwl, isc_rwlocktype_t type);
isc_result_t
-isc___rwlock_tryupgrade(isc__rwlock_t *rwl);
+isc__rwlock_tryupgrade(isc__rwlock_t *rwl);
-int
-isc___rwlock_destroy(isc__rwlock_t *rwl);
+void
+isc__rwlock_destroy(isc__rwlock_t *rwl);
ISC_LANG_ENDDECLS
#include <errno.h>
#include <pthread.h>
-int
-isc___rwlock_init(isc__rwlock_t *rwl, unsigned int read_quota,
- unsigned int write_quota) {
+void
+isc__rwlock_init(isc__rwlock_t *rwl, unsigned int read_quota,
+ unsigned int write_quota) {
int ret;
UNUSED(read_quota);
UNUSED(write_quota);
ret = pthread_rwlock_init(rwl, NULL);
-
- return (ret);
+ PTHREADS_RUNTIME_CHECK(pthread_rwlock_init, ret);
}
-int
-isc___rwlock_lock(isc__rwlock_t *rwl, isc_rwlocktype_t type) {
+void
+isc__rwlock_lock(isc__rwlock_t *rwl, isc_rwlocktype_t type) {
+ int ret;
switch (type) {
case isc_rwlocktype_read:
- return (pthread_rwlock_rdlock(rwl));
+ ret = pthread_rwlock_rdlock(rwl);
+ PTHREADS_RUNTIME_CHECK(pthread_rwlock_rdlock, ret);
+ break;
case isc_rwlocktype_write:
- return (pthread_rwlock_wrlock(rwl));
+ ret = pthread_rwlock_wrlock(rwl);
+ PTHREADS_RUNTIME_CHECK(pthread_rwlock_rwlock, ret);
+ break;
default:
UNREACHABLE();
}
}
isc_result_t
-isc___rwlock_trylock(isc__rwlock_t *rwl, isc_rwlocktype_t type) {
+isc__rwlock_trylock(isc__rwlock_t *rwl, isc_rwlocktype_t type) {
int ret = 0;
switch (type) {
case isc_rwlocktype_read:
case EAGAIN:
return (ISC_R_LOCKBUSY);
default:
- UNREACHABLE();
+ break;
}
+
+ switch (type) {
+ case isc_rwlocktype_read:
+ PTHREADS_RUNTIME_CHECK(pthread_rwlock_tryrdlock, ret);
+ break;
+ case isc_rwlocktype_write:
+ PTHREADS_RUNTIME_CHECK(pthread_rwlock_trywrlock, ret);
+ break;
+ default:
+ break;
+ }
+ UNREACHABLE();
}
-int
-isc___rwlock_unlock(isc__rwlock_t *rwl, isc_rwlocktype_t type) {
+void
+isc__rwlock_unlock(isc__rwlock_t *rwl, isc_rwlocktype_t type) {
+ int ret;
UNUSED(type);
- return (pthread_rwlock_unlock(rwl));
+ ret = pthread_rwlock_unlock(rwl);
+ PTHREADS_RUNTIME_CHECK(pthread_rwlock_rwlock, ret);
}
isc_result_t
-isc___rwlock_tryupgrade(isc__rwlock_t *rwl) {
+isc__rwlock_tryupgrade(isc__rwlock_t *rwl) {
UNUSED(rwl);
return (ISC_R_LOCKBUSY);
}
-int
-isc___rwlock_destroy(isc__rwlock_t *rwl) {
- return (pthread_rwlock_destroy(rwl));
+void
+isc__rwlock_destroy(isc__rwlock_t *rwl) {
+ int ret = pthread_rwlock_destroy(rwl);
+
+ PTHREADS_RUNTIME_CHECK(pthread_rwlock_destroy, ret);
}
#else /* if USE_PTHREAD_RWLOCK */
}
#endif /* ISC_RWLOCK_TRACE */
-int
-isc___rwlock_init(isc__rwlock_t *rwl, unsigned int read_quota,
- unsigned int write_quota) {
+void
+isc__rwlock_init(isc__rwlock_t *rwl, unsigned int read_quota,
+ unsigned int write_quota) {
REQUIRE(rwl != NULL);
/*
isc_condition_init(&rwl->writeable);
rwl->magic = RWLOCK_MAGIC;
-
- return (0);
}
-int
-isc___rwlock_destroy(isc__rwlock_t *rwl) {
+void
+isc__rwlock_destroy(isc__rwlock_t *rwl) {
REQUIRE(VALID_RWLOCK(rwl));
REQUIRE(atomic_load_acquire(&rwl->write_requests) ==
isc_condition_destroy(&rwl->readable);
isc_condition_destroy(&rwl->writeable);
isc_mutex_destroy(&rwl->lock);
-
- return (0);
}
/*
#endif /* ifdef ISC_RWLOCK_TRACE */
}
-int
-isc___rwlock_lock(isc__rwlock_t *rwl, isc_rwlocktype_t type) {
+void
+isc__rwlock_lock(isc__rwlock_t *rwl, isc_rwlocktype_t type) {
int32_t cnt = 0;
int32_t spins = atomic_load_acquire(&rwl->spins) * 2 + 10;
int32_t max_cnt = ISC_MAX(spins, RWLOCK_MAX_ADAPTIVE_COUNT);
} while (isc_rwlock_trylock(rwl, type) != ISC_R_SUCCESS);
atomic_fetch_add_release(&rwl->spins, (cnt - spins) / 8);
-
- return (0);
}
isc_result_t
-isc___rwlock_trylock(isc__rwlock_t *rwl, isc_rwlocktype_t type) {
+isc__rwlock_trylock(isc__rwlock_t *rwl, isc_rwlocktype_t type) {
int32_t cntflag;
REQUIRE(VALID_RWLOCK(rwl));
}
isc_result_t
-isc___rwlock_tryupgrade(isc__rwlock_t *rwl) {
+isc__rwlock_tryupgrade(isc__rwlock_t *rwl) {
REQUIRE(VALID_RWLOCK(rwl));
int_fast32_t reader_incr = READER_INCR;
return (ISC_R_SUCCESS);
}
-int
-isc___rwlock_unlock(isc__rwlock_t *rwl, isc_rwlocktype_t type) {
+void
+isc__rwlock_unlock(isc__rwlock_t *rwl, isc_rwlocktype_t type) {
int32_t prev_cnt;
REQUIRE(VALID_RWLOCK(rwl));
#ifdef ISC_RWLOCK_TRACE
print_lock("postunlock", rwl, type);
#endif /* ifdef ISC_RWLOCK_TRACE */
-
- return (0);
}
#endif /* USE_PTHREAD_RWLOCK */