12#ifndef ARCANE_UTILS_ARCANEGLOBAL_H
13#define ARCANE_UTILS_ARCANEGLOBAL_H
17#include "arccore/base/ArccoreGlobal.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)
52#ifndef ARCANE_NO_USING_FOR_STREAM
59using std::ostringstream;
60using std::istringstream;
67typedef ARCANE_TYPE_INT16 Int16;
68typedef ARCANE_TYPE_INT32 Int32;
69typedef ARCANE_TYPE_INT64 Int64;
72#define ARCANE_BEGIN_NAMESPACE namespace Arcane {
73#define ARCANE_END_NAMESPACE }
74#define NUMERICS_BEGIN_NAMESPACE namespace Numerics {
75#define NUMERICS_END_NAMESPACE }
80#ifdef ARCANE_COMPONENT_FULL
81#define ARCANE_COMPONENT_arcane_utils
82#define ARCANE_COMPONENT_arcane
83#define ARCANE_COMPONENT_arcane_mesh
84#define ARCANE_COMPONENT_arcane_std
85#define ARCANE_COMPONENT_arcane_impl
86#define ARCANE_COMPONENT_arcane_script
89#if defined(ARCANE_COMPONENT_arcane) || defined(ARCANE_COMPONENT_arcane_core)
90#define ARCANE_CORE_EXPORT ARCANE_EXPORT
91#define ARCANE_EXPR_EXPORT ARCANE_EXPORT
92#define ARCANE_DATATYPE_EXPORT ARCANE_EXPORT
93#define ARCANE_CORE_EXTERN_TPL
95#define ARCANE_CORE_EXPORT ARCANE_IMPORT
96#define ARCANE_EXPR_EXPORT ARCANE_IMPORT
97#define ARCANE_DATATYPE_EXPORT ARCANE_IMPORT
98#define ARCANE_CORE_EXTERN_TPL extern
101#ifdef ARCANE_COMPONENT_arcane_utils
102#define ARCANE_UTILS_EXPORT ARCANE_EXPORT
103#define ARCANE_UTILS_EXTERN_TPL
105#define ARCANE_UTILS_EXPORT ARCANE_IMPORT
106#define ARCANE_UTILS_EXTERN_TPL extern
109#ifdef ARCANE_COMPONENT_arcane_impl
110#define ARCANE_IMPL_EXPORT ARCANE_EXPORT
112#define ARCANE_IMPL_EXPORT ARCANE_IMPORT
115#ifdef ARCANE_COMPONENT_arcane_mesh
116#define ARCANE_MESH_EXPORT ARCANE_EXPORT
118#define ARCANE_MESH_EXPORT ARCANE_IMPORT
121#ifdef ARCANE_COMPONENT_arcane_std
122#define ARCANE_STD_EXPORT ARCANE_EXPORT
124#define ARCANE_STD_EXPORT ARCANE_IMPORT
127#ifdef ARCANE_COMPONENT_arcane_script
128#define ARCANE_SCRIPT_EXPORT ARCANE_EXPORT
130#define ARCANE_SCRIPT_EXPORT ARCANE_IMPORT
133#ifdef ARCANE_COMPONENT_arcane_solvers
134#define ARCANE_SOLVERS_EXPORT ARCANE_EXPORT
136#define ARCANE_SOLVERS_EXPORT ARCANE_IMPORT
139#ifdef ARCANE_COMPONENT_arcane_geometry
140#define ARCANE_GEOMETRY_EXPORT ARCANE_EXPORT
142#define ARCANE_GEOMETRY_EXPORT ARCANE_IMPORT
145#ifdef ARCANE_COMPONENT_arcane_thread
146#define ARCANE_THREAD_EXPORT ARCANE_EXPORT
148#define ARCANE_THREAD_EXPORT ARCANE_IMPORT
151#ifdef ARCANE_COMPONENT_arcane_mpi
152#define ARCANE_MPI_EXPORT ARCANE_EXPORT
154#define ARCANE_MPI_EXPORT ARCANE_IMPORT
157#ifdef ARCANE_COMPONENT_arcane_hyoda
158#define ARCANE_HYODA_EXPORT ARCANE_EXPORT
160#define ARCANE_HYODA_EXPORT ARCANE_IMPORT
163#ifdef ARCANE_REAL_USE_APFLOAT
176#define ARCANE_HAS_LONG_LONG
181const double cgrEPSILON_DELTA = 1.0e-2;
182const double cgrPI = 3.14159265358979323846;
187#define ARCANE_REAL(val) ARCCORE_REAL(val)
189#ifdef ARCCORE_REAL_NOT_BUILTIN
190# define ARCANE_REAL_NOT_BUILTIN
193#ifdef ARCCORE_REAL_LONG
194# define ARCANE_REAL_LONG
197#ifdef ARCCORE_REAL_IS_DOUBLE
198# define ARCANE_REAL_IS_DOUBLE
248extern "C++" ARCANE_UTILS_EXPORT
void
264extern "C++" ARCANE_UTILS_EXPORT
void
270extern "C++" ARCANE_UTILS_EXPORT
void
271_internalArcaneMathError(
long double arg_value,
const char* func_name);
273extern "C++" ARCANE_UTILS_EXPORT
void
274_internalArcaneMathError(
long double arg_value1,
long double arg_value2,
const char* func_name);
286ARCCORE_HOST_DEVICE
inline void
289#ifndef ARCCORE_DEVICE_CODE
290 _internalArcaneMathError(arg_value,func_name);
292 ARCANE_UNUSED(arg_value);
293 ARCANE_UNUSED(func_name);
306ARCCORE_HOST_DEVICE
inline void
309#ifndef ARCCORE_DEVICE_CODE
310 _internalArcaneMathError(arg_value1,arg_value2,func_name);
312 ARCANE_UNUSED(arg_value1);
313 ARCANE_UNUSED(arg_value2);
314 ARCANE_UNUSED(func_name);
330extern "C++" ARCANE_UTILS_EXPORT
void
337extern "C++" ARCANE_UTILS_EXPORT
void
352extern "C++" ARCANE_UTILS_EXPORT
void
364extern "C++" ARCANE_UTILS_EXPORT
void
373extern "C++" ARCANE_UTILS_EXPORT
Integer
382extern "C++" ARCANE_UTILS_EXPORT
Integer
391extern "C++" ARCANE_UTILS_EXPORT
Integer
400extern "C++" ARCANE_UTILS_EXPORT
Integer
409extern "C++" ARCANE_UTILS_EXPORT
Integer
418extern "C++" ARCANE_UTILS_EXPORT
Integer
425extern "C++" ARCANE_UTILS_EXPORT
void
434extern "C++" ARCANE_UTILS_EXPORT
444extern "C++" ARCANE_UTILS_EXPORT
450extern "C++" ARCANE_UTILS_EXPORT
456extern "C++" ARCANE_UTILS_EXPORT
468extern "C++" ARCANE_UTILS_EXPORT
476extern "C++" ARCANE_UTILS_EXPORT
483extern "C++" ARCANE_UTILS_EXPORT
bool _checkDebug(
size_t);
484#define ARCANE_DEBUGP(a,b) if (_checkDebug(a)) { arcanePrintf b; }
486#define ARCANE_DEBUGP(a,b)
493# define ARCANE_NOT_YET_IMPLEMENTED(a) \
494{ arcaneNotYetImplemented(__FILE__,__PRETTY_FUNCTION__,__LINE__,(a)); }
496# define ARCANE_NOT_YET_IMPLEMENTED(a) \
497{ arcaneNotYetImplemented(__FILE__,"(NoInfo)",__LINE__,(a)); }
500#define ARCANE_DEPRECATED ARCCORE_DEPRECATED
502#define ARCANE_DEPRECATED_112 ARCANE_DEPRECATED
503#define ARCANE_DEPRECATED_114 ARCANE_DEPRECATED
504#define ARCANE_DEPRECATED_116 ARCANE_DEPRECATED
505#define ARCANE_DEPRECATED_118 ARCANE_DEPRECATED
506#define ARCANE_DEPRECATED_120 ARCANE_DEPRECATED
507#define ARCANE_DEPRECATED_122 ARCANE_DEPRECATED
508#define ARCANE_DEPRECATED_200 ARCANE_DEPRECATED
509#define ARCANE_DEPRECATED_220 ARCANE_DEPRECATED
510#define ARCANE_DEPRECATED_240 ARCANE_DEPRECATED
511#define ARCANE_DEPRECATED_260 ARCANE_DEPRECATED
512#define ARCANE_DEPRECATED_280 ARCANE_DEPRECATED
513#define ARCANE_DEPRECATED_2018 ARCANE_DEPRECATED
514#define ARCANE_DEPRECATED_2018_R(reason) [[deprecated(reason)]]
516#ifndef ARCCORE_DEPRECATED_2021
517#define ARCCORE_DEPRECATED_2021(reason) [[deprecated(reason)]]
520#define ARCANE_DEPRECATED_REASON(reason) [[deprecated(reason)]]
522#ifdef ARCANE_NO_DEPRECATED_LONG_TERM
523#define ARCANE_DEPRECATED_LONG_TERM(reason)
532#define ARCANE_DEPRECATED_LONG_TERM(reason) [[deprecated(reason)]]
537#define ARCANE_NO_DEPRECATED
541#ifdef ARCANE_NO_NOTIFY_DEPRECATED_ARRAY
542#define ARCANE_DEPRECATED_ARRAY
544#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__)
563#define ARCANE_NORETURN ARCCORE_NORETURN
566#define ARCANE_CONSTEXPR ARCCORE_CONSTEXPR
573#define ARCANE_NOEXCEPT ARCCORE_NOEXCEPT
574#define ARCANE_NOEXCEPT_FALSE ARCCORE_NOEXCEPT_FALSE
589# define ARCANE_ALIGNAS(value) __declspec(align(value))
591# define ARCANE_ALIGNAS_PACKED(value) __declspec(align(value))
594# define ARCANE_ALIGNAS_PACKED(value) __attribute__ ((aligned (value),packed))
596# define ARCANE_ALIGNAS(value) __attribute__ ((aligned (value)))
603#ifdef ARCANE_DEPRECATED
604#undef ARCANE_DEPRECATED
611#if defined(ARCANE_CHECK) || defined(ARCANE_DEBUG)
612#ifndef ARCANE_DEBUG_ASSERT
613#define ARCANE_DEBUG_ASSERT
626extern "C++" ARCANE_UTILS_EXPORT
void
642extern "C++" ARCANE_UTILS_EXPORT
void
651arcaneCheckNull(
const void* ptr)
667extern "C++" ARCANE_UTILS_EXPORT
Integer
676#ifdef ARCANE_DEBUG_ASSERT
677extern "C++" ARCANE_UTILS_EXPORT
void _doAssert(
const char*,
const char*,
const char*,
size_t);
678template<
typename T>
inline T*
679_checkPointer(T* t,
const char* file,
const char* func,
size_t line)
682 _doAssert(
"ARCANE_ASSERT",file,func,line);
688# define ARCANE_D_WHERE(a) Arcane::_doAssert(a,__FILE__,__PRETTY_FUNCTION__,__LINE__)
689# define ARCANE_DCHECK_POINTER(a) Arcane::_checkPointer((a),__FILE__,__PRETTY_FUNCTION__,__LINE__);
691# define ARCANE_D_WHERE(a) Arcane::_doAssert(a,__FILE__,"(NoInfo)",__LINE__)
692# define ARCANE_DCHECK_POINTER(a) Arcane::_checkPointer((a),__FILE__,"(NoInfo"),__LINE__);
694# define ARCANE_CHECK_PTR(a) \
695 {if (!(a)){Arcane::arcanePrintf("Null value");ARCANE_D_WHERE("ARCANE_ASSERT");}}
697# define ARCANE_ASSERT(a,b) \
698 {if (!(a)){ Arcane::arcanePrintf("Assertion '%s' fails:",#a); Arcane::arcanePrintf b; ARCANE_D_WHERE("ARCANE_ASSERT");}}
699# define ARCANE_WARNING(a) \
700 { Arcane::arcanePrintf a; ARCANE_D_WHERE("ARCANE_WARNING"); }
702# define ARCANE_CHECK_PTR(a)
703# define ARCANE_ASSERT(a,b)
704# define ARCANE_WARNING(a)
705# define ARCANE_DCHECK_POINTER(a) (a);
717#define ARCANE_THROW(exception_class,...) \
718 ARCCORE_THROW(exception_class,__VA_ARGS__)
729#define ARCANE_THROW_IF(const, exception_class, ...) \
730 ARCCORE_THROW_IF(const, exception_class, __VA_ARGS__)
740#define ARCANE_FATAL(...) \
741 ARCCORE_FATAL(__VA_ARGS__)
751#define ARCANE_FATAL_IF(const, ...) \
752 ARCCORE_FATAL_IF(const, __VA_ARGS__)
763arcaneThrowIfNull(
void* ptr,
const char* ptr_name,
const char* text)
778static inline const void*
779arcaneThrowIfNull(
const void* ptr,
const char* ptr_name,
const char* text)
794template<
typename T>
inline T*
795arcaneThrowIfNull(T* ptr,
const char* ptr_name,
const char* text)
810#define ARCANE_CHECK_POINTER(ptr) \
811 arcaneThrowIfNull(ptr,#ptr,nullptr)
819#define ARCANE_CHECK_POINTER2(ptr,text)\
820 arcaneThrowIfNull(ptr,#ptr,text)
833extern "C++" ARCANE_UTILS_EXPORT
void
834arcaneRangeError [[noreturn]] (Int64 i,Int64 max_size);
839static inline constexpr ARCCORE_HOST_DEVICE
void
840arcaneCheckAt(Int64 i,Int64 max_size)
842#ifndef ARCCORE_DEVICE_CODE
843 if (i<0 || i>=max_size)
844 arcaneRangeError(i,max_size);
847 ARCANE_UNUSED(max_size);
851#if defined(ARCANE_CHECK) || defined(ARCANE_DEBUG)
852#define ARCANE_CHECK_AT(a,b) ::Arcane::arcaneCheckAt((a),(b))
854#define ARCANE_CHECK_AT(a,b)
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
void arcaneNoReferenceErrorCallTerminate(const void *ptr)
Utilisation d'un objet non référencé.
Int64 arcaneCurrentThread()
Retourne l'identifiant du thread courant.
Integer arcaneCheckArraySize(unsigned long long size)
Vérifie que size peut être converti dans un 'Integer' pour servir de taille à un tableau....
bool arcaneIsCheck()
Vrai si on est en mode vérification.
bool arcaneHasThread()
Vrai si arcane est compilé avec le support des threads ET qu'ils sont actifs.
Int64 UniqueIdType
Type des entiers utilisés pour stocker les identifiants uniques (globaux) des entités.
std::int64_t Int64
Type entier signé sur 64 bits.
void arcaneSetHasThread(bool v)
Active ou désactive le support des threads.
void arcaneNullPointerError()
Signalue l'utilisation d'un pointeur nul.
Int32 Integer
Type représentant un entier.
void arcanePrintf(const char *,...)
Encapsulation de la fonction C printf.
void arcaneNotYetImplemented(const char *file, const char *func, unsigned long line, const char *text)
Signale une fonction non implémentée.
Integer arcaneSizeWithPadding(Integer size)
Retourne la taille avec padding pour une taille size.
void arcaneDeprecated(const char *file, const char *func, unsigned long line, const char *text)
Signale l'utilisation d'une fonction obsolète.
bool arcaneIsDebug()
Vrai si la macro ARCANE_DEBUG est définie.
void arcaneSetCheck(bool v)
Active ou désactive le mode vérification.
void arcaneNoReferenceError(const void *ptr)
Utilisation d'un objet non référencé.
bool _checkDebug(unsigned int val)
__host__ __device__ void arcaneMathError(long double arg_value, const char *func_name)
Signale un argument invalide d'une fonction mathématique.
void _doAssert(const char *text, const char *file, const char *func, size_t line)
void arcaneDebugPause(const char *msg)
Passe en mode pause ou lance une erreur fatale.
void arcaneCheckAlignment(const void *ptr, Integer alignment)
Vérifie que ptr est aligné sur alignment octets. Si ce n'est pas le cas, Sinon, lance une exception d...
std::int32_t Int32
Type entier signé sur 32 bits.
void arcaneThrowNullPointerError(const char *ptr_name, const char *text)
Signalee l'utilisation d'un pointeur nul en envoyant une exception.