xref: /freebsd/contrib/ldns/ldns/common.h.in (revision d0b2dbfa)
1/**
2 * \file common.h
3 *
4 * Common definitions for LDNS
5 */
6
7/**
8 * a Net::DNS like library for C
9 *
10 * (c) NLnet Labs, 2004-2006
11 *
12 * See the file LICENSE for the license
13 */
14
15#ifndef LDNS_COMMON_H
16#define LDNS_COMMON_H
17
18/*
19 * The build configuration that is used in the distributed headers,
20 * as detected and determined by the auto configure script.
21 */
22#define LDNS_BUILD_CONFIG_HAVE_SSL         @ldns_build_config_have_ssl@
23#define LDNS_BUILD_CONFIG_HAVE_INTTYPES_H  @ldns_build_config_have_inttypes_h@
24#define LDNS_BUILD_CONFIG_HAVE_ATTR_FORMAT @ldns_build_config_have_attr_format@
25#define LDNS_BUILD_CONFIG_HAVE_ATTR_UNUSED @ldns_build_config_have_attr_unused@
26#define LDNS_BUILD_CONFIG_HAVE_SOCKLEN_T   @ldns_build_config_have_socklen_t@
27#define LDNS_BUILD_CONFIG_USE_DANE         @ldns_build_config_use_dane@
28#define LDNS_BUILD_CONFIG_HAVE_B32_PTON    @ldns_build_config_have_b32_pton@
29#define LDNS_BUILD_CONFIG_HAVE_B32_NTOP    @ldns_build_config_have_b32_ntop@
30#define LDNS_BUILD_CONFIG_USE_DSA          @ldns_build_config_use_dsa@
31#define LDNS_BUILD_CONFIG_USE_ED25519      @ldns_build_config_use_ed25519@
32#define LDNS_BUILD_CONFIG_USE_ED448        @ldns_build_config_use_ed448@
33
34/*
35 * HAVE_STDBOOL_H is not available when distributed as a library, but no build
36 * configuration variables may be used (like those above) because the header
37 * is sometimes only available when using special compiler flags to enable the
38 * c99 environment. Because we cannot force the usage of this flag, we have to
39 * provide a default type. Below what is suggested by the autoconf manual.
40 */
41/*@ignore@*/
42/* splint barfs on this construct */
43#ifndef __bool_true_false_are_defined
44# ifdef HAVE_STDBOOL_H
45#  include <stdbool.h>
46# else
47#  ifndef HAVE__BOOL
48#   ifdef __cplusplus
49typedef bool _Bool;
50#   else
51#    define _Bool signed char
52#   endif
53#  endif
54#  define bool _Bool
55#  define false 0
56#  define true 1
57#  define __bool_true_false_are_defined 1
58# endif
59#endif
60/*@end@*/
61
62#if LDNS_BUILD_CONFIG_HAVE_ATTR_FORMAT
63#define ATTR_FORMAT(archetype, string_index, first_to_check) \
64    __attribute__ ((format (archetype, string_index, first_to_check)))
65#else /* !LDNS_BUILD_CONFIG_HAVE_ATTR_FORMAT */
66#define ATTR_FORMAT(archetype, string_index, first_to_check) /* empty */
67#endif /* !LDNS_BUILD_CONFIG_HAVE_ATTR_FORMAT */
68
69#if defined(__cplusplus)
70#define ATTR_UNUSED(x)
71#elif LDNS_BUILD_CONFIG_HAVE_ATTR_UNUSED
72#define ATTR_UNUSED(x)  x __attribute__((unused))
73#else /* !LDNS_BUILD_CONFIG_HAVE_ATTR_UNUSED */
74#define ATTR_UNUSED(x)  x
75#endif /* !LDNS_BUILD_CONFIG_HAVE_ATTR_UNUSED */
76
77#if !LDNS_BUILD_CONFIG_HAVE_SOCKLEN_T
78typedef int socklen_t;
79#endif
80
81#endif /* LDNS_COMMON_H */
82