1/* $NetBSD$ */ 2 3/* 4 * Copyright (C) 2004, 2007 Internet Systems Consortium, Inc. ("ISC") 5 * Copyright (C) 2000, 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.6 2007/06/19 23:47:18 tbox Exp */ 21 22/* 23 * This provides a limited subset of the isc_condition_t 24 * functionality for use by single-threaded programs that 25 * need to block waiting for events. Only a single 26 * call to isc_condition_wait() may be blocked at any given 27 * time, and the _waituntil and _broadcast functions are not 28 * supported. This is intended primarily for use by the omapi 29 * library, and may go away once omapi goes away. Use for 30 * other purposes is strongly discouraged. 31 */ 32 33#ifndef ISC_CONDITION_H 34#define ISC_CONDITION_H 1 35 36#include <isc/mutex.h> 37 38typedef int isc_condition_t; 39 40isc_result_t isc__nothread_wait_hack(isc_condition_t *cp, isc_mutex_t *mp); 41isc_result_t isc__nothread_signal_hack(isc_condition_t *cp); 42 43#define isc_condition_init(cp) \ 44 (*(cp) = 0, ISC_R_SUCCESS) 45 46#define isc_condition_wait(cp, mp) \ 47 isc__nothread_wait_hack(cp, mp) 48 49#define isc_condition_waituntil(cp, mp, tp) \ 50 ((void)(cp), (void)(mp), (void)(tp), ISC_R_NOTIMPLEMENTED) 51 52#define isc_condition_signal(cp) \ 53 isc__nothread_signal_hack(cp) 54 55#define isc_condition_broadcast(cp) \ 56 ((void)(cp), ISC_R_NOTIMPLEMENTED) 57 58#define isc_condition_destroy(cp) \ 59 (*(cp) == 0 ? (*(cp) = -1, ISC_R_SUCCESS) : ISC_R_UNEXPECTED) 60 61#endif /* ISC_CONDITION_H */ 62