gem5
v24.0.0.0
Loading...
Searching...
No Matches
systemc
ext
tlm_core
2
generic_payload
helpers.hh
Go to the documentation of this file.
1
/*****************************************************************************
2
3
Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
4
more contributor license agreements. See the NOTICE file distributed
5
with this work for additional information regarding copyright ownership.
6
Accellera licenses this file to you under the Apache License, Version 2.0
7
(the "License"); you may not use this file except in compliance with the
8
License. You may obtain a copy of the License at
9
10
http://www.apache.org/licenses/LICENSE-2.0
11
12
Unless required by applicable law or agreed to in writing, software
13
distributed under the License is distributed on an "AS IS" BASIS,
14
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
15
implied. See the License for the specific language governing
16
permissions and limitations under the License.
17
18
*****************************************************************************/
19
20
#ifndef __SYSTEMC_EXT_TLM_CORE_2_GENERIC_PAYLOAD_HELPERS_HH__
21
#define __SYSTEMC_EXT_TLM_CORE_2_GENERIC_PAYLOAD_HELPERS_HH__
22
23
namespace
tlm
24
{
25
26
enum
tlm_endianness
{
TLM_UNKNOWN_ENDIAN
,
TLM_LITTLE_ENDIAN
,
TLM_BIG_ENDIAN
};
27
28
inline
tlm_endianness
29
get_host_endianness
()
30
{
31
static
tlm_endianness
host_endianness =
TLM_UNKNOWN_ENDIAN
;
32
33
if
(host_endianness ==
TLM_UNKNOWN_ENDIAN
) {
34
unsigned
int
number = 1;
35
unsigned
char
*p_msb_or_lsb = (
unsigned
char
*)&number;
36
host_endianness = (p_msb_or_lsb[0] == 0) ?
37
TLM_BIG_ENDIAN
:
TLM_LITTLE_ENDIAN
;
38
}
39
return
host_endianness;
40
}
41
42
inline
bool
43
host_has_little_endianness
()
44
{
45
static
tlm_endianness
host_endianness =
TLM_UNKNOWN_ENDIAN
;
46
static
bool
host_little_endian =
false
;
47
48
if
(host_endianness ==
TLM_UNKNOWN_ENDIAN
) {
49
unsigned
int
number = 1;
50
unsigned
char
*p_msb_or_lsb = (
unsigned
char
*)&number;
51
52
host_little_endian = (p_msb_or_lsb[0] == 0) ?
false
:
true
;
53
}
54
55
return
host_little_endian;
56
}
57
58
inline
bool
59
has_host_endianness
(
tlm_endianness
endianness)
60
{
61
if
(
host_has_little_endianness
()) {
62
return
endianness ==
TLM_LITTLE_ENDIAN
;
63
}
else
{
64
return
endianness ==
TLM_BIG_ENDIAN
;
65
}
66
}
67
68
}
// namespace tlm
69
70
#endif
/* __SYSTEMC_EXT_TLM_CORE_2_GENERIC_PAYLOAD_HELPERS_HH__ */
tlm
Definition
analysis_fifo.hh:28
tlm::get_host_endianness
tlm_endianness get_host_endianness()
Definition
helpers.hh:29
tlm::tlm_endianness
tlm_endianness
Definition
helpers.hh:26
tlm::TLM_BIG_ENDIAN
@ TLM_BIG_ENDIAN
Definition
helpers.hh:26
tlm::TLM_LITTLE_ENDIAN
@ TLM_LITTLE_ENDIAN
Definition
helpers.hh:26
tlm::TLM_UNKNOWN_ENDIAN
@ TLM_UNKNOWN_ENDIAN
Definition
helpers.hh:26
tlm::has_host_endianness
bool has_host_endianness(tlm_endianness endianness)
Definition
helpers.hh:59
tlm::host_has_little_endianness
bool host_has_little_endianness()
Definition
helpers.hh:43
Generated on Tue Jun 18 2024 16:24:04 for gem5 by
doxygen
1.11.0