ruby: Import ruby and slicc from GEMS
[gem5.git] / src / mem / slicc / slicc_global.hh
1
2 /*
3 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer;
10 * redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution;
13 * neither the name of the copyright holders nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30 #ifndef SLICC_GLOBAL_H
31 #define SLICC_GLOBAL_H
32
33 #include <assert.h> /* slicc needs to include this in order to use classes in
34 * ../common directory.
35 */
36
37 #include "std-includes.hh"
38 #include "Map.hh"
39
40 typedef unsigned char uint8;
41 typedef unsigned int uint32;
42 typedef unsigned long long uint64;
43
44 typedef signed char int8;
45 typedef int int32;
46 typedef long long int64;
47
48 typedef long long integer_t;
49 typedef unsigned long long uinteger_t;
50
51 const bool ASSERT_FLAG = true;
52
53 // when CHECK_RESOURCE_DEADLOCK is enabled, slicc will generate additional code
54 // that works in conjuction with the resources rank value specified in the protocol
55 // to detect invalid resource stalls as soon as they occur.
56 const bool CHECK_INVALID_RESOURCE_STALLS = false;
57
58 #undef assert
59 #define assert(EXPR) ASSERT(EXPR)
60
61 #define ASSERT(EXPR)\
62 {\
63 if (ASSERT_FLAG) {\
64 if (!(EXPR)) {\
65 cerr << "failed assertion '"\
66 << #EXPR << "' at fn "\
67 << __PRETTY_FUNCTION__ << " in "\
68 << __FILE__ << ":"\
69 << __LINE__ << endl;\
70 if(isatty(STDIN_FILENO)) {\
71 cerr << "At this point you might want to attach a debug to ";\
72 cerr << "the running and get to the" << endl;\
73 cerr << "crash site; otherwise press enter to continue" << endl;\
74 cerr << "PID: " << getpid();\
75 cerr << endl << flush; \
76 char c; \
77 cin.get(c); \
78 }\
79 abort();\
80 }\
81 }\
82 }
83
84 class State;
85 class Event;
86 class Symbol;
87 class Var;
88
89 namespace __gnu_cxx {
90 template <> struct hash<State*>
91 {
92 size_t operator()(State* s) const { return (size_t) s; }
93 };
94 template <> struct hash<Event*>
95 {
96 size_t operator()(Event* s) const { return (size_t) s; }
97 };
98 template <> struct hash<Symbol*>
99 {
100 size_t operator()(Symbol* s) const { return (size_t) s; }
101 };
102 template <> struct hash<Var*>
103 {
104 size_t operator()(Var* s) const { return (size_t) s; }
105 };
106 } // namespace __gnu_cxx
107
108 namespace std {
109 template <> struct equal_to<Event*>
110 {
111 bool operator()(Event* s1, Event* s2) const { return s1 == s2; }
112 };
113 template <> struct equal_to<State*>
114 {
115 bool operator()(State* s1, State* s2) const { return s1 == s2; }
116 };
117 template <> struct equal_to<Symbol*>
118 {
119 bool operator()(Symbol* s1, Symbol* s2) const { return s1 == s2; }
120 };
121 template <> struct equal_to<Var*>
122 {
123 bool operator()(Var* s1, Var* s2) const { return s1 == s2; }
124 };
125 } // namespace std
126
127 #endif //SLICC_GLOBAL_H