Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
BadAlignmentException.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/* BadAlignmentException.cc (C) 2000-2016 */
9/* */
10/* Exception when an address is not correctly aligned. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/utils/ArcanePrecomp.h"
15
16#include "arcane/utils/String.h"
17#include "arcane/utils/BadAlignmentException.h"
18
19/*---------------------------------------------------------------------------*/
20/*---------------------------------------------------------------------------*/
21
22namespace Arcane
23{
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
28BadAlignmentException::
29BadAlignmentException(const String& awhere, const void* ptr, Integer alignment)
30: Exception("BadAlignmentException", awhere)
31, m_ptr(ptr)
32, m_wanted_alignment(alignment)
33{
34}
35
36/*---------------------------------------------------------------------------*/
37/*---------------------------------------------------------------------------*/
38
39BadAlignmentException::
40BadAlignmentException(const TraceInfo& awhere, const void* ptr, Integer alignment)
41: Exception("BadAlignmentException", awhere)
42, m_ptr(ptr)
43, m_wanted_alignment(alignment)
44{
45}
46
47/*---------------------------------------------------------------------------*/
48/*---------------------------------------------------------------------------*/
49
50void BadAlignmentException::
51explain(std::ostream& m) const
52{
53 Int64 alignment = 0;
54 if (m_wanted_alignment > 0) {
55 Int64 ptr = (Int64)m_ptr;
56 alignment = ptr % m_wanted_alignment;
57 }
58 m << "Bad alignment for address " << m_ptr
59 << " alignment=" << alignment
60 << " (wanted=" << m_wanted_alignment << ").";
61}
62
63/*---------------------------------------------------------------------------*/
64/*---------------------------------------------------------------------------*/
65
66} // namespace Arcane
67
68/*---------------------------------------------------------------------------*/
69/*---------------------------------------------------------------------------*/
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
std::int64_t Int64
Signed integer type of 64 bits.
Int32 Integer
Type representing an integer.