12#ifndef ARCANE_UTILS_ARCANEGLOBAL_H
13#define ARCANE_UTILS_ARCANEGLOBAL_H
21#include "arcane_core_config.h"
23#ifdef ARCCORE_OS_LINUX
24#define ARCANE_OS_LINUX
28#ifdef ARCCORE_OS_WIN32
29#define ARCANE_OS_WIN32
32#ifdef ARCCORE_OS_MACOS
33#define ARCANE_OS_MACOS
36#define ARCANE_EXPORT ARCCORE_EXPORT
37#define ARCANE_IMPORT ARCCORE_IMPORT
38#define ARCANE_TEMPLATE_EXPORT ARCCORE_TEMPLATE_EXPORT
39#define ARCANE_RESTRICT ARCCORE_RESTRICT
45#define ARCANE_UNUSED(var) ARCCORE_UNUSED(var)
53#ifndef ARCANE_NO_USING_FOR_STREAM
58using std::istringstream;
61using std::ostringstream;
68typedef ARCANE_TYPE_INT16 Int16;
69typedef ARCANE_TYPE_INT32 Int32;
70typedef ARCANE_TYPE_INT64 Int64;
73#define ARCANE_BEGIN_NAMESPACE \
76#define ARCANE_END_NAMESPACE }
77#define NUMERICS_BEGIN_NAMESPACE \
80#define NUMERICS_END_NAMESPACE }
85#ifdef ARCANE_COMPONENT_FULL
86#define ARCANE_COMPONENT_arcane_utils
87#define ARCANE_COMPONENT_arcane
88#define ARCANE_COMPONENT_arcane_mesh
89#define ARCANE_COMPONENT_arcane_std
90#define ARCANE_COMPONENT_arcane_impl
91#define ARCANE_COMPONENT_arcane_script
94#if defined(ARCANE_COMPONENT_arcane) || defined(ARCANE_COMPONENT_arcane_core)
95#define ARCANE_CORE_EXPORT ARCANE_EXPORT
96#define ARCANE_EXPR_EXPORT ARCANE_EXPORT
97#define ARCANE_DATATYPE_EXPORT ARCANE_EXPORT
98#define ARCANE_CORE_EXTERN_TPL
100#define ARCANE_CORE_EXPORT ARCANE_IMPORT
101#define ARCANE_EXPR_EXPORT ARCANE_IMPORT
102#define ARCANE_DATATYPE_EXPORT ARCANE_IMPORT
103#define ARCANE_CORE_EXTERN_TPL extern
106#ifdef ARCANE_COMPONENT_arcane_utils
107#define ARCANE_UTILS_EXPORT ARCANE_EXPORT
108#define ARCANE_UTILS_EXTERN_TPL
110#define ARCANE_UTILS_EXPORT ARCANE_IMPORT
111#define ARCANE_UTILS_EXTERN_TPL extern
114#ifdef ARCANE_COMPONENT_arcane_impl
115#define ARCANE_IMPL_EXPORT ARCANE_EXPORT
117#define ARCANE_IMPL_EXPORT ARCANE_IMPORT
120#ifdef ARCANE_COMPONENT_arcane_mesh
121#define ARCANE_MESH_EXPORT ARCANE_EXPORT
123#define ARCANE_MESH_EXPORT ARCANE_IMPORT
126#ifdef ARCANE_COMPONENT_arcane_std
127#define ARCANE_STD_EXPORT ARCANE_EXPORT
129#define ARCANE_STD_EXPORT ARCANE_IMPORT
132#ifdef ARCANE_COMPONENT_arcane_script
133#define ARCANE_SCRIPT_EXPORT ARCANE_EXPORT
135#define ARCANE_SCRIPT_EXPORT ARCANE_IMPORT
138#ifdef ARCANE_COMPONENT_arcane_solvers
139#define ARCANE_SOLVERS_EXPORT ARCANE_EXPORT
141#define ARCANE_SOLVERS_EXPORT ARCANE_IMPORT
144#ifdef ARCANE_COMPONENT_arcane_geometry
145#define ARCANE_GEOMETRY_EXPORT ARCANE_EXPORT
147#define ARCANE_GEOMETRY_EXPORT ARCANE_IMPORT
150#ifdef ARCANE_COMPONENT_arcane_thread
151#define ARCANE_THREAD_EXPORT ARCANE_EXPORT
153#define ARCANE_THREAD_EXPORT ARCANE_IMPORT
156#ifdef ARCANE_COMPONENT_arcane_mpi
157#define ARCANE_MPI_EXPORT ARCANE_EXPORT
159#define ARCANE_MPI_EXPORT ARCANE_IMPORT
162#ifdef ARCANE_COMPONENT_arcane_hyoda
163#define ARCANE_HYODA_EXPORT ARCANE_EXPORT
165#define ARCANE_HYODA_EXPORT ARCANE_IMPORT
168#ifdef ARCANE_REAL_USE_APFLOAT
181#define ARCANE_HAS_LONG_LONG
186const double cgrEPSILON_DELTA = 1.0e-2;
187const double cgrPI = 3.14159265358979323846;
192#define ARCANE_REAL(val) ARCCORE_REAL(val)
194#ifdef ARCCORE_REAL_NOT_BUILTIN
195#define ARCANE_REAL_NOT_BUILTIN
198#ifdef ARCCORE_REAL_LONG
199#define ARCANE_REAL_LONG
202#ifdef ARCCORE_REAL_IS_DOUBLE
203#define ARCANE_REAL_IS_DOUBLE
253extern "C++" ARCANE_UTILS_EXPORT
void
269extern "C++" ARCANE_UTILS_EXPORT
void
275extern "C++" ARCANE_UTILS_EXPORT
void
276_internalArcaneMathError(
long double arg_value,
const char* func_name);
278extern "C++" ARCANE_UTILS_EXPORT
void
279_internalArcaneMathError(
long double arg_value1,
long double arg_value2,
const char* func_name);
291ARCCORE_HOST_DEVICE
inline void
294#ifndef ARCCORE_DEVICE_CODE
295 _internalArcaneMathError(arg_value, func_name);
297 ARCANE_UNUSED(arg_value);
298 ARCANE_UNUSED(func_name);
311ARCCORE_HOST_DEVICE
inline void
314#ifndef ARCCORE_DEVICE_CODE
315 _internalArcaneMathError(arg_value1, arg_value2, func_name);
317 ARCANE_UNUSED(arg_value1);
318 ARCANE_UNUSED(arg_value2);
319 ARCANE_UNUSED(func_name);
336extern "C++" ARCANE_UTILS_EXPORT
void
343extern "C++" ARCANE_UTILS_EXPORT
void
358extern "C++" ARCANE_UTILS_EXPORT
void
370extern "C++" ARCANE_UTILS_EXPORT
void
378extern "C++" ARCANE_UTILS_EXPORT
Integer
386extern "C++" ARCANE_UTILS_EXPORT
Integer
394extern "C++" ARCANE_UTILS_EXPORT
Integer
402extern "C++" ARCANE_UTILS_EXPORT
Integer
410extern "C++" ARCANE_UTILS_EXPORT
Integer
418extern "C++" ARCANE_UTILS_EXPORT
Integer
425extern "C++" ARCANE_UTILS_EXPORT
void
470extern "C++" ARCANE_UTILS_EXPORT
478extern "C++" ARCANE_UTILS_EXPORT
bool _checkDebug(
size_t);
479#define ARCANE_DEBUGP(a, b) \
480 if (_checkDebug(a)) { \
484#define ARCANE_DEBUGP(a, b)
491#define ARCANE_NOT_YET_IMPLEMENTED(a) \
493 arcaneNotYetImplemented(__FILE__, __PRETTY_FUNCTION__, __LINE__, (a)); \
496#define ARCANE_NOT_YET_IMPLEMENTED(a) \
498 arcaneNotYetImplemented(__FILE__, "(NoInfo)", __LINE__, (a)); \
502#define ARCANE_DEPRECATED ARCCORE_DEPRECATED
504#define ARCANE_DEPRECATED_112 ARCANE_DEPRECATED
505#define ARCANE_DEPRECATED_114 ARCANE_DEPRECATED
506#define ARCANE_DEPRECATED_116 ARCANE_DEPRECATED
507#define ARCANE_DEPRECATED_118 ARCANE_DEPRECATED
508#define ARCANE_DEPRECATED_120 ARCANE_DEPRECATED
509#define ARCANE_DEPRECATED_122 ARCANE_DEPRECATED
510#define ARCANE_DEPRECATED_200 ARCANE_DEPRECATED
511#define ARCANE_DEPRECATED_220 ARCANE_DEPRECATED
512#define ARCANE_DEPRECATED_240 ARCANE_DEPRECATED
513#define ARCANE_DEPRECATED_260 ARCANE_DEPRECATED
514#define ARCANE_DEPRECATED_280 ARCANE_DEPRECATED
515#define ARCANE_DEPRECATED_2018 ARCANE_DEPRECATED
516#define ARCANE_DEPRECATED_2018_R(reason) [[deprecated(reason)]]
518#ifndef ARCCORE_DEPRECATED_2021
519#define ARCCORE_DEPRECATED_2021(reason) [[deprecated(reason)]]
522#define ARCANE_DEPRECATED_REASON(reason) [[deprecated(reason)]]
524#ifdef ARCANE_NO_DEPRECATED_LONG_TERM
525#define ARCANE_DEPRECATED_LONG_TERM(reason)
534#define ARCANE_DEPRECATED_LONG_TERM(reason) [[deprecated(reason)]]
538#define ARCANE_NO_DEPRECATED
542#ifdef ARCANE_NO_NOTIFY_DEPRECATED_ARRAY
543#define ARCANE_DEPRECATED_ARRAY
545#define ARCANE_DEPRECATED_ARRAY ARCANE_DEPRECATED
555#define ARCANE_JOIN_HELPER2(a, b) a##b
556#define ARCANE_JOIN_HELPER(a, b) ARCANE_JOIN_HELPER2(a, b)
557#define ARCANE_JOIN_WITH_LINE(a) ARCANE_JOIN_HELPER(a, __LINE__)
562#define ARCANE_NORETURN ARCCORE_NORETURN
565#define ARCANE_CONSTEXPR ARCCORE_CONSTEXPR
571#define ARCANE_NOEXCEPT ARCCORE_NOEXCEPT
572#define ARCANE_NOEXCEPT_FALSE ARCCORE_NOEXCEPT_FALSE
586#define ARCANE_ALIGNAS(value) __declspec(align(value))
588#define ARCANE_ALIGNAS_PACKED(value) __declspec(align(value))
591#define ARCANE_ALIGNAS_PACKED(value) __attribute__((aligned(value), packed))
593#define ARCANE_ALIGNAS(value) __attribute__((aligned(value)))
600#ifdef ARCANE_DEPRECATED
601#undef ARCANE_DEPRECATED
608#if defined(ARCANE_CHECK) || defined(ARCANE_DEBUG)
609#ifndef ARCANE_DEBUG_ASSERT
610#define ARCANE_DEBUG_ASSERT
622extern "C++" ARCANE_UTILS_EXPORT
void
637extern "C++" ARCANE_UTILS_EXPORT
void
646arcaneCheckNull(
const void* ptr)
662extern "C++" ARCANE_UTILS_EXPORT
Integer
671#ifdef ARCANE_DEBUG_ASSERT
672extern "C++" ARCANE_UTILS_EXPORT
void _doAssert(
const char*,
const char*,
const char*,
size_t);
673template <
typename T>
inline T*
674_checkPointer(T* t,
const char* file,
const char* func,
size_t line)
677 _doAssert(
"ARCANE_ASSERT", file, func, line);
683#define ARCANE_D_WHERE(a) Arcane::_doAssert(a, __FILE__, __PRETTY_FUNCTION__, __LINE__)
684#define ARCANE_DCHECK_POINTER(a) Arcane::_checkPointer((a), __FILE__, __PRETTY_FUNCTION__, __LINE__);
686#define ARCANE_D_WHERE(a) Arcane::_doAssert(a, __FILE__, "(NoInfo)", __LINE__)
687#define ARCANE_DCHECK_POINTER(a) Arcane::_checkPointer((a),__FILE__,"(NoInfo"),__LINE__);
689#define ARCANE_CHECK_PTR(a) \
692 Arcane::arcanePrintf("Null value"); \
693 ARCANE_D_WHERE("ARCANE_ASSERT"); \
697#define ARCANE_ASSERT(a, b) \
700 Arcane::arcanePrintf("Assertion '%s' fails:", #a); \
701 Arcane::arcanePrintf b; \
702 ARCANE_D_WHERE("ARCANE_ASSERT"); \
705#define ARCANE_WARNING(a) \
707 Arcane::arcanePrintf a; \
708 ARCANE_D_WHERE("ARCANE_WARNING"); \
711#define ARCANE_CHECK_PTR(a)
712#define ARCANE_ASSERT(a, b)
713#define ARCANE_WARNING(a)
714#define ARCANE_DCHECK_POINTER(a) (a);
726#define ARCANE_THROW(exception_class, ...) \
727 ARCCORE_THROW(exception_class, __VA_ARGS__)
738#define ARCANE_THROW_IF(const, exception_class, ...) \
739 ARCCORE_THROW_IF(const, exception_class, __VA_ARGS__)
749#define ARCANE_FATAL(...) \
750 ARCCORE_FATAL(__VA_ARGS__)
760#define ARCANE_FATAL_IF(const, ...) \
761 ARCCORE_FATAL_IF(const, __VA_ARGS__)
772arcaneThrowIfNull(
void* ptr,
const char* ptr_name,
const char* text)
787static inline const void*
788arcaneThrowIfNull(
const void* ptr,
const char* ptr_name,
const char* text)
803template <
typename T>
inline T*
804arcaneThrowIfNull(T* ptr,
const char* ptr_name,
const char* text)
819#define ARCANE_CHECK_POINTER(ptr) \
820 arcaneThrowIfNull(ptr, #ptr, nullptr)
828#define ARCANE_CHECK_POINTER2(ptr, text) \
829 arcaneThrowIfNull(ptr, #ptr, text)
841extern "C++" ARCANE_UTILS_EXPORT
void
842arcaneRangeError [[noreturn]] (Int64 i, Int64 max_size);
847static inline constexpr ARCCORE_HOST_DEVICE
void
848arcaneCheckAt(Int64 i, Int64 max_size)
850#ifndef ARCCORE_DEVICE_CODE
851 if (i < 0 || i >= max_size)
852 arcaneRangeError(i, max_size);
855 ARCANE_UNUSED(max_size);
859#if defined(ARCANE_CHECK) || defined(ARCANE_DEBUG)
860#define ARCANE_CHECK_AT(a, b) ::Arcane::arcaneCheckAt((a), (b))
862#define ARCANE_CHECK_AT(a, b)
Definitions and globals of Arccore.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
void arcaneNoReferenceErrorCallTerminate(const void *ptr)
Use of an unreferenced object.
Int64 arcaneCurrentThread()
Returns the ID of the current thread.
Integer arcaneCheckArraySize(unsigned long long size)
Checks that size can be converted into an 'Integer' to serve as the size of an array....
bool arcaneIsCheck()
True if running in check mode.
bool arcaneHasThread()
True if arcane is compiled with thread support AND they are active.
Int64 UniqueIdType
Type of integers used to store unique (global) identifiers of entities.
std::int64_t Int64
Signed integer type of 64 bits.
void arcaneSetHasThread(bool v)
Activates or deactivates thread support.
void arcaneNullPointerError()
Signals the use of a null pointer.
Int32 Integer
Type representing an integer.
void arcanePrintf(const char *,...)
Encapsulation of the C printf function.
void arcaneNotYetImplemented(const char *file, const char *func, unsigned long line, const char *text)
Signals an unimplemented function.
Integer arcaneSizeWithPadding(Integer size)
Returns the size with padding for a size size.
void arcaneDeprecated(const char *file, const char *func, unsigned long line, const char *text)
Signals the use of a deprecated function.
bool arcaneIsDebug()
True if the ARCANE_DEBUG macro is defined.
void arcaneSetCheck(bool v)
Activates or deactivates verification mode.
void arcaneNoReferenceError(const void *ptr)
Use of an unreferenced object.
bool _checkDebug(unsigned int val)
__host__ __device__ void arcaneMathError(long double arg_value, const char *func_name)
Signals an invalid argument in a mathematical function.
void _doAssert(const char *text, const char *file, const char *func, size_t line)
void arcaneDebugPause(const char *msg)
Enters pause mode or throws a fatal error.
void arcaneCheckAlignment(const void *ptr, Integer alignment)
Checks that ptr is aligned on alignment bytes. If not, throws a BadAlignmentException.
std::int32_t Int32
Signed integer type of 32 bits.
void arcaneThrowNullPointerError(const char *ptr_name, const char *text)
Signals the use of a null pointer by throwing an exception.