00001 /* 00002 * Copyright (C) 2004, 2007 Internet Systems Consortium, Inc. ("ISC") 00003 * Copyright (C) 2000, 2001 Internet Software Consortium. 00004 * 00005 * Permission to use, copy, modify, and/or distribute this software for any 00006 * purpose with or without fee is hereby granted, provided that the above 00007 * copyright notice and this permission notice appear in all copies. 00008 * 00009 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 00010 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 00011 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 00012 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 00013 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 00014 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 00015 * PERFORMANCE OF THIS SOFTWARE. 00016 */ 00017 00018 /* $Id: condition.h,v 1.6 2007/06/19 23:47:18 tbox Exp $ */ 00019 00020 /* 00021 * This provides a limited subset of the isc_condition_t 00022 * functionality for use by single-threaded programs that 00023 * need to block waiting for events. Only a single 00024 * call to isc_condition_wait() may be blocked at any given 00025 * time, and the _waituntil and _broadcast functions are not 00026 * supported. This is intended primarily for use by the omapi 00027 * library, and may go away once omapi goes away. Use for 00028 * other purposes is strongly discouraged. 00029 */ 00030 00031 #ifndef ISC_CONDITION_H 00032 #define ISC_CONDITION_H 1 00033 00034 #include <isc/mutex.h> 00035 00036 typedef int isc_condition_t; 00037 00038 isc_result_t isc__nothread_wait_hack(isc_condition_t *cp, isc_mutex_t *mp); 00039 isc_result_t isc__nothread_signal_hack(isc_condition_t *cp); 00040 00041 #define isc_condition_init(cp) \ 00042 (*(cp) = 0, ISC_R_SUCCESS) 00043 00044 #define isc_condition_wait(cp, mp) \ 00045 isc__nothread_wait_hack(cp, mp) 00046 00047 #define isc_condition_waituntil(cp, mp, tp) \ 00048 ((void)(cp), (void)(mp), (void)(tp), ISC_R_NOTIMPLEMENTED) 00049 00050 #define isc_condition_signal(cp) \ 00051 isc__nothread_signal_hack(cp) 00052 00053 #define isc_condition_broadcast(cp) \ 00054 ((void)(cp), ISC_R_NOTIMPLEMENTED) 00055 00056 #define isc_condition_destroy(cp) \ 00057 (*(cp) == 0 ? (*(cp) = -1, ISC_R_SUCCESS) : ISC_R_UNEXPECTED) 00058 00059 #endif /* ISC_CONDITION_H */