]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - compat/types.h
SourceFormat Enforcement
[thirdparty/squid.git] / compat / types.h
index 20e265a1d5f6af95decfb774951405325edea3c8..8149f6211b71a4190d21695aa306bb93ca5184c9 100644 (file)
@@ -1,48 +1,15 @@
 /*
- * * * * * * * * Legal stuff * * * * * * *
- *
- * (C) 2000 Francesco Chemolli <kinkie@kame.usr.dsi.unimi.it>
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- * SQUID Web Proxy Cache          http://www.squid-cache.org/
- * ----------------------------------------------------------
- *
- *  Squid is the result of efforts by numerous individuals from
- *  the Internet community; see the CONTRIBUTORS file for full
- *  details.   Many organizations have provided support for Squid's
- *  development; see the SPONSORS file for full details.  Squid is
- *  Copyrighted (C) 2001 by the Regents of the University of
- *  California; see the COPYRIGHT file for full details.  Squid
- *  incorporates software developed and/or copyrighted by other
- *  sources; see the CREDITS file for full details.
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
- *
- * * * * * * * * Declaration of intents * * * * * * *
+ * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
  *
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
+ */
+
+#ifndef SQUID_TYPES_H
+#define SQUID_TYPES_H
+
+/*
  * Here are defined several known-width types, obtained via autoconf
  * from system locations or various attempts. This is just a convenience
  * header to include which takes care of proper preprocessor stuff
@@ -51,9 +18,6 @@
  * not include directly.
  */
 
-#ifndef SQUID_TYPES_H
-#define SQUID_TYPES_H
-
 /* This should be in synch with what we have in acinclude.m4 */
 #if HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #include <netinet/in_systm.h>
 #endif
 
+#if __cplusplus && HAVE_TR1_RANDOM
+#if !HAVE_STD_UNIFORM_INT_DISTRIBUTION && !HAVE_STD_UNIFORM_REAL_DISTRIBUTION
+#include <tr1/random>
+#endif
+#endif
+
 /******************************************************/
 /* 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
@@ -152,11 +163,23 @@ typedef long mtyp_t;
 #endif
 
 #ifndef NULL
-#if defined(__cplusplus) && HAVE_NULLPTR
-#define NULL nullptr
-#else
 #define NULL 0
 #endif
+
+/***********************************************************/
+/* uniform_int_distribution backward compatibility wrapper */
+/***********************************************************/
+#if HAVE_STD_UNIFORM_INT_DISTRIBUTION
+#define xuniform_int_distribution std::uniform_int_distribution
+#else
+#define xuniform_int_distribution std::tr1::uniform_int
+#endif
+
+#if HAVE_STD_UNIFORM_REAL_DISTRIBUTION
+#define xuniform_real_distribution std::uniform_real_distribution
+#else
+#define xuniform_real_distribution std::tr1::uniform_real
 #endif
 
 #endif /* SQUID_TYPES_H */
+