1/* $NetBSD$ */ 2 3/* 4 * Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC") 5 * Copyright (C) 1998-2001 Internet Software Consortium. 6 * 7 * Permission to use, copy, modify, and/or distribute this software for any 8 * purpose with or without fee is hereby granted, provided that the above 9 * copyright notice and this permission notice appear in all copies. 10 * 11 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 12 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 13 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 14 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 15 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 16 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 17 * PERFORMANCE OF THIS SOFTWARE. 18 */ 19 20/* Id: condition.h,v 1.26 2007/06/19 23:47:18 tbox Exp */ 21 22#ifndef ISC_CONDITION_H 23#define ISC_CONDITION_H 1 24 25/*! \file */ 26 27#include <isc/lang.h> 28#include <isc/mutex.h> 29#include <isc/result.h> 30#include <isc/types.h> 31 32typedef pthread_cond_t isc_condition_t; 33 34#define isc_condition_init(cp) \ 35 ((pthread_cond_init((cp), NULL) == 0) ? \ 36 ISC_R_SUCCESS : ISC_R_UNEXPECTED) 37 38#if ISC_MUTEX_PROFILE 39#define isc_condition_wait(cp, mp) \ 40 ((pthread_cond_wait((cp), &((mp)->mutex)) == 0) ? \ 41 ISC_R_SUCCESS : ISC_R_UNEXPECTED) 42#else 43#define isc_condition_wait(cp, mp) \ 44 ((pthread_cond_wait((cp), (mp)) == 0) ? \ 45 ISC_R_SUCCESS : ISC_R_UNEXPECTED) 46#endif 47 48#define isc_condition_signal(cp) \ 49 ((pthread_cond_signal((cp)) == 0) ? \ 50 ISC_R_SUCCESS : ISC_R_UNEXPECTED) 51 52#define isc_condition_broadcast(cp) \ 53 ((pthread_cond_broadcast((cp)) == 0) ? \ 54 ISC_R_SUCCESS : ISC_R_UNEXPECTED) 55 56#define isc_condition_destroy(cp) \ 57 ((pthread_cond_destroy((cp)) == 0) ? \ 58 ISC_R_SUCCESS : ISC_R_UNEXPECTED) 59 60ISC_LANG_BEGINDECLS 61 62isc_result_t 63isc_condition_waituntil(isc_condition_t *, isc_mutex_t *, isc_time_t *); 64 65ISC_LANG_ENDDECLS 66 67#endif /* ISC_CONDITION_H */ 68