tizen 2.4 release
[external/c-ares.git] / ares_setup.h
1 #ifndef HEADER_CARES_SETUP_H
2 #define HEADER_CARES_SETUP_H
3
4
5 /* Copyright (C) 2004 - 2012 by Daniel Stenberg et al
6  *
7  * Permission to use, copy, modify, and distribute this software and its
8  * documentation for any purpose and without fee is hereby granted, provided
9  * that the above copyright notice appear in all copies and that both that
10  * copyright notice and this permission notice appear in supporting
11  * documentation, and that the name of M.I.T. not be used in advertising or
12  * publicity pertaining to distribution of the software without specific,
13  * written prior permission.  M.I.T. makes no representations about the
14  * suitability of this software for any purpose.  It is provided "as is"
15  * without express or implied warranty.
16  */
17
18 /*
19  * Define WIN32 when build target is Win32 API
20  */
21
22 #if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32)
23 #define WIN32
24 #endif
25
26 /*
27  * Include configuration script results or hand-crafted
28  * configuration file for platforms which lack config tool.
29  */
30
31 #ifdef HAVE_CONFIG_H
32 #include "ares_config.h"
33 #else
34
35 #ifdef WIN32
36 #include "config-win32.h"
37 #endif
38
39 #endif /* HAVE_CONFIG_H */
40
41 /* ================================================================ */
42 /* Definition of preprocessor macros/symbols which modify compiler  */
43 /* behaviour or generated code characteristics must be done here,   */
44 /* as appropriate, before any system header file is included. It is */
45 /* also possible to have them defined in the config file included   */
46 /* before this point. As a result of all this we frown inclusion of */
47 /* system header files in our config files, avoid this at any cost. */
48 /* ================================================================ */
49
50 /*
51  * AIX 4.3 and newer needs _THREAD_SAFE defined to build
52  * proper reentrant code. Others may also need it.
53  */
54
55 #ifdef NEED_THREAD_SAFE
56 #  ifndef _THREAD_SAFE
57 #    define _THREAD_SAFE
58 #  endif
59 #endif
60
61 /*
62  * Tru64 needs _REENTRANT set for a few function prototypes and
63  * things to appear in the system header files. Unixware needs it
64  * to build proper reentrant code. Others may also need it.
65  */
66
67 #ifdef NEED_REENTRANT
68 #  ifndef _REENTRANT
69 #    define _REENTRANT
70 #  endif
71 #endif
72
73 /* ================================================================ */
74 /*  If you need to include a system header file for your platform,  */
75 /*  please, do it beyond the point further indicated in this file.  */
76 /* ================================================================ */
77
78 /*
79  * c-ares external interface definitions are also used internally,
80  * and might also include required system header files to define them.
81  */
82
83 #include <ares_build.h>
84
85 /*
86  * Compile time sanity checks must also be done when building the library.
87  */
88
89 #include <ares_rules.h>
90
91 /* ================================================================= */
92 /* No system header file shall be included in this file before this  */
93 /* point. The only allowed ones are those included from ares_build.h */
94 /* ================================================================= */
95
96 /*
97  * Include header files for windows builds before redefining anything.
98  * Use this preproessor block only to include or exclude windows.h,
99  * winsock2.h, ws2tcpip.h or winsock.h. Any other windows thing belongs
100  * to any other further and independent block.  Under Cygwin things work
101  * just as under linux (e.g. <sys/socket.h>) and the winsock headers should
102  * never be included when __CYGWIN__ is defined.  configure script takes
103  * care of this, not defining HAVE_WINDOWS_H, HAVE_WINSOCK_H, HAVE_WINSOCK2_H,
104  * neither HAVE_WS2TCPIP_H when __CYGWIN__ is defined.
105  */
106
107 #ifdef HAVE_WINDOWS_H
108 #  ifndef WIN32_LEAN_AND_MEAN
109 #    define WIN32_LEAN_AND_MEAN
110 #  endif
111 #  include <windows.h>
112 #  ifdef HAVE_WINSOCK2_H
113 #    include <winsock2.h>
114 #    ifdef HAVE_WS2TCPIP_H
115 #       include <ws2tcpip.h>
116 #    endif
117 #  else
118 #    ifdef HAVE_WINSOCK_H
119 #      include <winsock.h>
120 #    endif
121 #  endif
122 #endif
123
124 /*
125  * Define USE_WINSOCK to 2 if we have and use WINSOCK2 API, else
126  * define USE_WINSOCK to 1 if we have and use WINSOCK  API, else
127  * undefine USE_WINSOCK.
128  */
129
130 #undef USE_WINSOCK
131
132 #ifdef HAVE_WINSOCK2_H
133 #  define USE_WINSOCK 2
134 #else
135 #  ifdef HAVE_WINSOCK_H
136 #    define USE_WINSOCK 1
137 #  endif
138 #endif
139
140 /*
141  * Work-arounds for systems without configure support
142  */
143
144 #ifndef HAVE_CONFIG_H
145
146 #if !defined(HAVE_SYS_TIME_H) && !defined(_MSC_VER) && !defined(__WATCOMC__)
147 #define HAVE_SYS_TIME_H
148 #endif
149
150 #if !defined(HAVE_UNISTD_H) && !defined(_MSC_VER)
151 #define HAVE_UNISTD_H 1
152 #endif
153
154 #if !defined(HAVE_SYS_UIO_H) && !defined(WIN32) && !defined(MSDOS)
155 #define HAVE_SYS_UIO_H
156 #endif
157
158 #endif /* HAVE_CONFIG_H */
159
160 /*
161  * Arg 2 type for gethostname in case it hasn't been defined in config file.
162  */
163
164 #ifndef GETHOSTNAME_TYPE_ARG2
165 #  ifdef USE_WINSOCK
166 #    define GETHOSTNAME_TYPE_ARG2 int
167 #  else
168 #    define GETHOSTNAME_TYPE_ARG2 size_t
169 #  endif
170 #endif
171
172 #ifdef __POCC__
173 #  include <sys/types.h>
174 #  include <unistd.h>
175 #  define ESRCH 3
176 #endif
177
178 /*
179  * Android does have the arpa/nameser.h header which is detected by configure
180  * but it appears to be empty with recent NDK r7b / r7c, so we undefine here.
181  */
182 #if (defined(ANDROID) || defined(__ANDROID__)) && defined(HAVE_ARPA_NAMESER_H)
183 #  undef HAVE_ARPA_NAMESER_H
184 #endif
185
186 /*
187  * Recent autoconf versions define these symbols in ares_config.h. We don't
188  * want them (since they collide with the libcurl ones when we build
189  *  --enable-debug) so we undef them again here.
190  */
191
192 #undef PACKAGE_STRING
193 #undef PACKAGE_TARNAME
194 #undef PACKAGE_VERSION
195 #undef PACKAGE_BUGREPORT
196 #undef PACKAGE_NAME
197 #undef VERSION
198 #undef PACKAGE
199
200 /* IPv6 compatibility */
201 #if !defined(HAVE_AF_INET6)
202 #if defined(HAVE_PF_INET6)
203 #define AF_INET6 PF_INET6
204 #else
205 #define AF_INET6 AF_MAX+1
206 #endif
207 #endif
208
209 /*
210  * Include macros and defines that should only be processed once.
211  */
212
213 #ifndef __SETUP_ONCE_H
214 #include "setup_once.h"
215 #endif
216
217 #endif /* HEADER_CARES_SETUP_H */