]> git.ipfire.org Git - thirdparty/squid.git/blob - compat/types.h
Merged from trunk
[thirdparty/squid.git] / compat / types.h
1 #ifndef SQUID_CONFIG_H
2 #include "config.h"
3 #endif
4
5 /*
6 * * * * * * * * Legal stuff * * * * * * *
7 *
8 * (C) 2000 Francesco Chemolli <kinkie@kame.usr.dsi.unimi.it>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * SQUID Web Proxy Cache http://www.squid-cache.org/
23 * ----------------------------------------------------------
24 *
25 * Squid is the result of efforts by numerous individuals from
26 * the Internet community; see the CONTRIBUTORS file for full
27 * details. Many organizations have provided support for Squid's
28 * development; see the SPONSORS file for full details. Squid is
29 * Copyrighted (C) 2001 by the Regents of the University of
30 * California; see the COPYRIGHT file for full details. Squid
31 * incorporates software developed and/or copyrighted by other
32 * sources; see the CREDITS file for full details.
33 *
34 * This program is free software; you can redistribute it and/or modify
35 * it under the terms of the GNU General Public License as published by
36 * the Free Software Foundation; either version 2 of the License, or
37 * (at your option) any later version.
38 *
39 * This program is distributed in the hope that it will be useful,
40 * but WITHOUT ANY WARRANTY; without even the implied warranty of
41 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
42 * GNU General Public License for more details.
43 *
44 * You should have received a copy of the GNU General Public License
45 * along with this program; if not, write to the Free Software
46 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
47 *
48 * * * * * * * * Declaration of intents * * * * * * *
49 *
50 * Here are defined several known-width types, obtained via autoconf
51 * from system locations or various attempts. This is just a convenience
52 * header to include which takes care of proper preprocessor stuff
53 *
54 * This file is only intended to be included via compat/compat.h, do
55 * not include directly.
56 */
57
58 #ifndef SQUID_TYPES_H
59 #define SQUID_TYPES_H
60
61 /* This should be in synch with what we have in acinclude.m4 */
62 #if HAVE_SYS_TYPES_H
63 #include <sys/types.h>
64 #endif
65 #if HAVE_LINUX_TYPES_H
66 #include <linux/types.h>
67 #endif
68 #if HAVE_STDLIB_H
69 #include <stdlib.h>
70 #endif
71 #if HAVE_STDDEF_H
72 #include <stddef.h>
73 #endif
74 #if HAVE_INTTYPES_H
75 #include <inttypes.h>
76 #endif
77 #if HAVE_SYS_BITYPES_H
78 #include <sys/bitypes.h>
79 #endif
80 #if HAVE_SYS_SELECT_H
81 #include <sys/select.h>
82 #endif
83 #if HAVE_NETINET_IN_SYSTM_H
84 /* Several OS require types declared by in_systm.h without including it themselves. */
85 #include <netinet/in_systm.h>
86 #endif
87
88
89 /******************************************************/
90 /* Typedefs for missing entries on a system */
91 /******************************************************/
92
93
94 /*
95 * ISO C99 Standard printf() macros for 64 bit integers
96 * On some 64 bit platform, HP Tru64 is one, for printf must be used
97 * "%lx" instead of "%llx"
98 */
99 #ifndef PRId64
100 #ifdef _SQUID_MSWIN_ /* Windows native port using MSVCRT */
101 #define PRId64 "I64d"
102 #elif SIZEOF_INT64_T > SIZEOF_LONG
103 #define PRId64 "lld"
104 #else
105 #define PRId64 "ld"
106 #endif
107 #endif
108
109 #ifndef PRIu64
110 #ifdef _SQUID_MSWIN_ /* Windows native port using MSVCRT */
111 #define PRIu64 "I64u"
112 #elif SIZEOF_INT64_T > SIZEOF_LONG
113 #define PRIu64 "llu"
114 #else
115 #define PRIu64 "lu"
116 #endif
117 #endif
118
119 /* int64_t */
120 #ifndef HAVE_INT64_T
121 #if HAVE___INT64
122 typedef __int64 int64_t;
123 #elif HAVE_LONG && SIZEOF_LONG == 8
124 typedef long int64_t;
125 #elif HAVE_LONG_LONG && SIZEOF_LONG_LONG == 8
126 typedef long long int64_t;
127 #else
128 #error NO 64 bit signed type available
129 #endif
130 #endif
131
132 /* uint64_t */
133 #if !HAVE_UINT64_T
134 #if HAVE_U_INT64_T
135 typedef u_int64_t uint64_t;
136 #define HAVE_UINT64_T 1
137 #elif HAVE_INT64_T
138 typedef unsigned int64_t uint64_t;
139 #define HAVE_UINT64_T 1
140 #endif /* HAVE_U_INT64_T */
141 #endif /* HAVE_UINT64_T */
142
143 /* int32_t */
144 #ifndef HAVE_INT32_T
145 #if HAVE_INT && SIZEOF_INT == 4
146 typedef int int32_t;
147 #elif HAVE_LONG && SIZEOF_LONG == 4
148 typedef long int32_t;
149 #else
150 #error NO 32 bit signed type available
151 #endif
152 #endif
153
154 /* uint32_t */
155 #if !HAVE_UINT32_T
156 #if HAVE_U_INT32_T
157 typedef u_int32_t uint32_t;
158 #define HAVE_UINT32_T 1
159 #elif HAVE_INT32_T
160 typedef unsigned int32_t uint32_t;
161 #define HAVE_UINT32_T 1
162 #endif /* HAVE_U_INT32_T */
163 #endif /* HAVE_UINT32_T */
164
165 /* int16_t */
166 #ifndef HAVE_INT16_T
167 #if HAVE_SHORT && SIZEOF_SHORT == 2
168 typedef short int16_t;
169 #elif HAVE_INT && SIZEOF_INT == 2
170 typedef int int16_t;
171 #else
172 #error NO 16 bit signed type available
173 #endif
174 #endif
175
176 /* uint16_t */
177 #if !HAVE_UINT16_T
178 #if HAVE_U_INT16_T
179 typedef u_int16_t uint16_t;
180 #define HAVE_UINT16_T 1
181 #elif HAVE_INT16_T
182 typedef unsigned int16_t uint16_t;
183 #define HAVE_UINT16_T 1
184 #endif /* HAVE_U_INT16_T */
185 #endif /* HAVE_UINT16_T */
186
187 /* int8_t */
188 #ifndef HAVE_INT8_T
189 #if HAVE_CHAR && SIZEOF_CHAR == 1
190 typedef char int8_t;
191 #else
192 #error NO 8 bit signed type available
193 #endif
194 #endif
195
196 /* uint8_t */
197 #if !HAVE_UINT8_T
198 #if HAVE_U_INT8_T
199 typedef u_int8_t uint8_t;
200 #define HAVE_UINT8_T 1
201 #elif HAVE_INT8_T
202 typedef unsigned int8_t uint8_t;
203 #define HAVE_UINT8_T 1
204 #endif /* HAVE_U_INT8_T */
205 #endif /* HAVE_UINT8_T */
206
207 #ifndef HAVE_PID_T
208 #if defined(_MSC_VER) /* Microsoft C Compiler ONLY */
209 typedef long pid_t;
210 #else
211 typedef int pid_t;
212 #endif
213 #endif
214
215 #ifndef HAVE_SIZE_T
216 typedef unsigned int size_t;
217 #endif
218
219 #ifndef HAVE_SSIZE_T
220 typedef int ssize_t;
221 #endif
222
223 #ifndef HAVE_OFF_T
224 #if defined(_MSC_VER) /* Microsoft C Compiler ONLY */
225 #if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64
226 typedef int64_t off_t;
227 #else
228 typedef long off_t;
229 #endif
230 #else
231 typedef int off_t;
232 #endif
233 #endif
234
235 #ifndef HAVE_MODE_T
236 typedef unsigned short mode_t;
237 #endif
238
239 #ifndef HAVE_FD_MASK
240 typedef unsigned long fd_mask;
241 #endif
242
243 #ifndef HAVE_SOCKLEN_T
244 typedef int socklen_t;
245 #endif
246
247 #ifndef HAVE_MTYP_T
248 typedef long mtyp_t;
249 #endif
250
251 #endif /* SQUID_TYPES_H */