]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Portability: Add hacks to define C++11 explicit N-bit type limits
authorAmos Jeffries <squid3@treenet.co.nz>
Wed, 22 Apr 2015 13:32:56 +0000 (06:32 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Wed, 22 Apr 2015 13:32:56 +0000 (06:32 -0700)
Add cstdint and stdint.h to libcompat headers and ensure that type limits
used by Squid are always available. Mostly this involves shuffling
existing hacks into the compat headers but the UINT32_* limits are new.

compat/types.h
helpers/ntlm_auth/fake/ntlm_fake_auth.cc
src/String.cci
src/base/Lock.h
src/parser/Tokenizer.cc

index 3833bfa285fd255ad29cea880a4e55e078dafd61..50211aa31091e2d4c732cf1b3fa0527687482e61 100644 (file)
 /* Typedefs for missing entries on a system           */
 /******************************************************/
 
+/*
+ * Ensure that standard type limits are defined for use
+ */
+#if __cplusplus >= 201103L
+#include <cstdint>
+#elif HAVE_STDINT_H
+#include <stdint.h>
+#endif
+
+/* explicit bit sizes */
+#if !defined(UINT32_MIN)
+#define UINT32_MIN    0x00000000L
+#endif
+#if !defined(UINT32_MAX)
+#define UINT32_MAX    0xFFFFFFFFL
+#endif
+
+#if !defined(INT_MAX)
+#define INT_MAX    0x7FFFFFFFL // hack but a safe bet (32-bit signed integer)
+#endif
+
+#if !defined(INT64_MIN)
+/* Native 64 bit system without strtoll() */
+#if defined(LONG_MIN) && (SIZEOF_LONG == 8)
+#define INT64_MIN    LONG_MIN
+#else
+/* 32 bit system */
+#define INT64_MIN    (-9223372036854775807LL-1LL)
+#endif
+#endif
+
+#if !defined(INT64_MAX)
+/* Native 64 bit system without strtoll() */
+#if defined(LONG_MAX) && (SIZEOF_LONG == 8)
+#define INT64_MAX    LONG_MAX
+#else
+/* 32 bit system */
+#define INT64_MAX    9223372036854775807LL
+#endif
+#endif
+
 /*
  * ISO C99 Standard printf() macros for 64 bit integers
  * On some 64 bit platform, HP Tru64 is one, for printf must be used
index 38b0f7729dc29405928c75814638c907906ad993..026484fc21433fdf27734e78c5a178d04f7780dc 100644 (file)
 #if HAVE_GETOPT_H
 #include <getopt.h>
 #endif
-#if HAVE_STDINT_H
-#include <stdint.h>
-#endif
-#if HAVE_INTTYPES_H
-#include <inttypes.h>
-#endif
 
 /* A couple of harmless helper macros */
 #define SEND(X) {debug("sending '%s' to squid\n",X); printf(X "\n");}
index fa3fa78aefba434906f553fb239bb9d3c7d3a764..ddc65952188b4dbc51b3673f30ed057e7dea4bce 100644 (file)
 
 #include <cstring>
 
-#if HAVE_STDINT_H
-#include <stdint.h>
-#else /* HAVE_STDINT_H */
-#ifndef INT_MAX
-#define INT_MAX 1<<31 //hack but a safe bet
-#endif /* INT_MAX */
-#endif /* HAVE_STDINT_H */
-
 String::String() : size_(0), len_(0), buf_(NULL)
 {
 #if DEBUGSTRINGS
index f081cf5cf4e078c44256c91262beeb2557bf5d55..8a995e59ca5487067670fc1ab4d7eadd707395f6 100644 (file)
@@ -9,12 +9,6 @@
 #ifndef SQUID_SRC_BASE_LOCK_H
 #define SQUID_SRC_BASE_LOCK_H
 
-#if __cplusplus >= 201103L
-#include <cstdint>
-#else
-#include <stdint.h>
-#endif
-
 /**
  * This class provides a tracking counter and presents
  * lock(), unlock() and LockCount() accessors.
index 49fac70f7923a766c90167517f774da2c897e94f..68fcb7cafc9555ae51210aadc8ac3eaffad0528c 100644 (file)
 #if HAVE_CTYPE_H
 #include <ctype.h>
 #endif
-#if HAVE_STDINT_H
-#include <stdint.h>
-#endif
-#ifndef INT64_MIN
-/* Native 64 bit system without strtoll() */
-#if defined(LONG_MIN) && (SIZEOF_LONG == 8)
-#define INT64_MIN LONG_MIN
-#else
-/* 32 bit system */
-#define INT64_MIN       (-9223372036854775807LL-1LL)
-#endif
-#endif
-
-#ifndef INT64_MAX
-/* Native 64 bit system without strtoll() */
-#if defined(LONG_MAX) && (SIZEOF_LONG == 8)
-#define INT64_MAX LONG_MAX
-#else
-/* 32 bit system */
-#define INT64_MAX       9223372036854775807LL
-#endif
-#endif
 
 /// convenience method: consumes up to n bytes, counts, and returns them
 SBuf