1/*
2 * Copyright 2018 Google, Inc.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met: redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer;
8 * redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution;
11 * neither the name of the copyright holders nor the names of its
12 * contributors may be used to endorse or promote products derived from
13 * this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *
27 * Authors: Gabe Black
28 */
29
30#ifndef __SYSTEMC_EXT_UTIL_FUNCTIONS_HH__
31#define __SYSTEMC_EXT_UTIL_FUNCTIONS_HH__
32
33#include <string>
34
35namespace sc_dt
36{
37
38template <class T>
39const T
40sc_abs(const T &a)
41{
42    // return ( a >= 0 ? a : -a );
43    // the code below is functionaly the same as the code above; the
44    // difference is that the code below works for all arithmetic
45    // SystemC datatypes.
46    T z(a);
47    z = 0;
48    if (a >= z) {
49        return a;
50    } else {
51        T c(a);
52        c = -a;
53        return c;
54    }
55}
56
57template <class T>
58const T sc_max(const T &a, const T &b) { return ((a >= b) ? a : b); }
59
60template <class T>
61const T sc_min(const T &a, const T &b) { return ((a <= b) ? a : b); }
62
63} // namespace sc_dt
64
65namespace sc_core
66{
67
68#define IEEE_1666_SYSTEMC 201101L
69
70#define SC_VERSION_MAJOR 0
71#define SC_VERSION_MINOR 1
72#define SC_VERSION_PATCH 0
73#define SC_VERSION_ORIGINATOR "gem5"
74#define SC_VERSION_RELEASE_DATE "NA"
75#define SC_VERSION_PRERELEASE "beta"
76#define SC_IS_PRERELEASE true
77#define SC_VERSION "0.1.0_beta-gem5"
78#define SC_COPYRIGHT "Copyright 2018 Google, Inc."
79
80extern const unsigned int sc_version_major;
81extern const unsigned int sc_version_minor;
82extern const unsigned int sc_version_patch;
83extern const std::string sc_version_originator;
84extern const std::string sc_version_release_date;
85extern const std::string sc_version_prerelease;
86extern const bool sc_is_prerelease;
87extern const std::string sc_version_string;
88extern const std::string sc_copyright_string;
89
90static inline const char *
91sc_release()
92{
93    return sc_version_string.c_str();
94}
95static inline const char *
96sc_copyright()
97{
98    return sc_copyright_string.c_str();
99}
100const char *sc_version();
101
102} // namespace sc_core
103
104#endif  //__SYSTEMC_EXT_UTIL_FUNCTIONS_HH__
105