gem5 v24.0.0.0
Loading...
Searching...
No Matches
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
23namespace tlm
24{
25
27
28inline tlm_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) ?
38 }
39 return host_endianness;
40}
41
42inline bool
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
58inline bool
60{
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_endianness get_host_endianness()
Definition helpers.hh:29
tlm_endianness
Definition helpers.hh:26
@ TLM_BIG_ENDIAN
Definition helpers.hh:26
@ TLM_LITTLE_ENDIAN
Definition helpers.hh:26
@ TLM_UNKNOWN_ENDIAN
Definition helpers.hh:26
bool has_host_endianness(tlm_endianness endianness)
Definition helpers.hh:59
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