"Fossies" - the Fresh Open Source Software Archive

Member "bind-9.16.7/lib/isc/pthreads/include/isc/condition.h" (4 Sep 2020, 1913 Bytes) of package /linux/misc/dns/bind9/9.16.7/bind-9.16.7.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "condition.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2  * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
    3  *
    4  * This Source Code Form is subject to the terms of the Mozilla Public
    5  * License, v. 2.0. If a copy of the MPL was not distributed with this
    6  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
    7  *
    8  * See the COPYRIGHT file distributed with this work for additional
    9  * information regarding copyright ownership.
   10  */
   11 
   12 #pragma once
   13 
   14 /*! \file */
   15 
   16 #include <errno.h>
   17 
   18 #include <isc/error.h>
   19 #include <isc/lang.h>
   20 #include <isc/mutex.h>
   21 #include <isc/result.h>
   22 #include <isc/strerr.h>
   23 #include <isc/string.h>
   24 #include <isc/types.h>
   25 
   26 typedef pthread_cond_t isc_condition_t;
   27 
   28 #define isc_condition_init(cond)                                \
   29     if (pthread_cond_init(cond, NULL) != 0) {               \
   30         char isc_condition_strbuf[ISC_STRERRORSIZE];    \
   31         strerror_r(errno, isc_condition_strbuf,         \
   32                sizeof(isc_condition_strbuf));       \
   33         isc_error_fatal(__FILE__, __LINE__,             \
   34                 "pthread_cond_init failed: %s", \
   35                 isc_condition_strbuf);          \
   36     }
   37 
   38 #if ISC_MUTEX_PROFILE
   39 #define isc_condition_wait(cp, mp)                                      \
   40     ((pthread_cond_wait((cp), &((mp)->mutex)) == 0) ? ISC_R_SUCCESS \
   41                             : ISC_R_UNEXPECTED)
   42 #else /* if ISC_MUTEX_PROFILE */
   43 #define isc_condition_wait(cp, mp)                            \
   44     ((pthread_cond_wait((cp), (mp)) == 0) ? ISC_R_SUCCESS \
   45                           : ISC_R_UNEXPECTED)
   46 #endif /* if ISC_MUTEX_PROFILE */
   47 
   48 #define isc_condition_signal(cp) \
   49     ((pthread_cond_signal((cp)) == 0) ? ISC_R_SUCCESS : ISC_R_UNEXPECTED)
   50 
   51 #define isc_condition_broadcast(cp) \
   52     ((pthread_cond_broadcast((cp)) == 0) ? ISC_R_SUCCESS : ISC_R_UNEXPECTED)
   53 
   54 #define isc_condition_destroy(cp) \
   55     ((pthread_cond_destroy((cp)) == 0) ? ISC_R_SUCCESS : ISC_R_UNEXPECTED)
   56 
   57 ISC_LANG_BEGINDECLS
   58 
   59 isc_result_t
   60 isc_condition_waituntil(isc_condition_t *, isc_mutex_t *, isc_time_t *);
   61 
   62 ISC_LANG_ENDDECLS