summaryrefslogtreecommitdiff
path: root/src/systemc/ext/utils/endian.hh
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2018-05-18 02:12:34 -0700
committerGabe Black <gabeblack@google.com>2018-08-08 10:07:26 +0000
commit7adb1b250b712920ea5d685f146ad6df55346393 (patch)
treec431de9f29f2c7d1dc5a6e581cfcf7031bb26a49 /src/systemc/ext/utils/endian.hh
parent4b2e28307d0a1c2b31e403e8e394261eb363a7a9 (diff)
downloadgem5-7adb1b250b712920ea5d685f146ad6df55346393.tar.xz
systemc: Stub out all the standard utilility classes and functions.
Change-Id: I9e9724edb6281e0b0a6bae5546b0ede77d295c12 Reviewed-on: https://gem5-review.googlesource.com/10841 Reviewed-by: Gabe Black <gabeblack@google.com> Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src/systemc/ext/utils/endian.hh')
-rw-r--r--src/systemc/ext/utils/endian.hh79
1 files changed, 79 insertions, 0 deletions
diff --git a/src/systemc/ext/utils/endian.hh b/src/systemc/ext/utils/endian.hh
new file mode 100644
index 000000000..fcf47e824
--- /dev/null
+++ b/src/systemc/ext/utils/endian.hh
@@ -0,0 +1,79 @@
+// Copyright 2005 Caleb Epstein
+// Copyright 2006 John Maddock
+// Copyright 2010 Rene Rivera
+// Distributed under the Boost Software License, Version 1.0. (See accompany-
+// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+/*
+ * Copyright (c) 1997
+ * Silicon Graphics Computer Systems, Inc.
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation. Silicon Graphics makes no
+ * representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied warranty.
+ */
+
+/*
+ * Copyright notice reproduced from <sysc/packages/boost/detail/limits.hpp>,
+ * from which this code was originally taken.
+ *
+ * Modified by Caleb Epstein to use <endian.h> with GNU libc and to
+ * defined the SC_BOOST_ENDIAN macro.
+ */
+
+#ifndef __SYSTEMC_EXT_UTILS_ENDIAN_HH__
+#define __SYSTEMC_EXT_UTILS_ENDIAN_HH__
+
+// GNU libc offers the helpful header <endian.h> which defines
+// __BYTE_ORDER
+
+#if defined (__GLIBC__)
+# include <endian.h>
+# if (__BYTE_ORDER == __LITTLE_ENDIAN)
+# define SC_BOOST_LITTLE_ENDIAN
+# elif (__BYTE_ORDER == __BIG_ENDIAN)
+# define SC_BOOST_BIG_ENDIAN
+# elif (__BYTE_ORDER == __PDP_ENDIAN)
+# define SC_BOOST_PDP_ENDIAN
+# else
+# error Unknown machine endianness detected.
+# endif
+# define SC_BOOST_BYTE_ORDER __BYTE_ORDER
+#elif defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN) || \
+ defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__) || \
+ defined(_STLP_BIG_ENDIAN) && !defined(_STLP_LITTLE_ENDIAN)
+# define SC_BOOST_BIG_ENDIAN
+# define SC_BOOST_BYTE_ORDER 4321
+#elif defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN) || \
+ defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__) || \
+ defined(_STLP_LITTLE_ENDIAN) && !defined(_STLP_BIG_ENDIAN)
+# define SC_BOOST_LITTLE_ENDIAN
+# define SC_BOOST_BYTE_ORDER 1234
+#elif defined(__sparc) || defined(__sparc__) \
+ || defined(_POWER) || defined(__powerpc__) \
+ || defined(__ppc__) || defined(__ppc64__) \
+ || defined(__hpux) || defined(__hppa) \
+ || defined(_MIPSEB) || defined(_POWER) \
+ || defined(__s390__)
+# define SC_BOOST_BIG_ENDIAN
+# define SC_BOOST_BYTE_ORDER 4321
+#elif defined(__i386__) || defined(__alpha__) \
+ || defined(__ia64) || defined(__ia64__) \
+ || defined(_M_IX86) || defined(_M_IA64) \
+ || defined(_M_ALPHA) || defined(__amd64) \
+ || defined(__amd64__) || defined(_M_AMD64) \
+ || defined(__x86_64) || defined(__x86_64__) \
+ || defined(_M_X64) || defined(__bfin__)
+
+# define SC_BOOST_LITTLE_ENDIAN
+# define SC_BOOST_BYTE_ORDER 1234
+#else
+# error The file boost/detail/endian.hpp needs to be set up for your CPU type.
+#endif
+
+
+#endif // __SYSTEMC_EXT_UTILS_ENDIAN_HH__