1998-12-12 20:48:14 +00:00
|
|
|
/*
|
2018-02-23 09:53:12 +01:00
|
|
|
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
2000-08-01 01:33:37 +00:00
|
|
|
*
|
2021-06-03 08:37:05 +02:00
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
|
|
*
|
2016-06-27 14:56:38 +10:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
2020-09-14 16:20:40 -07:00
|
|
|
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
|
2018-02-23 09:53:12 +01:00
|
|
|
*
|
|
|
|
* See the COPYRIGHT file distributed with this work for additional
|
|
|
|
* information regarding copyright ownership.
|
1998-12-12 20:48:14 +00:00
|
|
|
*/
|
1998-08-18 00:37:02 +00:00
|
|
|
|
2018-11-15 17:20:36 +01:00
|
|
|
#pragma once
|
2005-04-27 04:57:32 +00:00
|
|
|
|
|
|
|
/*! \file */
|
1998-08-18 00:37:02 +00:00
|
|
|
|
2018-11-15 17:20:36 +01:00
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
#include <isc/error.h>
|
1999-03-04 02:38:48 +00:00
|
|
|
#include <isc/lang.h>
|
2000-04-28 18:58:40 +00:00
|
|
|
#include <isc/mutex.h>
|
|
|
|
#include <isc/result.h>
|
2018-11-16 15:33:22 +01:00
|
|
|
#include <isc/string.h>
|
2000-04-28 18:58:40 +00:00
|
|
|
#include <isc/types.h>
|
|
|
|
#include <isc/util.h>
|
1998-08-18 00:37:02 +00:00
|
|
|
|
1998-10-22 01:33:20 +00:00
|
|
|
typedef pthread_cond_t isc_condition_t;
|
1998-08-18 00:37:02 +00:00
|
|
|
|
|
|
|
#define isc_condition_init(cond) \
|
|
|
|
{ \
|
|
|
|
int _ret = pthread_cond_init(cond, NULL); \
|
|
|
|
ERRNO_CHECK(pthread_cond_init, _ret); \
|
2018-11-15 17:20:36 +01:00
|
|
|
}
|
1998-08-18 00:37:02 +00:00
|
|
|
|
2020-02-12 13:59:18 +01:00
|
|
|
#define isc_condition_wait(cp, mp) \
|
|
|
|
((pthread_cond_wait((cp), (mp)) == 0) ? ISC_R_SUCCESS \
|
|
|
|
: ISC_R_UNEXPECTED)
|
1998-08-20 22:21:35 +00:00
|
|
|
|
1998-10-22 01:33:20 +00:00
|
|
|
#define isc_condition_signal(cp) \
|
2020-02-12 13:59:18 +01:00
|
|
|
((pthread_cond_signal((cp)) == 0) ? ISC_R_SUCCESS : ISC_R_UNEXPECTED)
|
1998-10-22 01:33:20 +00:00
|
|
|
|
|
|
|
#define isc_condition_broadcast(cp) \
|
2020-02-12 13:59:18 +01:00
|
|
|
((pthread_cond_broadcast((cp)) == 0) ? ISC_R_SUCCESS : ISC_R_UNEXPECTED)
|
1998-10-22 01:33:20 +00:00
|
|
|
|
|
|
|
#define isc_condition_destroy(cp) \
|
2020-02-12 13:59:18 +01:00
|
|
|
((pthread_cond_destroy((cp)) == 0) ? ISC_R_SUCCESS : ISC_R_UNEXPECTED)
|
1998-10-22 01:33:20 +00:00
|
|
|
|
2000-04-28 18:58:40 +00:00
|
|
|
ISC_LANG_BEGINDECLS
|
|
|
|
|
|
|
|
isc_result_t
|
|
|
|
isc_condition_waituntil(isc_condition_t *, isc_mutex_t *, isc_time_t *);
|
1998-10-22 01:33:20 +00:00
|
|
|
|
1999-03-04 02:38:48 +00:00
|
|
|
ISC_LANG_ENDDECLS
|