]> git.ipfire.org Git - thirdparty/squid.git/blob - compat/types.h
Merged from trunk
[thirdparty/squid.git] / compat / types.h
1 /*
2 * Copyright (C) 1996-2014 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9 #ifndef SQUID_TYPES_H
10 #define SQUID_TYPES_H
11
12 /*
13 * Here are defined several known-width types, obtained via autoconf
14 * from system locations or various attempts. This is just a convenience
15 * header to include which takes care of proper preprocessor stuff
16 *
17 * This file is only intended to be included via compat/compat.h, do
18 * not include directly.
19 */
20
21 /* This should be in synch with what we have in acinclude.m4 */
22 #if HAVE_SYS_TYPES_H
23 #include <sys/types.h>
24 #endif
25 #if HAVE_LINUX_TYPES_H
26 #include <linux/types.h>
27 #endif
28 #if HAVE_STDLIB_H
29 #include <stdlib.h>
30 #endif
31 #if HAVE_STDDEF_H
32 #include <stddef.h>
33 #endif
34 #if HAVE_INTTYPES_H
35 #include <inttypes.h>
36 #endif
37 #if HAVE_SYS_BITYPES_H
38 #include <sys/bitypes.h>
39 #endif
40 #if HAVE_SYS_SELECT_H
41 #include <sys/select.h>
42 #endif
43 #if HAVE_NETINET_IN_SYSTM_H
44 /* Several OS require types declared by in_systm.h without including it themselves. */
45 #include <netinet/in_systm.h>
46 #endif
47
48 /******************************************************/
49 /* Typedefs for missing entries on a system */
50 /******************************************************/
51
52 /*
53 * ISO C99 Standard printf() macros for 64 bit integers
54 * On some 64 bit platform, HP Tru64 is one, for printf must be used
55 * "%lx" instead of "%llx"
56 */
57 #ifndef PRId64
58 #if _SQUID_WINDOWS_
59 #define PRId64 "I64d"
60 #elif SIZEOF_INT64_T > SIZEOF_LONG
61 #define PRId64 "lld"
62 #else
63 #define PRId64 "ld"
64 #endif
65 #endif
66
67 #ifndef PRIu64
68 #if _SQUID_WINDOWS_
69 #define PRIu64 "I64u"
70 #elif SIZEOF_INT64_T > SIZEOF_LONG
71 #define PRIu64 "llu"
72 #else
73 #define PRIu64 "lu"
74 #endif
75 #endif
76
77 #ifndef PRIX64
78 #if _SQUID_WINDOWS_
79 #define PRIX64 "I64X"
80 #elif SIZEOF_INT64_T > SIZEOF_LONG
81 #define PRIX64 "llX"
82 #else
83 #define PRIX64 "lX"
84 #endif
85 #endif
86
87 #ifndef PRIuSIZE
88 // NP: configure checks for support of %zu and defines where possible
89 #if SIZEOF_SIZE_T == 4 && _SQUID_MINGW_
90 #define PRIuSIZE "I32u"
91 #elif SIZEOF_SIZE_T == 4
92 #define PRIuSIZE "u"
93 #elif SIZEOF_SIZE_T == 8 && _SQUID_MINGW_
94 #define PRIuSIZE "I64u"
95 #elif SIZEOF_SIZE_T == 8
96 #define PRIuSIZE "lu"
97 #else
98 #error size_t is not 32-bit or 64-bit
99 #endif
100 #endif /* PRIuSIZE */
101
102 #ifndef HAVE_MODE_T
103 typedef unsigned short mode_t;
104 #endif
105
106 #ifndef HAVE_FD_MASK
107 typedef unsigned long fd_mask;
108 #endif
109
110 #ifndef HAVE_SOCKLEN_T
111 typedef int socklen_t;
112 #endif
113
114 #ifndef HAVE_MTYP_T
115 typedef long mtyp_t;
116 #endif
117
118 #ifndef NULL
119 #if defined(__cplusplus) && HAVE_NULLPTR
120 #define NULL nullptr
121 #else
122 #define NULL 0
123 #endif
124 #endif
125
126 #endif /* SQUID_TYPES_H */
127