mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-05 00:55:24 +00:00
more renaming
This commit is contained in:
@@ -1,23 +1,26 @@
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <isc/condition.h>
|
||||
#include <errno.h>
|
||||
#include <isc/unexpect.h>
|
||||
|
||||
isc_boolean_t
|
||||
os_condition_waituntil(os_condition_t *c, os_mutex_t *m, os_time_t *t,
|
||||
isc_boolean_t *timeout)
|
||||
isc_result_t
|
||||
isc_condition_waituntil(isc_condition_t *c, isc_mutex_t *m, isc_time_t t)
|
||||
{
|
||||
int result;
|
||||
int presult;
|
||||
struct timespec ts;
|
||||
|
||||
ts.tv_sec = t->seconds;
|
||||
ts.tv_nsec = t->nanoseconds;
|
||||
result = pthread_cond_timedwait(c, m, &ts);
|
||||
if (result == 0) {
|
||||
*timeout = ISC_FALSE;
|
||||
return (ISC_TRUE);
|
||||
} else if (result == ETIMEDOUT) {
|
||||
*timeout = ISC_TRUE;
|
||||
return (ISC_TRUE);
|
||||
}
|
||||
return (ISC_FALSE);
|
||||
presult = pthread_cond_timedwait(c, m, &ts);
|
||||
if (presult == 0)
|
||||
return (ISC_R_SUCCESS);
|
||||
if (presult == ETIMEDOUT)
|
||||
return (ISC_R_TIMEDOUT);
|
||||
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"pthread_cond_timedwait() returned %s",
|
||||
strerror(presult));
|
||||
return (ISC_R_UNEXPECTED);
|
||||
}
|
||||
|
@@ -1,25 +1,37 @@
|
||||
|
||||
#ifndef CONDITION_H
|
||||
#define CONDITION_H 1
|
||||
#ifndef ISC_CONDITION_H
|
||||
#define ISC_CONDITION_H 1
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
#include <isc/boolean.h>
|
||||
#include <isc/result.h>
|
||||
#include <isc/mutex.h>
|
||||
#include <isc/time.h>
|
||||
|
||||
typedef pthread_cond_t os_condition_t;
|
||||
#define OS_CONDITION_INITIALIZER PTHREAD_COND_INITIALIZER
|
||||
typedef pthread_cond_t isc_condition_t;
|
||||
|
||||
#define os_condition_init(cp) (pthread_cond_init((cp), NULL) == 0)
|
||||
#define os_condition_wait(cp, mp) (pthread_cond_wait((cp), (mp)) == 0)
|
||||
#define os_condition_signal(cp) (pthread_cond_signal((cp)) == 0)
|
||||
#define os_condition_broadcast(cp) (pthread_cond_broadcast((cp)) == 0)
|
||||
#define os_condition_destroy(cp) (pthread_cond_destroy((cp)) == 0)
|
||||
#define isc_condition_init(cp) \
|
||||
((pthread_cond_init((cp), NULL) == 0) ? \
|
||||
ISC_R_SUCCESS : ISC_R_UNEXPECTED)
|
||||
|
||||
isc_boolean_t os_condition_waituntil(os_condition_t *,
|
||||
os_mutex_t *,
|
||||
os_time_t *,
|
||||
isc_boolean_t *);
|
||||
#define isc_condition_wait(cp, mp) \
|
||||
((pthread_cond_wait((cp), (mp)) == 0) ? \
|
||||
ISC_R_SUCCESS : ISC_R_UNEXPECTED)
|
||||
|
||||
#endif /* CONDITION_H */
|
||||
#define isc_condition_signal(cp) \
|
||||
((pthread_cond_signal((cp)) == 0) ? \
|
||||
ISC_R_SUCCESS : ISC_R_UNEXPECTED)
|
||||
|
||||
#define isc_condition_broadcast(cp) \
|
||||
((pthread_cond_broadcast((cp)) == 0) ? \
|
||||
ISC_R_SUCCESS : ISC_R_UNEXPECTED)
|
||||
|
||||
#define isc_condition_destroy(cp) \
|
||||
((pthread_cond_destroy((cp)) == 0) ? \
|
||||
ISC_R_SUCCESS : ISC_R_UNEXPECTED)
|
||||
|
||||
isc_result_t isc_condition_waituntil(isc_condition_t *, isc_mutex_t *,
|
||||
isc_time_t);
|
||||
|
||||
#endif /* ISC_CONDITION_H */
|
||||
|
@@ -1,15 +1,26 @@
|
||||
|
||||
#ifndef MUTEX_H
|
||||
#define MUTEX_H 1
|
||||
#ifndef ISC_MUTEX_H
|
||||
#define ISC_MUTEX_H 1
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
typedef pthread_mutex_t os_mutex_t;
|
||||
#define OS_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
|
||||
#include <isc/result.h>
|
||||
|
||||
#define os_mutex_init(mp) (pthread_mutex_init((mp), NULL) == 0)
|
||||
#define os_mutex_lock(mp) (pthread_mutex_lock((mp)) == 0)
|
||||
#define os_mutex_unlock(mp) (pthread_mutex_unlock((mp)) == 0)
|
||||
#define os_mutex_destroy(mp) (pthread_mutex_destroy((mp)) == 0)
|
||||
typedef pthread_mutex_t isc_mutex_t;
|
||||
|
||||
#endif /* MUTEX_H */
|
||||
/* XXX We could do fancier error handling... */
|
||||
|
||||
#define isc_mutex_init(mp) \
|
||||
((pthread_mutex_init((mp), NULL) == 0) ? \
|
||||
ISC_R_SUCCESS : ISC_R_UNEXPECTED)
|
||||
#define isc_mutex_lock(mp) \
|
||||
((pthread_mutex_lock((mp)) == 0) ? \
|
||||
ISC_R_SUCCESS : ISC_R_UNEXPECTED)
|
||||
#define isc_mutex_unlock(mp) \
|
||||
((pthread_mutex_unlock((mp)) == 0) ? \
|
||||
ISC_R_SUCCESS : ISC_R_UNEXPECTED)
|
||||
#define isc_mutex_destroy(mp) \
|
||||
((pthread_mutex_destroy((mp)) == 0) ? \
|
||||
ISC_R_SUCCESS : ISC_R_UNEXPECTED)
|
||||
|
||||
#endif /* ISC_MUTEX_H */
|
||||
|
@@ -1,17 +1,28 @@
|
||||
|
||||
#ifndef THREAD_H
|
||||
#define THREAD_H 1
|
||||
#ifndef ISC_THREAD_H
|
||||
#define ISC_THREAD_H 1
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
#include <isc/assertions.h>
|
||||
#include <isc/result.h>
|
||||
|
||||
typedef pthread_t os_thread_t;
|
||||
typedef pthread_t isc_thread_t;
|
||||
|
||||
#define os_thread_create(s, a, tp) (pthread_create((tp), NULL, (s), (a)) \
|
||||
== 0)
|
||||
#define os_thread_detach(t) (pthread_detach((t)) == 0)
|
||||
#define os_thread_join(t) (pthread_join((t), NULL) == 0)
|
||||
#define os_thread_self pthread_self
|
||||
/* XXX We could do fancier error handling... */
|
||||
|
||||
#endif /* THREAD_H */
|
||||
#define isc_thread_create(s, a, tp) \
|
||||
((pthread_create((tp), NULL, (s), (a)) == 0) ? \
|
||||
ISC_R_SUCCESS : ISC_R_UNEXPECTED)
|
||||
|
||||
#define isc_thread_detach(t) \
|
||||
((pthread_detach((t)) == 0) ? \
|
||||
ISC_R_SUCCESS : ISC_R_UNEXPECTED)
|
||||
|
||||
#define isc_thread_join(t) \
|
||||
((pthread_join((t), NULL) == 0) ? \
|
||||
ISC_R_SUCCESS : ISC_R_UNEXPECTED)
|
||||
|
||||
#define isc_thread_self \
|
||||
pthread_self
|
||||
|
||||
#endif /* ISC_THREAD_H */
|
||||
|
Reference in New Issue
Block a user