simplify header include order

pull/797/head
Brad House 5 months ago
parent 94b69fbd45
commit adc6659486
  1. 2
      include/Makefile.am
  2. 69
      include/ares.h
  3. 4
      include/ares_build.h.cmake
  4. 40
      include/ares_build.h.dist
  5. 1
      include/ares_build.h.in
  6. 133
      include/ares_rules.h
  7. 6
      src/lib/ares_setup.h

@ -4,6 +4,6 @@ AUTOMAKE_OPTIONS = foreign nostdinc 1.9.6
ACLOCAL_AMFLAGS = -I m4 --install ACLOCAL_AMFLAGS = -I m4 --install
# what headers to install on 'make install': # what headers to install on 'make install':
include_HEADERS = ares.h ares_version.h ares_build.h ares_rules.h ares_dns.h ares_dns_record.h ares_nameser.h include_HEADERS = ares.h ares_version.h ares_build.h ares_dns.h ares_dns_record.h ares_nameser.h
EXTRA_DIST = ares_build.h.cmake ares_build.h.in ares_build.h.dist CMakeLists.txt EXTRA_DIST = ares_build.h.cmake ares_build.h.in ares_build.h.dist CMakeLists.txt

@ -30,9 +30,43 @@
#include "ares_version.h" /* c-ares version defines */ #include "ares_version.h" /* c-ares version defines */
#include "ares_build.h" /* c-ares build definitions */ #include "ares_build.h" /* c-ares build definitions */
#include "ares_rules.h" /* c-ares rules enforcement */
#include <sys/types.h> #if defined(_WIN32)
# ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
# endif
#endif
#ifdef CARES_HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef CARES_HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef CARES_HAVE_SYS_SELECT_H
# include <sys/select.h>
#endif
#ifdef CARES_HAVE_WINSOCK2_H
# include <winsock2.h>
/* To aid with linking against a static c-ares build, lets tell the microsoft
* compiler to pull in needed dependencies */
# ifdef _MSC_VER
# pragma comment(lib, "ws2_32")
# pragma comment(lib, "advapi32")
# pragma comment(lib, "iphlpapi")
# endif
#endif
#ifdef CARES_HAVE_WS2TCPIP_H
# include <ws2tcpip.h>
#endif
#ifdef CARES_HAVE_WINDOWS_H
# include <windows.h>
#endif
/* HP-UX systems version 9, 10 and 11 lack sys/select.h and so does oldish /* HP-UX systems version 9, 10 and 11 lack sys/select.h and so does oldish
libc5-based Linux systems. Only include it on system that are known to libc5-based Linux systems. Only include it on system that are known to
@ -43,43 +77,26 @@
defined(__QNXNTO__) || defined(__MVS__) || defined(__HAIKU__) defined(__QNXNTO__) || defined(__MVS__) || defined(__HAIKU__)
# include <sys/select.h> # include <sys/select.h>
#endif #endif
#if (defined(NETWARE) && !defined(__NOVELL_LIBC__)) #if (defined(NETWARE) && !defined(__NOVELL_LIBC__))
# include <sys/bsdskt.h> # include <sys/bsdskt.h>
#endif #endif
#if defined(_WIN32) #if !defined(_WIN32)
# ifndef WIN32_LEAN_AND_MEAN # include <netinet/in.h>
# define WIN32_LEAN_AND_MEAN
# endif
#endif #endif
#if defined(WATT32) #ifdef WATT32
# include <netinet/in.h>
# include <sys/socket.h>
# include <tcp.h> # include <tcp.h>
#elif defined(_WIN32_WCE)
# include <windows.h>
# include <winsock.h>
#elif defined(_WIN32)
# include <windows.h>
# include <winsock2.h>
# include <ws2tcpip.h>
/* To aid with linking against a static c-ares build, lets tell the microsoft
* compiler to pull in needed dependencies */
# ifdef _MSC_VER
# pragma comment(lib, "ws2_32")
# pragma comment(lib, "advapi32")
# pragma comment(lib, "iphlpapi")
# endif
#else
# include <sys/socket.h>
# include <netinet/in.h>
#endif #endif
#if defined(ANDROID) || defined(__ANDROID__) #if defined(ANDROID) || defined(__ANDROID__)
# include <jni.h> # include <jni.h>
#endif #endif
typedef CARES_TYPEOF_ARES_SOCKLEN_T ares_socklen_t;
typedef CARES_TYPEOF_ARES_SSIZE_T ares_ssize_t;
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif

@ -44,8 +44,4 @@
# include <windows.h> # include <windows.h>
#endif #endif
typedef CARES_TYPEOF_ARES_SOCKLEN_T ares_socklen_t;
typedef CARES_TYPEOF_ARES_SSIZE_T ares_ssize_t;
#endif /* __CARES_BUILD_H */ #endif /* __CARES_BUILD_H */

@ -173,12 +173,12 @@
# define CARES_HAVE_WINDOWS_H 1 # define CARES_HAVE_WINDOWS_H 1
# define CARES_HAVE_SYS_TYPES_H 1 # define CARES_HAVE_SYS_TYPES_H 1
# if defined(USE_WINSOCK) # if defined(WATT32)
# define CARES_HAVE_WS2TCPIP_H 1
# define CARES_HAVE_WINSOCK2_H 1
# elif defined(WATT32)
# define CARES_HAVE_SYS_SOCKET_H 1 # define CARES_HAVE_SYS_SOCKET_H 1
# define CARES_HAVE_SYS_SELECT_H 1 # define CARES_HAVE_SYS_SELECT_H 1
# else
# define CARES_HAVE_WS2TCPIP_H 1
# define CARES_HAVE_WINSOCK2_H 1
# endif # endif
#elif defined(__GNUC__) #elif defined(__GNUC__)
@ -192,36 +192,6 @@
Error Compilation_aborted_Unknown_non_configure_build_target Error Compilation_aborted_Unknown_non_configure_build_target
#endif #endif
#ifdef CARES_HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef CARES_HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef CARES_HAVE_SYS_SELECT_H
# include <sys/select.h>
#endif
#ifdef CARES_HAVE_WINSOCK2_H
# include <winsock2.h>
#endif
#ifdef CARES_HAVE_WS2TCPIP_H
# include <ws2tcpip.h>
#endif
#ifdef CARES_HAVE_WINDOWS_H
# include <windows.h>
#endif
/* Data type definition of ares_socklen_t. */
#ifdef CARES_TYPEOF_ARES_SOCKLEN_T
typedef CARES_TYPEOF_ARES_SOCKLEN_T ares_socklen_t;
#endif
/* Data type definition of ares_ssize_t. */ /* Data type definition of ares_ssize_t. */
#ifdef _WIN32 #ifdef _WIN32
# ifdef _WIN64 # ifdef _WIN64
@ -233,6 +203,4 @@
# define CARES_TYPEOF_ARES_SSIZE_T ssize_t # define CARES_TYPEOF_ARES_SSIZE_T ssize_t
#endif #endif
typedef CARES_TYPEOF_ARES_SSIZE_T ares_ssize_t;
#endif /* __CARES_BUILD_H */ #endif /* __CARES_BUILD_H */

@ -44,7 +44,6 @@
# include <windows.h> # include <windows.h>
#endif #endif
typedef CARES_TYPEOF_ARES_SOCKLEN_T ares_socklen_t; typedef CARES_TYPEOF_ARES_SOCKLEN_T ares_socklen_t;
typedef CARES_TYPEOF_ARES_SSIZE_T ares_ssize_t; typedef CARES_TYPEOF_ARES_SSIZE_T ares_ssize_t;

@ -1,133 +0,0 @@
/* MIT License
*
* Copyright (c) 2009 Daniel Stenberg
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* SPDX-License-Identifier: MIT
*/
#ifndef __CARES_RULES_H
#define __CARES_RULES_H
/* ================================================================ */
/* COMPILE TIME SANITY CHECKS */
/* ================================================================ */
/*
* NOTE 1:
* -------
*
* All checks done in this file are intentionally placed in a public
* header file which is pulled by ares.h when an application is
* being built using an already built c-ares library. Additionally
* this file is also included and used when building the library.
*
* If compilation fails on this file it is certainly sure that the
* problem is elsewhere. It could be a problem in the ares_build.h
* header file, or simply that you are using different compilation
* settings than those used to build the library.
*
* Nothing in this file is intended to be modified or adjusted by the
* c-ares library user nor by the c-ares library builder.
*
* Do not deactivate any check, these are done to make sure that the
* library is properly built and used.
*
* You can find further help on the c-ares development mailing list:
* http://lists.haxx.se/listinfo/c-ares/
*
* NOTE 2
* ------
*
* Some of the following compile time checks are based on the fact
* that the dimension of a constant array can not be a negative one.
* In this way if the compile time verification fails, the compilation
* will fail issuing an error. The error description wording is compiler
* dependent but it will be quite similar to one of the following:
*
* "negative subscript or subscript is too large"
* "array must have at least one element"
* "-1 is an illegal array size"
* "size of array is negative"
*
* If you are building an application which tries to use an already
* built c-ares library and you are getting this kind of errors on
* this file, it is a clear indication that there is a mismatch between
* how the library was built and how you are trying to use it for your
* application. Your already compiled or binary library provider is the
* only one who can give you the details you need to properly use it.
*/
/*
* Verify that some macros are actually defined.
*/
#ifndef CARES_TYPEOF_ARES_SOCKLEN_T
# error "CARES_TYPEOF_ARES_SOCKLEN_T definition is missing!"
Error Compilation_aborted_CARES_TYPEOF_ARES_SOCKLEN_T_is_missing
#endif
/*
* Macros private to this header file.
*/
#define CareschkszEQ(t, s) sizeof(t) == s ? 1 : -1
#define CareschkszGE(t1, t2) sizeof(t1) >= sizeof(t2) ? 1 : -1
/*
* Verify that the size previously defined and expected for
* ares_socklen_t is actually the same as the one reported
* by sizeof() at compile time.
*/
typedef char __cares_rule_02__[CareschkszEQ(
ares_socklen_t, sizeof(CARES_TYPEOF_ARES_SOCKLEN_T))];
/*
* Verify at compile time that the size of ares_socklen_t as reported
* by sizeof() is greater or equal than the one reported for int for
* the current compilation.
*/
typedef char __cares_rule_03__[CareschkszGE(ares_socklen_t, int)];
/* ================================================================ */
/* EXTERNALLY AND INTERNALLY VISIBLE DEFINITIONS */
/* ================================================================ */
/*
* Get rid of macros private to this header file.
*/
#undef CareschkszEQ
#undef CareschkszGE
/*
* Get rid of macros not intended to exist beyond this point.
*/
#undef CARES_PULL_WS2TCPIP_H
#undef CARES_PULL_SYS_TYPES_H
#undef CARES_PULL_SYS_SOCKET_H
#undef CARES_TYPEOF_ARES_SOCKLEN_T
#endif /* __CARES_RULES_H */

@ -85,12 +85,6 @@
#include <ares_build.h> #include <ares_build.h>
/*
* Compile time sanity checks must also be done when building the library.
*/
#include <ares_rules.h>
/* ================================================================= */ /* ================================================================= */
/* No system header file shall be included in this file before this */ /* No system header file shall be included in this file before this */
/* point. The only allowed ones are those included from ares_build.h */ /* point. The only allowed ones are those included from ares_build.h */

Loading…
Cancel
Save