44# if ALIB_CONFIGURATION
111DOX_MARKER([DOX_CRITICAL_SECTIONS_ADD_LOCK])
112#if ALIB_DEBUG_CRITICAL_SECTIONS && ALIB_MONOMEM
118DOX_MARKER([DOX_CRITICAL_SECTIONS_ADD_LOCK])
143 { 6,
"CONFIGURATION" },
147 { 9,
"EXPRESSIONS" },
150 { 12,
"SINGLETONS" },
152 { 14,
"THREADMODEL" },
158 { 24,
"ALIB_DEBUG_ARRAY_COMPRESSION" },
159 { 25,
"ALIB_DEBUG_ALLOCATIONS" },
160 { 26,
"ALIB_DEBUG_BOXING" },
161 { 27,
"ALIB_DEBUG_CONTAINERS" },
162 { 28,
"ALIB_DEBUG_CRITICAL_SECTIONS" },
163 { 29,
"ALIB_DEBUG_MONOMEM" },
164 { 30,
"ALIB_DEBUG_STRINGS" },
165 { 31,
"ALIB_DEBUG_RESOURCES" },
168 { 32,
"FEAT_SINGLETON_MAPPED" },
169 { 33,
"CHARACTERS_WIDE" },
170 { 34,
"CHARACTERS_WCHAR_IS_4" },
171 { 35,
"FEAT_BOXING_BIJECTIVE_INTEGRALS" },
172 { 36,
"FEAT_BOXING_BIJECTIVE_CHARACTERS" },
173 { 37,
"FEAT_BOXING_BIJECTIVE_FLOATS" },
174 { 38,
"ALIB_FEAT_BOOST_REGEX" },
177 { 41,
"DBG_LOG_CI" },
179 { 43,
"REL_LOG_CI" },
189 std::cerr <<
"!!! Error in ALox library compilation: linked against wrong version of ALib" << std::endl;
190 std::cerr <<
"!!! ALib library version: " <<
VERSION <<
"R" << int(
REVISION) << std::endl;
191 std::cerr <<
"!!! ALib requested version: " << alibVersion <<
"R" << alibRevision << std::endl;
192 std::cerr <<
"!!! Exiting with exit(-1)" << std::endl;
203 std::cerr <<
"!!! Error in ALib library compilation: linked library of ALib has "
204 "different compiler symbols set than the using executable (or library)." << std::endl;
207 std::cerr << std::left << std::setw(35) <<
"Symbol" <<
'|' << std::setw(5) <<
" Lib" <<
'|' <<
" Comp. Unit" << std::endl;
208 std::cerr<< std::setw(62) << std::setfill(
'-') <<
' ' << std::endl << std::setfill(
' ');
213 bool reqFlag= (compilationFlags.
bits[p.Flag/8] & (1 << (p.Flag % 8))) != 0;
215 std::cerr << std::setw(35) << p.Name <<
'|' << std::setw(5) << (libFlag ?
" On" :
" Off")
216 <<
"|" << std::setw(5) << (reqFlag ?
" On" :
" Off")
217 << ( libFlag != reqFlag ?
" <-- Mismatch! " :
"")
222 std::cerr <<
"!!! Exiting with exit(-1)" << std::endl;
233#if (ALIB_DEBUG && !ALIB_THREADS && ALIB_EXT_LIB_THREADS_AVAILABLE) || DOXYGEN
238 namespace { std::thread::id dbg_thread_seen;
239 bool dbg_in_single_threaded_check=
false; }
269 if( dbg_in_single_threaded_check )
271 dbg_in_single_threaded_check=
true;
276 dbg_thread_seen= std::this_thread::get_id();
277 dbg_in_single_threaded_check=
false;
281 if( dbg_thread_seen != std::this_thread::get_id() )
284 "A second thread was detected using a single-threaded compilation of "
285 "ALib! (Module 'Threads' not included in the ALib distribution)." )
287 dbg_in_single_threaded_check=
false;
297#if ALIB_DEBUG_CRITICAL_SECTIONS
309# if defined( _WIN32 ) && !defined(_STRING_)
317 int qtyMsgs,
const char** msgs )
324 const char* msg1,
const char* msg2,
const char* msg3,
325 const char* msg4,
const char* msg5 )
329 int qtyMsgs= msg2 !=
nullptr ? (msg3 !=
nullptr ? (msg4 !=
nullptr ? (msg5 !=
nullptr ? 5 : 4) : 3) : 2) : 1;
330 const char* msgs[5]= { msg1, msg2, msg3, msg4, msg5 };
339 if( type == 0 ) std::cout <<
"ALib Error: ";
340 else if( type == 1 ) std::cout <<
"ALib WARNING: ";
341 else std::cout <<
"ALib Message(" << type <<
"): ";
349 bool illegalCharacterFound=
false;
351 auto strLen= strlen(msg1);
352 for(
size_t idx= 0 ; idx< strLen ; ++idx )
356 || ( c >=
'A' && c <=
'Z' )
363 illegalCharacterFound=
true;
368 if(!illegalCharacterFound)
370 std::cout << msg1 <<
": ";
376 for ( ; msgNo != qtyMsgs; ++msgNo )
377 std::cout << msgs[msgNo];
378 std::cout << std::endl;
379 std::cout <<
"At : " << ci.
File <<
':' << ci.
Line <<
' ' << ci.
Func <<
"()" << std::endl;
385 const char* msg,
int intVal )
387 std::basic_string<char> sIntVal= std::to_string( intVal );
390 const char* msgs[2]= { msg, sIntVal.c_str() };
397 std::cout <<
"Error in '" << topic <<
"': ";
399 std::cout <<
"Warning in '" << topic <<
"' " <<
"(type=" << type <<
"): ";
400 std::cout << msg << sIntVal << std::endl;
401 std::cout <<
"At : " << ci.
File <<
':' << ci.
Line <<
' ' << ci.
Func <<
"()" << std::endl;
414#include <type_traits>
418static_assert(
sizeof(
alib::integer ) ==
sizeof(std::size_t ),
"Error in ALib type definitions" );
419static_assert(std::is_signed< alib::integer>::value == std::is_signed<std::ptrdiff_t >::value,
"Error in ALib type definitions" );
420static_assert(std::is_signed< alib::integer>::value != std::is_signed<std::size_t >::value,
"Error in ALib type definitions" );
421static_assert(std::is_signed<alib::uinteger>::value == std::is_signed<std::size_t >::value,
"Error in ALib type definitions" );
422static_assert(std::is_signed<alib::uinteger>::value != std::is_signed<std::ptrdiff_t >::value,
"Error in ALib type definitions" );
429#if ALIB_DEBUG && !DOXYGEN
431# if defined(__GNUC__) || defined(__clang__)
442 #if defined(__GNUC__) || defined(__clang__)
447 name= abi::__cxa_demangle( typeInfo.name(),
nullptr,
nullptr, &status);
448 assert( status==0 || !
name );
450 name=
"<DbgTypeDemangler Error>";
454 {
if (!failed) std::free(
static_cast<void*
>(
const_cast<char*
>(name) ) ); }
459 name= typeInfo.name();
460 if (std::strncmp( name,
"class ", 6) == 0)
475 bool startedWithDoubleColon=
false;
476 for (
integer i = 0; i < typeName.Length(); ++i)
479 if(typeName.Substring(i, 7).Equals(
"struct ")) i+= 7;
480 if(typeName.Substring(i, 6).Equals(
"class " )) i+= 6;
481 if(typeName.Substring(i, 6).Equals(
"union " )) i+= 6;
483 char c = typeName.CharAt<NC>(i);
491 if (!(isalnum(c) || c=='_') || i == typeName.Length() - 1)
493 if (startedWithDoubleColon)
495 result << typeName.Substring(nameStart, i-nameStart+1);
497 startedWithDoubleColon= typeName.CharAt(nameStart) ==
':';
503 result.SearchAndReplace(
"> >",
">>");
bool failed
If true, demangling failed.
ALIB_API NAString & GetShort(NAString &target)
ALIB_API const char * Get()
ALIB_API ~DbgTypeDemangler()
Destructor.
const char * name
The translated name.
ALIB_API DbgTypeDemangler(const std::type_info &typeInfo)
lang::Placeholder< lang::DbgCriticalSections > DbgCriticalSectionsPH
DbgLockAsserter Dbg
The debug tool instance.
#define IF_ALIB_BOXING(...)
#define IF_ALIB_THREADS(...)
#define ALIB_WARNINGS_RESTORE
#define IF_ALIB_SINGLETONS(...)
#define IF_ALIB_THREADMODEL(...)
#define IF_ALIB_TIME(...)
#define IF_ALIB_ENUMS(...)
#define ALIB_WARNINGS_ALLOW_UNSAFE_BUFFER_USAGE
#define ALIB_ASSERT(cond)
constexpr bool IsNull(const T &t)
platform_specific integer
ALIB_API void DbgSimpleALibMsg(const CallerInfo &ci, int type, const char *topic, const char *msg1=nullptr, const char *msg2=nullptr, const char *msg3=nullptr, const char *msg4=nullptr, const char *msg5=nullptr)
unsigned int DBG_CRITICAL_SECTION_YIELD_OR_SLEEP_TIME_IN_NS
void(* DBG_SIMPLE_ALIB_MSG_PLUGIN)(const CallerInfo &ci, int type, const char *topic, int qtyMsgs, const char **msgs)
@ Get
Denotes to search data.
ALIB_API MonoAllocator GLOBAL_ALLOCATOR
ALIB_API RecursiveLock GLOBAL_ALLOCATOR_LOCK
ALIB_API void Bootstrap()
@ Destruct
The main phase of termination that destructs everything.
ALIB_WARNINGS_ALLOW_UNSAFE_BUFFER_USAGE void AssertALibVersionAndFlags(int alibVersion, int alibRevision, TCompilationFlags compilationFlags)
CompilationFlagMeaningsEntry COMPILATION_FLAG_MEANINGS[37]
lang::uinteger uinteger
Type alias in namespace alib.
@ Final
The final initialization phase. Here, camps are initializing their custom setup.
strings::TString< nchar > NString
Type alias in namespace alib.
strings::TAString< nchar, lang::HeapAllocator > NAString
Type alias in namespace alib.
bool NonCampModulesInitialized
ALIB_API List< MonoAllocator, lang::Camp * > CAMPS
monomem::TMonoAllocator< lang::HeapAllocator > MonoAllocator
void BootstrapAddDefaultCamps()
ALIB_WARNINGS_RESTORE void Bootstrap(int alibVersion, int alibRevision, TCompilationFlags compilationFlags)
void DbgAssertSingleThreaded()
lang::integer integer
Type alias in namespace alib.
ALIB_WARNINGS_ALLOW_UNSAFE_BUFFER_USAGE TCompilationFlags COMPILATION_FLAGS
This is a struct composing an entry in COMPILATION_FLAG_MEANINGS.
unsigned char bits[6]
The Flags.
const char * File
The name of the source file as given by compiler.
int Line
The line number within File.