1 /* MIT License 2 * 3 * Copyright (c) 2009 Daniel Stenberg 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a copy 6 * of this software and associated documentation files (the "Software"), to deal 7 * in the Software without restriction, including without limitation the rights 8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 * copies of the Software, and to permit persons to whom the Software is 10 * furnished to do so, subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice (including the next 13 * paragraph) shall be included in all copies or substantial portions of the 14 * Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 * SOFTWARE. 23 * 24 * SPDX-License-Identifier: MIT 25 */ 26 #ifndef __CARES_RULES_H 27 #define __CARES_RULES_H 28 29 /* ================================================================ */ 30 /* COMPILE TIME SANITY CHECKS */ 31 /* ================================================================ */ 32 33 /* 34 * NOTE 1: 35 * ------- 36 * 37 * All checks done in this file are intentionally placed in a public 38 * header file which is pulled by ares.h when an application is 39 * being built using an already built c-ares library. Additionally 40 * this file is also included and used when building the library. 41 * 42 * If compilation fails on this file it is certainly sure that the 43 * problem is elsewhere. It could be a problem in the ares_build.h 44 * header file, or simply that you are using different compilation 45 * settings than those used to build the library. 46 * 47 * Nothing in this file is intended to be modified or adjusted by the 48 * c-ares library user nor by the c-ares library builder. 49 * 50 * Do not deactivate any check, these are done to make sure that the 51 * library is properly built and used. 52 * 53 * You can find further help on the c-ares development mailing list: 54 * http://lists.haxx.se/listinfo/c-ares/ 55 * 56 * NOTE 2 57 * ------ 58 * 59 * Some of the following compile time checks are based on the fact 60 * that the dimension of a constant array can not be a negative one. 61 * In this way if the compile time verification fails, the compilation 62 * will fail issuing an error. The error description wording is compiler 63 * dependent but it will be quite similar to one of the following: 64 * 65 * "negative subscript or subscript is too large" 66 * "array must have at least one element" 67 * "-1 is an illegal array size" 68 * "size of array is negative" 69 * 70 * If you are building an application which tries to use an already 71 * built c-ares library and you are getting this kind of errors on 72 * this file, it is a clear indication that there is a mismatch between 73 * how the library was built and how you are trying to use it for your 74 * application. Your already compiled or binary library provider is the 75 * only one who can give you the details you need to properly use it. 76 */ 77 78 /* 79 * Verify that some macros are actually defined. 80 */ 81 82 #ifndef CARES_TYPEOF_ARES_SOCKLEN_T 83 # error "CARES_TYPEOF_ARES_SOCKLEN_T definition is missing!" 84 Error Compilation_aborted_CARES_TYPEOF_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 97 * ares_socklen_t is actually the same as the one reported 98 * by sizeof() at compile time. 99 */ 100 101 typedef char __cares_rule_02__[CareschkszEQ( 102 ares_socklen_t, sizeof(CARES_TYPEOF_ARES_SOCKLEN_T))]; 103 104 /* 105 * Verify at compile time that the size of ares_socklen_t as reported 106 * by sizeof() is greater or equal than the one reported for int for 107 * the current compilation. 108 */ 109 110 typedef char __cares_rule_03__[CareschkszGE(ares_socklen_t, int)]; 111 112 /* ================================================================ */ 113 /* EXTERNALLY AND INTERNALLY VISIBLE DEFINITIONS */ 114 /* ================================================================ */ 115 116 /* 117 * Get rid of macros private to this header file. 118 */ 119 120 #undef CareschkszEQ 121 #undef CareschkszGE 122 123 /* 124 * Get rid of macros not intended to exist beyond this point. 125 */ 126 127 #undef CARES_PULL_WS2TCPIP_H 128 #undef CARES_PULL_SYS_TYPES_H 129 #undef CARES_PULL_SYS_SOCKET_H 130 131 #undef CARES_TYPEOF_ARES_SOCKLEN_T 132 133 #endif /* __CARES_RULES_H */ 134