"Fossies" - the Fresh Open Source Software Archive

Member "hitch-1.5.2/src/foreign/vas.h" (27 Aug 2019, 3060 Bytes) of package /linux/www/hitch-1.5.2.tar.gz:


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 "vas.h" see the Fossies "Dox" file reference documentation.

    1 /*-
    2  * Copyright (c) 2006 Verdens Gang AS
    3  * Copyright (c) 2006-2011 Varnish Software AS
    4  * All rights reserved.
    5  *
    6  * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>
    7  *
    8  * Redistribution and use in source and binary forms, with or without
    9  * modification, are permitted provided that the following conditions
   10  * are met:
   11  * 1. Redistributions of source code must retain the above copyright
   12  *    notice, this list of conditions and the following disclaimer.
   13  * 2. Redistributions in binary form must reproduce the above copyright
   14  *    notice, this list of conditions and the following disclaimer in the
   15  *    documentation and/or other materials provided with the distribution.
   16  *
   17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   20  * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
   21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   27  * SUCH DAMAGE.
   28  *
   29  * assert(), AN() and AZ() are static checks that should not happen.
   30  *  In general asserts should be cheap, such as checking return
   31  *  values and similar.
   32  * diagnostic() are asserts which are so expensive that we may want
   33  *  to compile them out for performance at a later date.
   34  * xxxassert(), XXXAN() and XXXAZ() marks conditions we ought to
   35  *  handle gracefully, such as malloc failure.
   36  */
   37 
   38 #ifndef VAS_H_INCLUDED
   39 #define VAS_H_INCLUDED
   40 
   41 enum vas_e {
   42     VAS_WRONG,
   43     VAS_MISSING,
   44     VAS_ASSERT,
   45     VAS_INCOMPLETE,
   46 };
   47 
   48 typedef void vas_f(const char *, const char *, int, const char *, enum vas_e);
   49 
   50 extern vas_f *VAS_Fail __attribute__((__noreturn__));
   51 
   52 #ifdef WITHOUT_ASSERTS
   53 #define assert(e)   ((void)(e))
   54 #else /* WITH_ASSERTS */
   55 #define assert(e)                           \
   56 do {                                    \
   57     if (!(e)) {                         \
   58         VAS_Fail(__func__, __FILE__, __LINE__,          \
   59             #e, VAS_ASSERT);                    \
   60     }                               \
   61 } while (0)
   62 #endif
   63 
   64 #define xxxassert(e)                            \
   65 do {                                    \
   66     if (!(e)) {                         \
   67         VAS_Fail(__func__, __FILE__, __LINE__,          \
   68             #e, VAS_MISSING);                   \
   69     }                               \
   70 } while (0)
   71 
   72 /* Assert zero return value */
   73 #define AZ(foo)     do { assert((foo) == 0); } while (0)
   74 #define AN(foo)     do { assert((foo) != 0); } while (0)
   75 #define XXXAZ(foo)  do { xxxassert((foo) == 0); } while (0)
   76 #define XXXAN(foo)  do { xxxassert((foo) != 0); } while (0)
   77 #define diagnostic(foo) assert(foo)
   78 #define WRONG(expl)                         \
   79 do {                                    \
   80     VAS_Fail(__func__, __FILE__, __LINE__, expl, VAS_WRONG);    \
   81 } while (0)
   82 
   83 #define INCOMPL()                           \
   84 do {                                    \
   85     VAS_Fail(__func__, __FILE__, __LINE__,              \
   86         "", VAS_INCOMPLETE);                    \
   87 } while (0)
   88 
   89 #endif