1#ifndef __CURL_SYSTEM_H
2#define __CURL_SYSTEM_H
3/***************************************************************************
4 * _ _ ____ _
5 * Project ___| | | | _ \| |
6 * / __| | | | |_) | |
7 * | (__| |_| | _ <| |___
8 * \___|\___/|_| \_\_____|
9 *
10 * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
11 *
12 * This software is licensed as described in the file COPYING, which
13 * you should have received as part of this distribution. The terms
14 * are also available at https://curl.haxx.se/docs/copyright.html.
15 *
16 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17 * copies of the Software, and permit persons to whom the Software is
18 * furnished to do so, under the terms of the COPYING file.
19 *
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
22 *
23 ***************************************************************************/
24
25/*
26 * Try to keep one section per platform, compiler and architecture, otherwise,
27 * if an existing section is reused for a different one and later on the
28 * original is adjusted, probably the piggybacking one can be adversely
29 * changed.
30 *
31 * In order to differentiate between platforms/compilers/architectures use
32 * only compiler built in predefined preprocessor symbols.
33 *
34 * curl_off_t
35 * ----------
36 *
37 * For any given platform/compiler curl_off_t must be typedef'ed to a 64-bit
38 * wide signed integral data type. The width of this data type must remain
39 * constant and independent of any possible large file support settings.
40 *
41 * As an exception to the above, curl_off_t shall be typedef'ed to a 32-bit
42 * wide signed integral data type if there is no 64-bit type.
43 *
44 * As a general rule, curl_off_t shall not be mapped to off_t. This rule shall
45 * only be violated if off_t is the only 64-bit data type available and the
46 * size of off_t is independent of large file support settings. Keep your
47 * build on the safe side avoiding an off_t gating. If you have a 64-bit
48 * off_t then take for sure that another 64-bit data type exists, dig deeper
49 * and you will find it.
50 *
51 */
52
53#if defined(__DJGPP__) || defined(__GO32__)
54# if defined(__DJGPP__) && (__DJGPP__ > 1)
55# define CURL_TYPEOF_CURL_OFF_T long long
56# define CURL_FORMAT_CURL_OFF_T "lld"
57# define CURL_FORMAT_CURL_OFF_TU "llu"
58# define CURL_SUFFIX_CURL_OFF_T LL
59# define CURL_SUFFIX_CURL_OFF_TU ULL
60# else
61# define CURL_TYPEOF_CURL_OFF_T long
62# define CURL_FORMAT_CURL_OFF_T "ld"
63# define CURL_FORMAT_CURL_OFF_TU "lu"
64# define CURL_SUFFIX_CURL_OFF_T L
65# define CURL_SUFFIX_CURL_OFF_TU UL
66# endif
67# define CURL_TYPEOF_CURL_SOCKLEN_T int
68
69#elif defined(__SALFORDC__)
70# define CURL_TYPEOF_CURL_OFF_T long
71# define CURL_FORMAT_CURL_OFF_T "ld"
72# define CURL_FORMAT_CURL_OFF_TU "lu"
73# define CURL_SUFFIX_CURL_OFF_T L
74# define CURL_SUFFIX_CURL_OFF_TU UL
75# define CURL_TYPEOF_CURL_SOCKLEN_T int
76
77#elif defined(__BORLANDC__)
78# if (__BORLANDC__ < 0x520)
79# define CURL_TYPEOF_CURL_OFF_T long
80# define CURL_FORMAT_CURL_OFF_T "ld"
81# define CURL_FORMAT_CURL_OFF_TU "lu"
82# define CURL_SUFFIX_CURL_OFF_T L
83# define CURL_SUFFIX_CURL_OFF_TU UL
84# else
85# define CURL_TYPEOF_CURL_OFF_T __int64
86# define CURL_FORMAT_CURL_OFF_T "I64d"
87# define CURL_FORMAT_CURL_OFF_TU "I64u"
88# define CURL_SUFFIX_CURL_OFF_T i64
89# define CURL_SUFFIX_CURL_OFF_TU ui64
90# endif
91# define CURL_TYPEOF_CURL_SOCKLEN_T int
92
93#elif defined(__TURBOC__)
94# define CURL_TYPEOF_CURL_OFF_T long
95# define CURL_FORMAT_CURL_OFF_T "ld"
96# define CURL_FORMAT_CURL_OFF_TU "lu"
97# define CURL_SUFFIX_CURL_OFF_T L
98# define CURL_SUFFIX_CURL_OFF_TU UL
99# define CURL_TYPEOF_CURL_SOCKLEN_T int
100
101#elif defined(__WATCOMC__)
102# if defined(__386__)
103# define CURL_TYPEOF_CURL_OFF_T __int64
104# define CURL_FORMAT_CURL_OFF_T "I64d"
105# define CURL_FORMAT_CURL_OFF_TU "I64u"
106# define CURL_SUFFIX_CURL_OFF_T i64
107# define CURL_SUFFIX_CURL_OFF_TU ui64
108# else
109# define CURL_TYPEOF_CURL_OFF_T long
110# define CURL_FORMAT_CURL_OFF_T "ld"
111# define CURL_FORMAT_CURL_OFF_TU "lu"
112# define CURL_SUFFIX_CURL_OFF_T L
113# define CURL_SUFFIX_CURL_OFF_TU UL
114# endif
115# define CURL_TYPEOF_CURL_SOCKLEN_T int
116
117#elif defined(__POCC__)
118# if (__POCC__ < 280)
119# define CURL_TYPEOF_CURL_OFF_T long
120# define CURL_FORMAT_CURL_OFF_T "ld"
121# define CURL_FORMAT_CURL_OFF_TU "lu"
122# define CURL_SUFFIX_CURL_OFF_T L
123# define CURL_SUFFIX_CURL_OFF_TU UL
124# elif defined(_MSC_VER)
125# define CURL_TYPEOF_CURL_OFF_T __int64
126# define CURL_FORMAT_CURL_OFF_T "I64d"
127# define CURL_FORMAT_CURL_OFF_TU "I64u"
128# define CURL_SUFFIX_CURL_OFF_T i64
129# define CURL_SUFFIX_CURL_OFF_TU ui64
130# else
131# define CURL_TYPEOF_CURL_OFF_T long long
132# define CURL_FORMAT_CURL_OFF_T "lld"
133# define CURL_FORMAT_CURL_OFF_TU "llu"
134# define CURL_SUFFIX_CURL_OFF_T LL
135# define CURL_SUFFIX_CURL_OFF_TU ULL
136# endif
137# define CURL_TYPEOF_CURL_SOCKLEN_T int
138
139#elif defined(__LCC__)
140# define CURL_TYPEOF_CURL_OFF_T long
141# define CURL_FORMAT_CURL_OFF_T "ld"
142# define CURL_FORMAT_CURL_OFF_TU "lu"
143# define CURL_SUFFIX_CURL_OFF_T L
144# define CURL_SUFFIX_CURL_OFF_TU UL
145# define CURL_TYPEOF_CURL_SOCKLEN_T int
146
147#elif defined(__SYMBIAN32__)
148# if defined(__EABI__) /* Treat all ARM compilers equally */
149# define CURL_TYPEOF_CURL_OFF_T long long
150# define CURL_FORMAT_CURL_OFF_T "lld"
151# define CURL_FORMAT_CURL_OFF_TU "llu"
152# define CURL_SUFFIX_CURL_OFF_T LL
153# define CURL_SUFFIX_CURL_OFF_TU ULL
154# elif defined(__CW32__)
155# pragma longlong on
156# define CURL_TYPEOF_CURL_OFF_T long long
157# define CURL_FORMAT_CURL_OFF_T "lld"
158# define CURL_FORMAT_CURL_OFF_TU "llu"
159# define CURL_SUFFIX_CURL_OFF_T LL
160# define CURL_SUFFIX_CURL_OFF_TU ULL
161# elif defined(__VC32__)
162# define CURL_TYPEOF_CURL_OFF_T __int64
163# define CURL_FORMAT_CURL_OFF_T "lld"
164# define CURL_FORMAT_CURL_OFF_TU "llu"
165# define CURL_SUFFIX_CURL_OFF_T LL
166# define CURL_SUFFIX_CURL_OFF_TU ULL
167# endif
168# define CURL_TYPEOF_CURL_SOCKLEN_T unsigned int
169
170#elif defined(__MWERKS__)
171# define CURL_TYPEOF_CURL_OFF_T long long
172# define CURL_FORMAT_CURL_OFF_T "lld"
173# define CURL_FORMAT_CURL_OFF_TU "llu"
174# define CURL_SUFFIX_CURL_OFF_T LL
175# define CURL_SUFFIX_CURL_OFF_TU ULL
176# define CURL_TYPEOF_CURL_SOCKLEN_T int
177
178#elif defined(_WIN32_WCE)
179# define CURL_TYPEOF_CURL_OFF_T __int64
180# define CURL_FORMAT_CURL_OFF_T "I64d"
181# define CURL_FORMAT_CURL_OFF_TU "I64u"
182# define CURL_SUFFIX_CURL_OFF_T i64
183# define CURL_SUFFIX_CURL_OFF_TU ui64
184# define CURL_TYPEOF_CURL_SOCKLEN_T int
185
186#elif defined(__MINGW32__)
187# define CURL_TYPEOF_CURL_OFF_T long long
188# define CURL_FORMAT_CURL_OFF_T "I64d"
189# define CURL_FORMAT_CURL_OFF_TU "I64u"
190# define CURL_SUFFIX_CURL_OFF_T LL
191# define CURL_SUFFIX_CURL_OFF_TU ULL
192# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
193# define CURL_PULL_SYS_TYPES_H 1
194# define CURL_PULL_WS2TCPIP_H 1
195
196#elif defined(__VMS)
197# if defined(__VAX)
198# define CURL_TYPEOF_CURL_OFF_T long
199# define CURL_FORMAT_CURL_OFF_T "ld"
200# define CURL_FORMAT_CURL_OFF_TU "lu"
201# define CURL_SUFFIX_CURL_OFF_T L
202# define CURL_SUFFIX_CURL_OFF_TU UL
203# else
204# define CURL_TYPEOF_CURL_OFF_T long long
205# define CURL_FORMAT_CURL_OFF_T "lld"
206# define CURL_FORMAT_CURL_OFF_TU "llu"
207# define CURL_SUFFIX_CURL_OFF_T LL
208# define CURL_SUFFIX_CURL_OFF_TU ULL
209# endif
210# define CURL_TYPEOF_CURL_SOCKLEN_T unsigned int
211
212#elif defined(__OS400__)
213# if defined(__ILEC400__)
214# define CURL_TYPEOF_CURL_OFF_T long long
215# define CURL_FORMAT_CURL_OFF_T "lld"
216# define CURL_FORMAT_CURL_OFF_TU "llu"
217# define CURL_SUFFIX_CURL_OFF_T LL
218# define CURL_SUFFIX_CURL_OFF_TU ULL
219# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
220# define CURL_PULL_SYS_TYPES_H 1
221# define CURL_PULL_SYS_SOCKET_H 1
222# endif
223
224#elif defined(__MVS__)
225# if defined(__IBMC__) || defined(__IBMCPP__)
226# if defined(_ILP32)
227# elif defined(_LP64)
228# endif
229# if defined(_LONG_LONG)
230# define CURL_TYPEOF_CURL_OFF_T long long
231# define CURL_FORMAT_CURL_OFF_T "lld"
232# define CURL_FORMAT_CURL_OFF_TU "llu"
233# define CURL_SUFFIX_CURL_OFF_T LL
234# define CURL_SUFFIX_CURL_OFF_TU ULL
235# elif defined(_LP64)
236# define CURL_TYPEOF_CURL_OFF_T long
237# define CURL_FORMAT_CURL_OFF_T "ld"
238# define CURL_FORMAT_CURL_OFF_TU "lu"
239# define CURL_SUFFIX_CURL_OFF_T L
240# define CURL_SUFFIX_CURL_OFF_TU UL
241# else
242# define CURL_TYPEOF_CURL_OFF_T long
243# define CURL_FORMAT_CURL_OFF_T "ld"
244# define CURL_FORMAT_CURL_OFF_TU "lu"
245# define CURL_SUFFIX_CURL_OFF_T L
246# define CURL_SUFFIX_CURL_OFF_TU UL
247# endif
248# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
249# define CURL_PULL_SYS_TYPES_H 1
250# define CURL_PULL_SYS_SOCKET_H 1
251# endif
252
253#elif defined(__370__)
254# if defined(__IBMC__) || defined(__IBMCPP__)
255# if defined(_ILP32)
256# elif defined(_LP64)
257# endif
258# if defined(_LONG_LONG)
259# define CURL_TYPEOF_CURL_OFF_T long long
260# define CURL_FORMAT_CURL_OFF_T "lld"
261# define CURL_FORMAT_CURL_OFF_TU "llu"
262# define CURL_SUFFIX_CURL_OFF_T LL
263# define CURL_SUFFIX_CURL_OFF_TU ULL
264# elif defined(_LP64)
265# define CURL_TYPEOF_CURL_OFF_T long
266# define CURL_FORMAT_CURL_OFF_T "ld"
267# define CURL_FORMAT_CURL_OFF_TU "lu"
268# define CURL_SUFFIX_CURL_OFF_T L
269# define CURL_SUFFIX_CURL_OFF_TU UL
270# else
271# define CURL_TYPEOF_CURL_OFF_T long
272# define CURL_FORMAT_CURL_OFF_T "ld"
273# define CURL_FORMAT_CURL_OFF_TU "lu"
274# define CURL_SUFFIX_CURL_OFF_T L
275# define CURL_SUFFIX_CURL_OFF_TU UL
276# endif
277# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
278# define CURL_PULL_SYS_TYPES_H 1
279# define CURL_PULL_SYS_SOCKET_H 1
280# endif
281
282#elif defined(TPF)
283# define CURL_TYPEOF_CURL_OFF_T long
284# define CURL_FORMAT_CURL_OFF_T "ld"
285# define CURL_FORMAT_CURL_OFF_TU "lu"
286# define CURL_SUFFIX_CURL_OFF_T L
287# define CURL_SUFFIX_CURL_OFF_TU UL
288# define CURL_TYPEOF_CURL_SOCKLEN_T int
289
290#elif defined(__TINYC__) /* also known as tcc */
291
292# define CURL_TYPEOF_CURL_OFF_T long long
293# define CURL_FORMAT_CURL_OFF_T "lld"
294# define CURL_FORMAT_CURL_OFF_TU "llu"
295# define CURL_SUFFIX_CURL_OFF_T LL
296# define CURL_SUFFIX_CURL_OFF_TU ULL
297# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
298# define CURL_PULL_SYS_TYPES_H 1
299# define CURL_PULL_SYS_SOCKET_H 1
300
301#elif defined(__SUNPRO_C) /* Oracle Solaris Studio */
302# if !defined(__LP64) && (defined(__ILP32) || \
303 defined(__i386) || defined(__sparcv8))
304# define CURL_TYPEOF_CURL_OFF_T long long
305# define CURL_FORMAT_CURL_OFF_T "lld"
306# define CURL_FORMAT_CURL_OFF_TU "llu"
307# define CURL_SUFFIX_CURL_OFF_T LL
308# define CURL_SUFFIX_CURL_OFF_TU ULL
309# elif defined(__LP64) || \
310 defined(__amd64) || defined(__sparcv9)
311# define CURL_TYPEOF_CURL_OFF_T long
312# define CURL_FORMAT_CURL_OFF_T "ld"
313# define CURL_FORMAT_CURL_OFF_TU "lu"
314# define CURL_SUFFIX_CURL_OFF_T L
315# define CURL_SUFFIX_CURL_OFF_TU UL
316# endif
317# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
318# define CURL_PULL_SYS_TYPES_H 1
319# define CURL_PULL_SYS_SOCKET_H 1
320
321/* ===================================== */
322/* KEEP MSVC THE PENULTIMATE ENTRY */
323/* ===================================== */
324
325#elif defined(_MSC_VER)
326# if (_MSC_VER >= 900) && (_INTEGRAL_MAX_BITS >= 64)
327# define CURL_TYPEOF_CURL_OFF_T __int64
328# define CURL_FORMAT_CURL_OFF_T "I64d"
329# define CURL_FORMAT_CURL_OFF_TU "I64u"
330# define CURL_SUFFIX_CURL_OFF_T i64
331# define CURL_SUFFIX_CURL_OFF_TU ui64
332# else
333# define CURL_TYPEOF_CURL_OFF_T long
334# define CURL_FORMAT_CURL_OFF_T "ld"
335# define CURL_FORMAT_CURL_OFF_TU "lu"
336# define CURL_SUFFIX_CURL_OFF_T L
337# define CURL_SUFFIX_CURL_OFF_TU UL
338# endif
339# define CURL_TYPEOF_CURL_SOCKLEN_T int
340
341/* ===================================== */
342/* KEEP GENERIC GCC THE LAST ENTRY */
343/* ===================================== */
344
345#elif defined(__GNUC__)
346# if !defined(__LP64__) && \
347 (defined(__ILP32__) || defined(__i386__) || defined(__hppa__) || \
348 defined(__ppc__) || defined(__powerpc__) || defined(__arm__) || \
349 defined(__sparc__) || defined(__mips__) || defined(__sh__) || \
350 defined(__XTENSA__) || \
351 (defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ == 4) || \
352 (defined(__LONG_MAX__) && __LONG_MAX__ == 2147483647L))
353# define CURL_TYPEOF_CURL_OFF_T long long
354# define CURL_FORMAT_CURL_OFF_T "lld"
355# define CURL_FORMAT_CURL_OFF_TU "llu"
356# define CURL_SUFFIX_CURL_OFF_T LL
357# define CURL_SUFFIX_CURL_OFF_TU ULL
358# elif defined(__LP64__) || \
359 defined(__x86_64__) || defined(__ppc64__) || defined(__sparc64__) || \
360 (defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ == 8) || \
361 (defined(__LONG_MAX__) && __LONG_MAX__ == 9223372036854775807L)
362# define CURL_TYPEOF_CURL_OFF_T long
363# define CURL_FORMAT_CURL_OFF_T "ld"
364# define CURL_FORMAT_CURL_OFF_TU "lu"
365# define CURL_SUFFIX_CURL_OFF_T L
366# define CURL_SUFFIX_CURL_OFF_TU UL
367# endif
368# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
369# define CURL_PULL_SYS_TYPES_H 1
370# define CURL_PULL_SYS_SOCKET_H 1
371
372#else
373/* generic "safe guess" on old 32 bit style */
374# define CURL_TYPEOF_CURL_OFF_T long
375# define CURL_FORMAT_CURL_OFF_T "ld"
376# define CURL_FORMAT_CURL_OFF_TU "lu"
377# define CURL_SUFFIX_CURL_OFF_T L
378# define CURL_SUFFIX_CURL_OFF_TU UL
379# define CURL_TYPEOF_CURL_SOCKLEN_T int
380#endif
381
382#ifdef _AIX
383/* AIX needs <sys/poll.h> */
384#define CURL_PULL_SYS_POLL_H
385#endif
386
387
388/* CURL_PULL_WS2TCPIP_H is defined above when inclusion of header file */
389/* ws2tcpip.h is required here to properly make type definitions below. */
390#ifdef CURL_PULL_WS2TCPIP_H
391# include <winsock2.h>
392# include <windows.h>
393# include <ws2tcpip.h>
394#endif
395
396/* CURL_PULL_SYS_TYPES_H is defined above when inclusion of header file */
397/* sys/types.h is required here to properly make type definitions below. */
398#ifdef CURL_PULL_SYS_TYPES_H
399# include <sys/types.h>
400#endif
401
402/* CURL_PULL_SYS_SOCKET_H is defined above when inclusion of header file */
403/* sys/socket.h is required here to properly make type definitions below. */
404#ifdef CURL_PULL_SYS_SOCKET_H
405# include <sys/socket.h>
406#endif
407
408/* CURL_PULL_SYS_POLL_H is defined above when inclusion of header file */
409/* sys/poll.h is required here to properly make type definitions below. */
410#ifdef CURL_PULL_SYS_POLL_H
411# include <sys/poll.h>
412#endif
413
414/* Data type definition of curl_socklen_t. */
415#ifdef CURL_TYPEOF_CURL_SOCKLEN_T
416 typedef CURL_TYPEOF_CURL_SOCKLEN_T curl_socklen_t;
417#endif
418
419/* Data type definition of curl_off_t. */
420
421#ifdef CURL_TYPEOF_CURL_OFF_T
422 typedef CURL_TYPEOF_CURL_OFF_T curl_off_t;
423#endif
424
425/*
426 * CURL_ISOCPP and CURL_OFF_T_C definitions are done here in order to allow
427 * these to be visible and exported by the external libcurl interface API,
428 * while also making them visible to the library internals, simply including
429 * curl_setup.h, without actually needing to include curl.h internally.
430 * If some day this section would grow big enough, all this should be moved
431 * to its own header file.
432 */
433
434/*
435 * Figure out if we can use the ## preprocessor operator, which is supported
436 * by ISO/ANSI C and C++. Some compilers support it without setting __STDC__
437 * or __cplusplus so we need to carefully check for them too.
438 */
439
440#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus) || \
441 defined(__HP_aCC) || defined(__BORLANDC__) || defined(__LCC__) || \
442 defined(__POCC__) || defined(__SALFORDC__) || defined(__HIGHC__) || \
443 defined(__ILEC400__)
444 /* This compiler is believed to have an ISO compatible preprocessor */
445#define CURL_ISOCPP
446#else
447 /* This compiler is believed NOT to have an ISO compatible preprocessor */
448#undef CURL_ISOCPP
449#endif
450
451/*
452 * Macros for minimum-width signed and unsigned curl_off_t integer constants.
453 */
454
455#if defined(__BORLANDC__) && (__BORLANDC__ == 0x0551)
456# define __CURL_OFF_T_C_HLPR2(x) x
457# define __CURL_OFF_T_C_HLPR1(x) __CURL_OFF_T_C_HLPR2(x)
458# define CURL_OFF_T_C(Val) __CURL_OFF_T_C_HLPR1(Val) ## \
459 __CURL_OFF_T_C_HLPR1(CURL_SUFFIX_CURL_OFF_T)
460# define CURL_OFF_TU_C(Val) __CURL_OFF_T_C_HLPR1(Val) ## \
461 __CURL_OFF_T_C_HLPR1(CURL_SUFFIX_CURL_OFF_TU)
462#else
463# ifdef CURL_ISOCPP
464# define __CURL_OFF_T_C_HLPR2(Val,Suffix) Val ## Suffix
465# else
466# define __CURL_OFF_T_C_HLPR2(Val,Suffix) Val/**/Suffix
467# endif
468# define __CURL_OFF_T_C_HLPR1(Val,Suffix) __CURL_OFF_T_C_HLPR2(Val,Suffix)
469# define CURL_OFF_T_C(Val) __CURL_OFF_T_C_HLPR1(Val,CURL_SUFFIX_CURL_OFF_T)
470# define CURL_OFF_TU_C(Val) __CURL_OFF_T_C_HLPR1(Val,CURL_SUFFIX_CURL_OFF_TU)
471#endif
472
473#endif /* __CURL_SYSTEM_H */
474