1 /* $NetBSD: magic.h,v 1.8 2025/01/26 16:25:41 christos Exp $ */ 2 3 /* 4 * Copyright (C) Internet Systems Consortium, Inc. ("ISC") 5 * 6 * SPDX-License-Identifier: MPL-2.0 7 * 8 * This Source Code Form is subject to the terms of the Mozilla Public 9 * License, v. 2.0. If a copy of the MPL was not distributed with this 10 * file, you can obtain one at https://mozilla.org/MPL/2.0/. 11 * 12 * See the COPYRIGHT file distributed with this work for additional 13 * information regarding copyright ownership. 14 */ 15 16 #pragma once 17 18 /*! \file isc/magic.h */ 19 20 typedef struct { 21 unsigned int magic; 22 } isc__magic_t; 23 24 /*% 25 * To use this macro the magic number MUST be the first thing in the 26 * structure, and MUST be of type "unsigned int". 27 * The intent of this is to allow magic numbers to be checked even though 28 * the object is otherwise opaque. 29 */ 30 #define ISC_MAGIC_VALID(a, b) \ 31 ((a) != NULL && ((const isc__magic_t *)(a))->magic == (b)) 32 33 #define ISC_MAGIC(a, b, c, d) ((a) << 24 | (b) << 16 | (c) << 8 | (d)) 34