Fix spelling
[platform/upstream/c-ares.git] / ares_rules.h
1 #ifndef __CARES_RULES_H
2 #define __CARES_RULES_H
3
4 /* $Id$ */
5
6 /* Copyright (C) 2009 by Daniel Stenberg et al
7  *
8  * Permission to use, copy, modify, and distribute this software and its
9  * documentation for any purpose and without fee is hereby granted, provided
10  * that the above copyright notice appear in all copies and that both that
11  * copyright notice and this permission notice appear in supporting
12  * documentation, and that the name of M.I.T. not be used in advertising or
13  * publicity pertaining to distribution of the software without specific,
14  * written prior permission.  M.I.T. makes no representations about the
15  * suitability of this software for any purpose.  It is provided "as is"
16  * without express or implied warranty.
17  */
18
19 /* ================================================================ */
20 /*                    COMPILE TIME SANITY CHECKS                    */
21 /* ================================================================ */
22
23 /*
24  * NOTE 1:
25  * -------
26  *
27  * All checks done in this file are intentionally placed in a public
28  * header file which is pulled by ares.h when an application is
29  * being built using an already built c-ares library. Additionally
30  * this file is also included and used when building the library.
31  *
32  * If compilation fails on this file it is certainly sure that the
33  * problem is elsewhere. It could be a problem in the ares_build.h
34  * header file, or simply that you are using different compilation
35  * settings than those used to build the library.
36  *
37  * Nothing in this file is intended to be modified or adjusted by the
38  * c-ares library user nor by the c-ares library builder.
39  *
40  * Do not deactivate any check, these are done to make sure that the
41  * library is properly built and used.
42  *
43  * You can find further help on the c-ares development mailing list:
44  * http://cool.haxx.se/mailman/listinfo/c-ares/
45  *
46  * NOTE 2
47  * ------
48  *
49  * Some of the following compile time checks are based on the fact
50  * that the dimension of a constant array can not be a negative one.
51  * In this way if the compile time verification fails, the compilation
52  * will fail issuing an error. The error description wording is compiler
53  * dependent but it will be quite similar to one of the following:
54  *
55  *   "negative subscript or subscript is too large"
56  *   "array must have at least one element"
57  *   "-1 is an illegal array size"
58  *   "size of array is negative"
59  *
60  * If you are building an application which tries to use an already
61  * built c-ares library and you are getting this kind of errors on
62  * this file, it is a clear indication that there is a mismatch between
63  * how the library was built and how you are trying to use it for your
64  * application. Your already compiled or binary library provider is the
65  * only one who can give you the details you need to properly use it.
66  */
67
68 /*
69  * Verify that some macros are actually defined.
70  */
71
72 #ifndef CARES_SIZEOF_LONG
73 #  error "CARES_SIZEOF_LONG definition is missing!"
74    Error Compilation_aborted_CARES_SIZEOF_LONG_is_missing
75 #endif
76
77 #ifndef CARES_TYPEOF_ARES_SOCKLEN_T
78 #  error "CARES_TYPEOF_ARES_SOCKLEN_T definition is missing!"
79    Error Compilation_aborted_CARES_TYPEOF_ARES_SOCKLEN_T_is_missing
80 #endif
81
82 #ifndef CARES_SIZEOF_ARES_SOCKLEN_T
83 #  error "CARES_SIZEOF_ARES_SOCKLEN_T definition is missing!"
84    Error Compilation_aborted_CARES_SIZEOF_ARES_SOCKLEN_T_is_missing
85 #endif
86
87 /*
88  * Macros private to this header file.
89  */
90
91 #define CareschkszEQ(t, s) sizeof(t) == s ? 1 : -1
92
93 #define CareschkszGE(t1, t2) sizeof(t1) >= sizeof(t2) ? 1 : -1
94
95 /*
96  * Verify that the size previously defined and expected for long
97  * is the same as the one reported by sizeof() at compile time.
98  */
99
100 typedef char
101   __cares_rule_01__
102     [CareschkszEQ(long, CARES_SIZEOF_LONG)];
103
104 /*
105  * Verify that the size previously defined and expected for
106  * ares_socklen_t is actually the the same as the one reported
107  * by sizeof() at compile time.
108  */
109
110 typedef char
111   __cares_rule_02__
112     [CareschkszEQ(ares_socklen_t, CARES_SIZEOF_ARES_SOCKLEN_T)];
113
114 /*
115  * Verify at compile time that the size of ares_socklen_t as reported
116  * by sizeof() is greater or equal than the one reported for int for
117  * the current compilation.
118  */
119
120 typedef char
121   __cares_rule_03__
122     [CareschkszGE(ares_socklen_t, int)];
123
124 /* ================================================================ */
125 /*          EXTERNALLY AND INTERNALLY VISIBLE DEFINITIONS           */
126 /* ================================================================ */
127
128 /*
129  * Get rid of macros private to this header file.
130  */
131
132 #undef CareschkszEQ
133 #undef CareschkszGE
134
135 /*
136  * Get rid of macros not intended to exist beyond this point.
137  */
138
139 #undef CARES_PULL_WS2TCPIP_H
140 #undef CARES_PULL_SYS_TYPES_H
141 #undef CARES_PULL_SYS_SOCKET_H
142
143 #undef CARES_TYPEOF_ARES_SOCKLEN_T
144
145 #endif /* __CARES_RULES_H */