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_BUILD_H
27 #define __CARES_BUILD_H
28 
29 
30 /* ================================================================ */
31 /*               NOTES FOR CONFIGURE CAPABLE SYSTEMS                */
32 /* ================================================================ */
33 
34 /*
35  * NOTE 1:
36  * -------
37  *
38  * See file ares_build.h.in, run configure, and forget that this file
39  * exists it is only used for non-configure systems.
40  * But you can keep reading if you want ;-)
41  *
42  */
43 
44 /* ================================================================ */
45 /*                 NOTES FOR NON-CONFIGURE SYSTEMS                  */
46 /* ================================================================ */
47 
48 /*
49  * NOTE 1:
50  * -------
51  *
52  * Nothing in this file is intended to be modified or adjusted by the
53  * c-ares library user nor by the c-ares library builder.
54  *
55  * If you think that something actually needs to be changed, adjusted
56  * or fixed in this file, then, report it on the c-ares development
57  * mailing list: http://lists.haxx.se/listinfo/c-ares/
58  *
59  * Try to keep one section per platform, compiler and architecture,
60  * otherwise, if an existing section is reused for a different one and
61  * later on the original is adjusted, probably the piggybacking one can
62  * be adversely changed.
63  *
64  * In order to differentiate between platforms/compilers/architectures
65  * use only compiler built in predefined preprocessor symbols.
66  *
67  * This header file shall only export symbols which are 'cares' or 'CARES'
68  * prefixed, otherwise public name space would be polluted.
69  *
70  * NOTE 2:
71  * -------
72  *
73  * Right now you might be staring at file ares_build.h.dist or ares_build.h,
74  * this is due to the following reason: file ares_build.h.dist is renamed
75  * to ares_build.h when the c-ares source code distribution archive file is
76  * created.
77  *
78  * File ares_build.h.dist is not included in the distribution archive.
79  * File ares_build.h is not present in the git tree.
80  *
81  * The distributed ares_build.h file is only intended to be used on systems
82  * which can not run the also distributed configure script.
83  *
84  * On systems capable of running the configure script, the configure process
85  * will overwrite the distributed ares_build.h file with one that is suitable
86  * and specific to the library being configured and built, which is generated
87  * from the ares_build.h.in template file.
88  *
89  * If you check out from git on a non-configure platform, you must run the
90  * appropriate buildconf* script to set up ares_build.h and other local files.
91  *
92  */
93 
94 /* ================================================================ */
95 /*  DEFINITION OF THESE SYMBOLS SHALL NOT TAKE PLACE ANYWHERE ELSE  */
96 /* ================================================================ */
97 
98 #ifdef CARES_TYPEOF_ARES_SOCKLEN_T
99 #  error "CARES_TYPEOF_ARES_SOCKLEN_T shall not be defined except in ares_build.h"
100    Error Compilation_aborted_CARES_TYPEOF_ARES_SOCKLEN_T_already_defined
101 #endif
102 
103 /* ================================================================ */
104 /*    EXTERNAL INTERFACE SETTINGS FOR NON-CONFIGURE SYSTEMS ONLY    */
105 /* ================================================================ */
106 
107 #if defined(__DJGPP__) || defined(__GO32__)
108 #  define CARES_TYPEOF_ARES_SOCKLEN_T int
109 
110 #elif defined(__SALFORDC__)
111 #  define CARES_TYPEOF_ARES_SOCKLEN_T int
112 
113 #elif defined(__BORLANDC__)
114 #  define CARES_TYPEOF_ARES_SOCKLEN_T int
115 
116 #elif defined(__TURBOC__)
117 #  define CARES_TYPEOF_ARES_SOCKLEN_T int
118 
119 #elif defined(__WATCOMC__)
120 #  define CARES_TYPEOF_ARES_SOCKLEN_T int
121 
122 #elif defined(__POCC__)
123 #  define CARES_TYPEOF_ARES_SOCKLEN_T int
124 
125 #elif defined(__LCC__)
126 #  define CARES_TYPEOF_ARES_SOCKLEN_T int
127 
128 #elif defined(__SYMBIAN32__)
129 #  define CARES_TYPEOF_ARES_SOCKLEN_T unsigned int
130 
131 #elif defined(__MWERKS__)
132 #  define CARES_TYPEOF_ARES_SOCKLEN_T int
133 
134 #elif defined(_WIN32_WCE)
135 #  define CARES_TYPEOF_ARES_SOCKLEN_T int
136 
137 #elif defined(__MINGW32__)
138 #  define CARES_TYPEOF_ARES_SOCKLEN_T int
139 
140 #elif defined(__VMS)
141 #  define CARES_TYPEOF_ARES_SOCKLEN_T unsigned int
142 
143 #elif defined(__OS400__)
144 #  if defined(__ILEC400__)
145 #    define CARES_TYPEOF_ARES_SOCKLEN_T socklen_t
146 #    define CARES_PULL_SYS_TYPES_H      1
147 #    define CARES_PULL_SYS_SOCKET_H     1
148 #  endif
149 
150 #elif defined(__MVS__)
151 #  if defined(__IBMC__) || defined(__IBMCPP__)
152 #    define CARES_TYPEOF_ARES_SOCKLEN_T socklen_t
153 #    define CARES_PULL_SYS_TYPES_H      1
154 #    define CARES_PULL_SYS_SOCKET_H     1
155 #  endif
156 
157 #elif defined(__370__)
158 #  if defined(__IBMC__) || defined(__IBMCPP__)
159 #    define CARES_TYPEOF_ARES_SOCKLEN_T socklen_t
160 #    define CARES_PULL_SYS_TYPES_H      1
161 #    define CARES_PULL_SYS_SOCKET_H     1
162 #  endif
163 
164 #elif defined(TPF)
165 #  define CARES_TYPEOF_ARES_SOCKLEN_T int
166 
167 /* ===================================== */
168 /*    KEEP MSVC THE PENULTIMATE ENTRY    */
169 /* ===================================== */
170 
171 #elif defined(_MSC_VER)
172 #  define CARES_TYPEOF_ARES_SOCKLEN_T int
173 
174 /* ===================================== */
175 /*    KEEP GENERIC GCC THE LAST ENTRY    */
176 /* ===================================== */
177 
178 #elif defined(__GNUC__)
179 #  define CARES_TYPEOF_ARES_SOCKLEN_T socklen_t
180 #  define CARES_PULL_SYS_TYPES_H      1
181 #  define CARES_PULL_SYS_SOCKET_H     1
182 
183 #else
184 #  error "Unknown non-configure build target!"
185    Error Compilation_aborted_Unknown_non_configure_build_target
186 #endif
187 
188 /* CARES_PULL_SYS_TYPES_H is defined above when inclusion of header file  */
189 /* sys/types.h is required here to properly make type definitions below.  */
190 #ifdef CARES_PULL_SYS_TYPES_H
191 #  include <sys/types.h>
192 #endif
193 
194 /* CARES_PULL_SYS_SOCKET_H is defined above when inclusion of header file  */
195 /* sys/socket.h is required here to properly make type definitions below.  */
196 #ifdef CARES_PULL_SYS_SOCKET_H
197 #  include <sys/socket.h>
198 #endif
199 
200 /* Data type definition of ares_socklen_t. */
201 
202 #ifdef CARES_TYPEOF_ARES_SOCKLEN_T
203   typedef CARES_TYPEOF_ARES_SOCKLEN_T ares_socklen_t;
204 #endif
205 
206 /* Data type definition of ares_ssize_t. */
207 #ifdef _WIN32
208 #  ifdef _WIN64
209 #    define CARES_TYPEOF_ARES_SSIZE_T __int64
210 #  else
211 #    define CARES_TYPEOF_ARES_SSIZE_T long
212 #  endif
213 #else
214 #  define CARES_TYPEOF_ARES_SSIZE_T ssize_t
215 #endif
216 
217 typedef CARES_TYPEOF_ARES_SSIZE_T ares_ssize_t;
218 
219 #endif /* __CARES_BUILD_H */
220