Arcane  v3.14.10.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
MemoryAccessInfo.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2022 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/* Informations sur un accès mémoire. */
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
22ARCANE_BEGIN_NAMESPACE
23
24/*---------------------------------------------------------------------------*/
25/*---------------------------------------------------------------------------*/
26
27static Byte MA_HasValue = 1 << 1;
28static Byte MA_IsSync = 1 << 2;
29static Byte MA_NeedSync = 1 << 3;
30
31/*---------------------------------------------------------------------------*/
32/*---------------------------------------------------------------------------*/
33
34void MemoryAccessInfo::
35setCreate() const
36{
37 *m_info = 0;
38}
39
40void MemoryAccessInfo::
41setRead() const
42{
43 Byte v = *m_info;
44 if (v & MA_HasValue){
45 if ( (v & MA_NeedSync) && !(v & MA_IsSync) ){
46 if (m_trace)
47 m_trace->notify(MAM_NotSyncRead,m_handle);
48 else
49 std::cerr << "Not Sync Read\n";
50 }
51 return;
52 }
53 if (m_trace)
54 m_trace->notify(MAM_UnitializedMemoryRead,m_handle);
55 else
56 std::cerr << "Unitialized Memory Read\n";
57}
58
59void MemoryAccessInfo::
60setWrite() const
61{
62 Byte v = *m_info;
63 *m_info |= MA_HasValue;
64 if (v & MA_NeedSync)
65 *m_info = static_cast<Byte>(v & (~MA_IsSync));
66}
67
68void MemoryAccessInfo::
69setWriteAndSync() const
70{
71 *m_info |= MA_HasValue;
72 setSync();
73}
74
75void MemoryAccessInfo::
76setSync() const
77{
78 bool v = *m_info;
79 if (v & MA_NeedSync)
80 *m_info |= MA_IsSync;
81}
82
83void MemoryAccessInfo::
84setNeedSync(bool need_sync) const
85{
86 Byte v = *m_info;
87 if (need_sync)
88 *m_info |= MA_NeedSync;
89 else
90 *m_info = static_cast<Byte>(v & (~MA_NeedSync));
91}
92
93void MemoryAccessInfo::
94setReadOrWrite() const
95{
96 Byte v = *m_info;
97 if (v & MA_HasValue)
98 return;
99 if (m_trace)
100 m_trace->notify(MAM_MayBeUnitializedMemoryRead,m_handle);
101 else
102 std::cerr << "Value may be used unitialized\n";
103}
104
105/*---------------------------------------------------------------------------*/
106/*---------------------------------------------------------------------------*/
107
108ARCANE_END_NAMESPACE
109
110/*---------------------------------------------------------------------------*/
111/*---------------------------------------------------------------------------*/
112
unsigned char Byte
Type d'un octet.
Definition UtilsTypes.h:142