ares_rules.h 4.2 KB

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