Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
MemoryAccessInfo.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* MemoryAccessInfo.cc (C) 2000-2006 */
9/* */
10/* Memory access information. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/utils/ArcanePrecomp.h"
15
16#include "arcane/utils/MemoryAccessInfo.h"
17#include "arcane/utils/Iostream.h"
18
19/*---------------------------------------------------------------------------*/
20/*---------------------------------------------------------------------------*/
21
22namespace Arcane
23{
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
28static Byte MA_HasValue = 1 << 1;
29static Byte MA_IsSync = 1 << 2;
30static Byte MA_NeedSync = 1 << 3;
31
32/*---------------------------------------------------------------------------*/
33/*---------------------------------------------------------------------------*/
34
35void MemoryAccessInfo::
36setCreate() const
37{
38 *m_info = 0;
39}
40
41void MemoryAccessInfo::
42setRead() const
43{
44 Byte v = *m_info;
45 if (v & MA_HasValue) {
46 if ((v & MA_NeedSync) && !(v & MA_IsSync)) {
47 if (m_trace)
48 m_trace->notify(MAM_NotSyncRead, m_handle);
49 else
50 std::cerr << "Not Sync Read\n";
51 }
52 return;
53 }
54 if (m_trace)
55 m_trace->notify(MAM_UnitializedMemoryRead, m_handle);
56 else
57 std::cerr << "Unitialized Memory Read\n";
58}
59
60void MemoryAccessInfo::
61setWrite() const
62{
63 Byte v = *m_info;
64 *m_info |= MA_HasValue;
65 if (v & MA_NeedSync)
66 *m_info = static_cast<Byte>(v & (~MA_IsSync));
67}
68
69void MemoryAccessInfo::
70setWriteAndSync() const
71{
72 *m_info |= MA_HasValue;
73 setSync();
74}
75
76void MemoryAccessInfo::
77setSync() const
78{
79 bool v = *m_info;
80 if (v & MA_NeedSync)
81 *m_info |= MA_IsSync;
82}
83
84void MemoryAccessInfo::
85setNeedSync(bool need_sync) const
86{
87 Byte v = *m_info;
88 if (need_sync)
89 *m_info |= MA_NeedSync;
90 else
91 *m_info = static_cast<Byte>(v & (~MA_NeedSync));
92}
93
94void MemoryAccessInfo::
95setReadOrWrite() const
96{
97 Byte v = *m_info;
98 if (v & MA_HasValue)
99 return;
100 if (m_trace)
101 m_trace->notify(MAM_MayBeUnitializedMemoryRead, m_handle);
102 else
103 std::cerr << "Value may be used unitialized\n";
104}
105
106/*---------------------------------------------------------------------------*/
107/*---------------------------------------------------------------------------*/
108
109} // namespace Arcane
110
111/*---------------------------------------------------------------------------*/
112/*---------------------------------------------------------------------------*/
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
unsigned char Byte
Type of a byte.
Definition BaseTypes.h:43