mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-30 22:15:20 +00:00
convert back to UNIX text format
This commit is contained in:
@@ -1,110 +1,111 @@
|
|||||||
|
|
||||||
#include <isc/condition.h>
|
|
||||||
#include <isc/assertions.h>
|
|
||||||
|
|
||||||
#define SIGNAL 0
|
|
||||||
#define BROADCAST 1
|
|
||||||
|
|
||||||
isc_result_t
|
|
||||||
isc_condition_init(isc_condition_t *cond) {
|
|
||||||
HANDLE h;
|
|
||||||
|
|
||||||
REQUIRE(cond != NULL);
|
|
||||||
|
|
||||||
cond->waiters = 0;
|
|
||||||
h = CreateEvent(NULL, FALSE, FALSE, NULL);
|
|
||||||
if (h == NULL) {
|
|
||||||
/* XXX */
|
|
||||||
return (ISC_R_UNEXPECTED);
|
|
||||||
}
|
|
||||||
cond->events[SIGNAL] = h;
|
|
||||||
h = CreateEvent(NULL, TRUE, FALSE, NULL);
|
|
||||||
if (h == NULL) {
|
|
||||||
(void)CloseHandle(cond->events[SIGNAL]);
|
|
||||||
/* XXX */
|
|
||||||
return (ISC_R_UNEXPECTED);
|
|
||||||
}
|
|
||||||
cond->events[BROADCAST] = h;
|
|
||||||
return (ISC_R_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
isc_result_t
|
|
||||||
isc_condition_signal(isc_condition_t *cond) {
|
|
||||||
|
|
||||||
REQUIRE(cond != NULL);
|
|
||||||
|
|
||||||
if (cond->waiters > 0 &&
|
|
||||||
!SetEvent(cond->events[SIGNAL])) {
|
|
||||||
/* XXX */
|
|
||||||
return (ISC_R_UNEXPECTED);
|
|
||||||
}
|
|
||||||
return (ISC_R_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
isc_result_t
|
|
||||||
isc_condition_broadcast(isc_condition_t *cond) {
|
|
||||||
|
|
||||||
REQUIRE(cond != NULL);
|
|
||||||
|
|
||||||
if (cond->waiters > 0 &&
|
|
||||||
!SetEvent(cond->events[BROADCAST])) {
|
|
||||||
/* XXX */
|
|
||||||
return (ISC_R_UNEXPECTED);
|
|
||||||
}
|
|
||||||
return (ISC_R_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
isc_result_t
|
#include <isc/condition.h>
|
||||||
isc_condition_destroy(isc_condition_t *cond) {
|
#include <isc/assertions.h>
|
||||||
|
|
||||||
REQUIRE(cond != NULL);
|
#define SIGNAL 0
|
||||||
|
#define BROADCAST 1
|
||||||
(void)CloseHandle(cond->events[SIGNAL]);
|
|
||||||
(void)CloseHandle(cond->events[BROADCAST]);
|
isc_result_t
|
||||||
return (ISC_R_SUCCESS);
|
isc_condition_init(isc_condition_t *cond) {
|
||||||
|
HANDLE h;
|
||||||
|
|
||||||
|
REQUIRE(cond != NULL);
|
||||||
|
|
||||||
|
cond->waiters = 0;
|
||||||
|
h = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||||
|
if (h == NULL) {
|
||||||
|
/* XXX */
|
||||||
|
return (ISC_R_UNEXPECTED);
|
||||||
|
}
|
||||||
|
cond->events[SIGNAL] = h;
|
||||||
|
h = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||||
|
if (h == NULL) {
|
||||||
|
(void)CloseHandle(cond->events[SIGNAL]);
|
||||||
|
/* XXX */
|
||||||
|
return (ISC_R_UNEXPECTED);
|
||||||
|
}
|
||||||
|
cond->events[BROADCAST] = h;
|
||||||
|
|
||||||
|
return (ISC_R_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
isc_result_t
|
||||||
isc_result_t
|
isc_condition_signal(isc_condition_t *cond) {
|
||||||
wait(isc_condition_t *cond, isc_mutex_t *mutex,
|
|
||||||
DWORD milliseconds)
|
REQUIRE(cond != NULL);
|
||||||
{
|
|
||||||
DWORD result;
|
if (cond->waiters > 0 &&
|
||||||
|
!SetEvent(cond->events[SIGNAL])) {
|
||||||
cond->waiters++;
|
/* XXX */
|
||||||
LeaveCriticalSection(mutex);
|
return (ISC_R_UNEXPECTED);
|
||||||
result = WaitForMultipleObjects(2, cond->events, FALSE,
|
}
|
||||||
milliseconds);
|
|
||||||
if (result == WAIT_FAILED) {
|
return (ISC_R_SUCCESS);
|
||||||
/* XXX */
|
}
|
||||||
return (ISC_R_UNEXPECTED);
|
|
||||||
}
|
isc_result_t
|
||||||
EnterCriticalSection(mutex);
|
isc_condition_broadcast(isc_condition_t *cond) {
|
||||||
cond->waiters--;
|
|
||||||
if (cond->waiters == 0 &&
|
REQUIRE(cond != NULL);
|
||||||
!ResetEvent(cond->events[BROADCAST])) {
|
|
||||||
/* XXX */
|
if (cond->waiters > 0 &&
|
||||||
LeaveCriticalSection(mutex);
|
!SetEvent(cond->events[BROADCAST])) {
|
||||||
return (ISC_R_UNEXPECTED);
|
/* XXX */
|
||||||
}
|
return (ISC_R_UNEXPECTED);
|
||||||
|
}
|
||||||
if (result == WAIT_TIMEOUT)
|
|
||||||
return (ISC_R_TIMEDOUT);
|
return (ISC_R_SUCCESS);
|
||||||
|
}
|
||||||
return (ISC_R_SUCCESS);
|
|
||||||
}
|
isc_result_t
|
||||||
|
isc_condition_destroy(isc_condition_t *cond) {
|
||||||
isc_result_t
|
|
||||||
isc_condition_wait(isc_condition_t *cond, isc_mutex_t *mutex) {
|
REQUIRE(cond != NULL);
|
||||||
return (wait(cond, mutex, INFINITE));
|
|
||||||
}
|
(void)CloseHandle(cond->events[SIGNAL]);
|
||||||
|
(void)CloseHandle(cond->events[BROADCAST]);
|
||||||
isc_result_t
|
|
||||||
|
return (ISC_R_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
isc_result_t
|
||||||
|
wait(isc_condition_t *cond, isc_mutex_t *mutex, DWORD milliseconds) {
|
||||||
|
DWORD result;
|
||||||
|
|
||||||
|
cond->waiters++;
|
||||||
|
LeaveCriticalSection(mutex);
|
||||||
|
result = WaitForMultipleObjects(2, cond->events, FALSE, milliseconds);
|
||||||
|
if (result == WAIT_FAILED) {
|
||||||
|
/* XXX */
|
||||||
|
return (ISC_R_UNEXPECTED);
|
||||||
|
}
|
||||||
|
EnterCriticalSection(mutex);
|
||||||
|
cond->waiters--;
|
||||||
|
if (cond->waiters == 0 &&
|
||||||
|
!ResetEvent(cond->events[BROADCAST])) {
|
||||||
|
/* XXX */
|
||||||
|
LeaveCriticalSection(mutex);
|
||||||
|
return (ISC_R_UNEXPECTED);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result == WAIT_TIMEOUT)
|
||||||
|
return (ISC_R_TIMEDOUT);
|
||||||
|
|
||||||
|
return (ISC_R_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
isc_result_t
|
||||||
|
isc_condition_wait(isc_condition_t *cond, isc_mutex_t *mutex) {
|
||||||
|
return (wait(cond, mutex, INFINITE));
|
||||||
|
}
|
||||||
|
|
||||||
|
isc_result_t
|
||||||
isc_condition_waituntil(isc_condition_t *cond, isc_mutex_t *mutex,
|
isc_condition_waituntil(isc_condition_t *cond, isc_mutex_t *mutex,
|
||||||
isc_time_t t)
|
isc_time_t t)
|
||||||
{
|
{
|
||||||
DWORD milliseconds;
|
DWORD milliseconds;
|
||||||
|
|
||||||
milliseconds = 100; /* XXX */
|
milliseconds = 100; /* XXX */
|
||||||
return (wait(cond, mutex, milliseconds));
|
return (wait(cond, mutex, milliseconds));
|
||||||
}
|
}
|
||||||
|
@@ -9,14 +9,14 @@
|
|||||||
#include <isc/mutex.h>
|
#include <isc/mutex.h>
|
||||||
#include <isc/time.h>
|
#include <isc/time.h>
|
||||||
|
|
||||||
typedef struct isc_condition {
|
typedef struct isc_condition {
|
||||||
HANDLE events[2];
|
HANDLE events[2];
|
||||||
unsigned int waiters;
|
unsigned int waiters;
|
||||||
} isc_condition_t;
|
} isc_condition_t;
|
||||||
|
|
||||||
isc_result_t isc_condition_init(isc_condition_t *);
|
isc_result_t isc_condition_init(isc_condition_t *);
|
||||||
isc_result_t isc_condition_wait(isc_condition_t *, isc_mutex_t *);
|
isc_result_t isc_condition_wait(isc_condition_t *, isc_mutex_t *);
|
||||||
isc_result_t isc_condition_signal(isc_condition_t *);
|
isc_result_t isc_condition_signal(isc_condition_t *);
|
||||||
isc_result_t isc_condition_broadcast(isc_condition_t *);
|
isc_result_t isc_condition_broadcast(isc_condition_t *);
|
||||||
isc_result_t isc_condition_destroy(isc_condition_t *);
|
isc_result_t isc_condition_destroy(isc_condition_t *);
|
||||||
isc_result_t isc_condition_waituntil(isc_condition_t *, isc_mutex_t *,
|
isc_result_t isc_condition_waituntil(isc_condition_t *, isc_mutex_t *,
|
||||||
|
@@ -7,14 +7,14 @@
|
|||||||
#include <isc/result.h>
|
#include <isc/result.h>
|
||||||
|
|
||||||
typedef CRITICAL_SECTION isc_mutex_t;
|
typedef CRITICAL_SECTION isc_mutex_t;
|
||||||
|
|
||||||
#define isc_mutex_init(mp) \
|
#define isc_mutex_init(mp) \
|
||||||
(InitializeCriticalSection((mp)), ISC_R_SUCCESS)
|
(InitializeCriticalSection((mp)), ISC_R_SUCCESS)
|
||||||
#define isc_mutex_lock(mp) \
|
#define isc_mutex_lock(mp) \
|
||||||
(EnterCriticalSection((mp)), ISC_R_SUCCESS)
|
(EnterCriticalSection((mp)), ISC_R_SUCCESS)
|
||||||
#define isc_mutex_unlock(mp) \
|
#define isc_mutex_unlock(mp) \
|
||||||
(LeaveCriticalSection((mp)), ISC_R_SUCCESS)
|
(LeaveCriticalSection((mp)), ISC_R_SUCCESS)
|
||||||
#define isc_mutex_destroy(mp) \
|
#define isc_mutex_destroy(mp) \
|
||||||
(DeleteCriticalSection((mp)), ISC_R_SUCCESS)
|
(DeleteCriticalSection((mp)), ISC_R_SUCCESS)
|
||||||
|
|
||||||
#endif /* ISC_MUTEX_H */
|
#endif /* ISC_MUTEX_H */
|
||||||
|
@@ -12,10 +12,10 @@ typedef LPVOID isc_threadarg_t;
|
|||||||
typedef isc_threadresult_t (WINAPI *isc_threadfunc_t)(isc_threadarg_t);
|
typedef isc_threadresult_t (WINAPI *isc_threadfunc_t)(isc_threadarg_t);
|
||||||
|
|
||||||
isc_result_t isc_thread_create(isc_threadfunc_t, isc_threadarg_t,
|
isc_result_t isc_thread_create(isc_threadfunc_t, isc_threadarg_t,
|
||||||
isc_thread_t *);
|
isc_thread_t *);
|
||||||
isc_result_t isc_thread_join(isc_thread_t, isc_threadresult_t *);
|
isc_result_t isc_thread_join(isc_thread_t, isc_threadresult_t *);
|
||||||
isc_result_t isc_thread_detach(isc_thread_t);
|
isc_result_t isc_thread_detach(isc_thread_t);
|
||||||
#define isc_thread_self \
|
#define isc_thread_self \
|
||||||
(unsigned long)GetCurrentThreadId
|
(unsigned long)GetCurrentThreadId
|
||||||
|
|
||||||
#endif /* ISC_THREAD_H */
|
#endif /* ISC_THREAD_H */
|
||||||
|
@@ -1,41 +1,44 @@
|
|||||||
|
|
||||||
#include <isc/thread.h>
|
#include <isc/thread.h>
|
||||||
|
|
||||||
isc_result_t
|
isc_result_t
|
||||||
isc_thread_create(isc_threadfunc_t start, isc_threadarg_t arg,
|
isc_thread_create(isc_threadfunc_t start, isc_threadarg_t arg,
|
||||||
isc_thread_t *threadp)
|
isc_thread_t *threadp)
|
||||||
{
|
{
|
||||||
HANDLE h;
|
HANDLE h;
|
||||||
DWORD id;
|
DWORD id;
|
||||||
|
|
||||||
h = CreateThread(NULL, 0, start, arg, 0, &id);
|
h = CreateThread(NULL, 0, start, arg, 0, &id);
|
||||||
if (h == NULL) {
|
if (h == NULL) {
|
||||||
/* XXX */
|
/* XXX */
|
||||||
return (ISC_R_UNEXPECTED);
|
return (ISC_R_UNEXPECTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
*threadp = h;
|
*threadp = h;
|
||||||
|
|
||||||
return (ISC_R_SUCCESS);
|
return (ISC_R_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
isc_result_t
|
isc_result_t
|
||||||
isc_thread_join(isc_thread_t thread, isc_threadresult_t *rp) {
|
isc_thread_join(isc_thread_t thread, isc_threadresult_t *rp) {
|
||||||
DWORD result;
|
DWORD result;
|
||||||
|
|
||||||
result = WaitForSingleObject(thread, INFINITE);
|
result = WaitForSingleObject(thread, INFINITE);
|
||||||
if (result != WAIT_OBJECT_0) {
|
if (result != WAIT_OBJECT_0) {
|
||||||
/* XXX */
|
/* XXX */
|
||||||
return (ISC_R_UNEXPECTED);
|
return (ISC_R_UNEXPECTED);
|
||||||
}
|
}
|
||||||
if (rp != NULL && !GetExitCodeThread(thread, rp)) {
|
if (rp != NULL && !GetExitCodeThread(thread, rp)) {
|
||||||
/* XXX */
|
/* XXX */
|
||||||
return (ISC_R_UNEXPECTED);
|
return (ISC_R_UNEXPECTED);
|
||||||
}
|
}
|
||||||
return (ISC_R_SUCCESS);
|
|
||||||
}
|
return (ISC_R_SUCCESS);
|
||||||
|
}
|
||||||
isc_result_t isc_thread_detach(isc_thread_t thread) {
|
|
||||||
/* XXX */
|
isc_result_t isc_thread_detach(isc_thread_t thread) {
|
||||||
return (ISC_R_SUCCESS);
|
|
||||||
}
|
/* XXX */
|
||||||
|
|
||||||
|
return (ISC_R_SUCCESS);
|
||||||
|
}
|
||||||
|
@@ -4,8 +4,8 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
#include <isc/assertions.h>
|
#include <isc/assertions.h>
|
||||||
#include <isc/unexpect.h>
|
#include <isc/unexpect.h>
|
||||||
@@ -19,10 +19,11 @@ isc_time_get(isc_time_t t) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
REQUIRE(t != NULL);
|
REQUIRE(t != NULL);
|
||||||
|
|
||||||
/* XXX No nanoseconds! */
|
/* XXX No nanoseconds! */
|
||||||
t->seconds = (unsigned long)time(NULL);
|
t->seconds = (unsigned long)time(NULL);
|
||||||
t->nanoseconds = 0;
|
t->nanoseconds = 0;
|
||||||
|
|
||||||
return (ISC_R_SUCCESS);
|
return (ISC_R_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user