"Fossies" - the Fresh Open Source Software Archive

Member "bind-9.11.23/lib/isc/include/isc/magic.h" (7 Sep 2020, 993 Bytes) of package /linux/misc/dns/bind9/9.11.23/bind-9.11.23.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 "magic.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 
   13 #ifndef ISC_MAGIC_H
   14 #define ISC_MAGIC_H 1
   15 
   16 #include <isc/likely.h>
   17 
   18 /*! \file isc/magic.h */
   19 
   20 typedef struct {
   21     unsigned int magic;
   22 } isc__magic_t;
   23 
   24 
   25 /*%
   26  * To use this macro the magic number MUST be the first thing in the
   27  * structure, and MUST be of type "unsigned int".
   28  * The intent of this is to allow magic numbers to be checked even though
   29  * the object is otherwise opaque.
   30  */
   31 #define ISC_MAGIC_VALID(a,b)    (ISC_LIKELY((a) != NULL) && \
   32                  ISC_LIKELY(((const isc__magic_t *)(a))->magic == (b)))
   33 
   34 #define ISC_MAGIC(a, b, c, d)   ((a) << 24 | (b) << 16 | (c) << 8 | (d))
   35 
   36 #endif /* ISC_MAGIC_H */