]>
git.ipfire.org Git - thirdparty/squid.git/blob - compat/types.h
2 * Copyright (C) 1996-2016 The Squid Software Foundation and contributors
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.
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
17 * This file is only intended to be included via compat/compat.h, do
18 * not include directly.
21 /* This should be in synch with what we have in acinclude.m4 */
23 #include <sys/types.h>
25 #if HAVE_LINUX_TYPES_H
26 #include <linux/types.h>
37 #if HAVE_SYS_BITYPES_H
38 #include <sys/bitypes.h>
41 #include <sys/select.h>
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>
48 #if __cplusplus && HAVE_TR1_RANDOM
49 #if !HAVE_STD_UNIFORM_INT_DISTRIBUTION && !HAVE_STD_UNIFORM_REAL_DISTRIBUTION
54 /******************************************************/
55 /* Typedefs for missing entries on a system */
56 /******************************************************/
59 * Ensure that standard type limits are defined for use
61 #if __cplusplus >= 201103L
67 /* explicit bit sizes */
68 #if !defined(UINT32_MIN)
69 #define UINT32_MIN 0x00000000L
71 #if !defined(UINT32_MAX)
72 #define UINT32_MAX 0xFFFFFFFFL
76 #define INT_MAX 0x7FFFFFFFL // hack but a safe bet (32-bit signed integer)
79 #if !defined(INT64_MIN)
80 /* Native 64 bit system without strtoll() */
81 #if defined(LONG_MIN) && (SIZEOF_LONG == 8)
82 #define INT64_MIN LONG_MIN
85 #define INT64_MIN (-9223372036854775807LL-1LL)
89 #if !defined(INT64_MAX)
90 /* Native 64 bit system without strtoll() */
91 #if defined(LONG_MAX) && (SIZEOF_LONG == 8)
92 #define INT64_MAX LONG_MAX
95 #define INT64_MAX 9223372036854775807LL
100 * ISO C99 Standard printf() macros for 64 bit integers
101 * On some 64 bit platform, HP Tru64 is one, for printf must be used
102 * "%lx" instead of "%llx"
106 #define PRId64 "I64d"
107 #elif SIZEOF_INT64_T > SIZEOF_LONG
116 #define PRIu64 "I64u"
117 #elif SIZEOF_INT64_T > SIZEOF_LONG
126 #define PRIX64 "I64X"
127 #elif SIZEOF_INT64_T > SIZEOF_LONG
135 // NP: configure checks for support of %zu and defines where possible
136 #if SIZEOF_SIZE_T == 4 && _SQUID_MINGW_
137 #define PRIuSIZE "I32u"
138 #elif SIZEOF_SIZE_T == 4
140 #elif SIZEOF_SIZE_T == 8 && _SQUID_MINGW_
141 #define PRIuSIZE "I64u"
142 #elif SIZEOF_SIZE_T == 8
143 #define PRIuSIZE "lu"
145 #error size_t is not 32-bit or 64-bit
147 #endif /* PRIuSIZE */
150 typedef unsigned short mode_t
;
154 typedef unsigned long fd_mask
;
157 #ifndef HAVE_SOCKLEN_T
158 typedef int socklen_t
;
169 /***********************************************************/
170 /* uniform_int_distribution backward compatibility wrapper */
171 /***********************************************************/
172 #if HAVE_STD_UNIFORM_INT_DISTRIBUTION
173 #define xuniform_int_distribution std::uniform_int_distribution
175 #define xuniform_int_distribution std::tr1::uniform_int
178 #if HAVE_STD_UNIFORM_REAL_DISTRIBUTION
179 #define xuniform_real_distribution std::uniform_real_distribution
181 #define xuniform_real_distribution std::tr1::uniform_real
184 #endif /* SQUID_TYPES_H */