1290001Sglebius/* 2290001Sglebius * Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC") 3290001Sglebius * Copyright (C) 1998-2001 Internet Software Consortium. 4290001Sglebius * 5290001Sglebius * Permission to use, copy, modify, and/or distribute this software for any 6290001Sglebius * purpose with or without fee is hereby granted, provided that the above 7290001Sglebius * copyright notice and this permission notice appear in all copies. 8290001Sglebius * 9290001Sglebius * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 10290001Sglebius * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 11290001Sglebius * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 12290001Sglebius * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 13290001Sglebius * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 14290001Sglebius * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 15290001Sglebius * PERFORMANCE OF THIS SOFTWARE. 16290001Sglebius */ 17290001Sglebius 18290001Sglebius/* $Id: condition.h,v 1.26 2007/06/19 23:47:18 tbox Exp $ */ 19290001Sglebius 20290001Sglebius#ifndef ISC_CONDITION_H 21290001Sglebius#define ISC_CONDITION_H 1 22290001Sglebius 23290001Sglebius/*! \file */ 24290001Sglebius 25290001Sglebius#include <isc/lang.h> 26290001Sglebius#include <isc/mutex.h> 27290001Sglebius#include <isc/result.h> 28290001Sglebius#include <isc/types.h> 29290001Sglebius 30290001Sglebiustypedef pthread_cond_t isc_condition_t; 31290001Sglebius 32290001Sglebius#define isc_condition_init(cp) \ 33290001Sglebius ((pthread_cond_init((cp), NULL) == 0) ? \ 34290001Sglebius ISC_R_SUCCESS : ISC_R_UNEXPECTED) 35290001Sglebius 36290001Sglebius#if ISC_MUTEX_PROFILE 37290001Sglebius#define isc_condition_wait(cp, mp) \ 38290001Sglebius ((pthread_cond_wait((cp), &((mp)->mutex)) == 0) ? \ 39290001Sglebius ISC_R_SUCCESS : ISC_R_UNEXPECTED) 40290001Sglebius#else 41290001Sglebius#define isc_condition_wait(cp, mp) \ 42290001Sglebius ((pthread_cond_wait((cp), (mp)) == 0) ? \ 43290001Sglebius ISC_R_SUCCESS : ISC_R_UNEXPECTED) 44290001Sglebius#endif 45290001Sglebius 46290001Sglebius#define isc_condition_signal(cp) \ 47290001Sglebius ((pthread_cond_signal((cp)) == 0) ? \ 48290001Sglebius ISC_R_SUCCESS : ISC_R_UNEXPECTED) 49290001Sglebius 50290001Sglebius#define isc_condition_broadcast(cp) \ 51290001Sglebius ((pthread_cond_broadcast((cp)) == 0) ? \ 52290001Sglebius ISC_R_SUCCESS : ISC_R_UNEXPECTED) 53290001Sglebius 54290001Sglebius#define isc_condition_destroy(cp) \ 55290001Sglebius ((pthread_cond_destroy((cp)) == 0) ? \ 56290001Sglebius ISC_R_SUCCESS : ISC_R_UNEXPECTED) 57290001Sglebius 58290001SglebiusISC_LANG_BEGINDECLS 59290001Sglebius 60290001Sglebiusisc_result_t 61290001Sglebiusisc_condition_waituntil(isc_condition_t *, isc_mutex_t *, isc_time_t *); 62290001Sglebius 63290001SglebiusISC_LANG_ENDDECLS 64290001Sglebius 65290001Sglebius#endif /* ISC_CONDITION_H */ 66