libGimbal 0.1.0
C17-Based Extended Standard Library and Cross-Language Runtime Framework
Loading...
Searching...
No Matches
gimbal_ctx.h
Go to the documentation of this file.
1/*! \file
2 * \brief GblContext top-level debug and control-flow macros
3 * \ingroup core
4 *
5 * \author Falco Girgis
6 */
7#ifndef GIMBAL_CTX_H
8#define GIMBAL_CTX_H
9
10#include "../algorithms/gimbal_numeric.h"
11#include "../meta/ifaces/gimbal_ilogger.h"
12#include "gimbal_thd.h"
13#include <stdarg.h>
14#include <string.h>
15#include <errno.h>
16
18
19// ===== GBL API FRAME CONVENIENCE ACCESSORS =====
20
21#define GBL_CTX_FRAME_DECLARE GblStackFrame* GBL_CTX_FRAME_NAME
22#define GBL_CTX_FRAME() (GblThd_current()->pStackFrameTop)
23#define GBL_CTX_CONTEXT() GBL_CTX_FRAME()->pContext
24#define GBL_CTX_OBJECT() GBL_CTX_FRAME()->pObject
25#define GBL_CTX_RECORD() (GBL_CTX_FRAME_NAME)->record
26#define GBL_CTX_RESULT() (GBL_CTX_FRAME_NAME)->record.result
27#define GBL_CTX_SOURCE() (GBL_CTX_FRAME_NAME)->record.srcLocation
28#define GBL_CTX_LAST_RECORD() (GblThd_current()->callRecord)
29#define GBL_CTX_LAST_RESULT() (GBL_CTX_LAST_RECORD().result)
30
31// ====== SOURCE LOCATION PROPAGATION UTILITIES =====
32
33#define GBL_SRC_FILE __FILE__
34#define GBL_SRC_FN __func__
35#define GBL_SRC_LN __LINE__
36#define GBL_SRC_LOC GBL_SOURCE_LOCATION
37#define GblSrcLoc GblSourceLocation
38
39#define GBL_SOURCE_LOCATION(FILE, FUNCTION, LINE) GBL_STRUCT_INIT(GblSourceLocation, FILE, FUNCTION, LINE)
40
41#define GBL_CTX_STACK_FRAME_SOURCE_PUSH(pStackFrame, current)
42 if(++pStackFrame->sourceCurrentCaptureDepth == 1) GBL_CTX_SOURCE() = current;
43
44#define GBL_CTX_STACK_FRAME_SOURCE_POP(pStackFrame)
46 GBL_ASSERT(pStackFrame->sourceCurrentCaptureDepth);
47 --pStackFrame->sourceCurrentCaptureDepth;
49
50#define GBL_CTX_SOURCE_LOC_PUSH(srcLoc)
51 GBL_CTX_STACK_FRAME_SOURCE_PUSH(GBL_CTX_FRAME_NAME, srcLoc)
52
53#define GBL_CTX_SOURCE_PUSH(FILE, FUNCTION, LINE)
54 GBL_CTX_SOURCE_LOC_PUSH(GBL_SOURCE_LOCATION(FILE, FUNCTION, LINE))
55
56#define GBL_CTX_SOURCE_POP()
57 GBL_CTX_STACK_FRAME_SOURCE_POP(GBL_CTX_FRAME_NAME)
58
59#define GBL_CTX_SOURCE_SCOPED(CALL, loc, ...)
62 GBL_IDENTITY(CALL)(__VA_ARGS__);
65
66// ====== BOTTOM-LEVEL ERROR HANDLING + CONTROL FLOW =====
67
68#define GBL_CTX_RECORD_SET_JMP_CND_(expr, result, label, srcLoc, ...)
71 if(!(expr)) GBL_UNLIKELY {
72 GBL_CTX_RECORD_SET(result, __VA_ARGS__);
74 label;
75 } else GBL_LIKELY {
77 }
79
80#define GBL_CTX_RECORD_SET_JMP_CND(expr, result, label, ...)
81 GBL_CTX_RECORD_SET_JMP_CND_(expr, result, goto label, GBL_SRC_LOC(GBL_SRC_FILE, GBL_SRC_FN, GBL_SRC_LN), __VA_ARGS__);
82
83//====== VERIFY =========
84
85#define GBL_CTX_VERIFY_(expr, result, srcLoc, ...)
87 result,
88 goto GBL_CTX_END_LABEL,
89 srcLoc, __VA_ARGS__)
90
91#define GBL_CTX_VERIFY_N(srcLoc, expr, result, ...)
92 GBL_CTX_VERIFY_(expr, result, srcLoc, __VA_ARGS__)
93
94#define GBL_CTX_VERIFY_3(srcLoc, expr, result)
95 GBL_CTX_VERIFY_N(srcLoc, expr, result, gblResultString(result))
96
97#define GBL_CTX_VERIFY(...)
100 GBL_VA_OVERLOAD_SELECT(GBL_CTX_VERIFY, GBL_VA_OVERLOAD_SUFFIXER_3_N, src_, __VA_ARGS__)(src_, __VA_ARGS__);
102
103//====== VERIFY_EXPRESSION =========
104
105#define GBL_CTX_VERIFY_EXPRESSION_N(srcLoc, expr, ...)
106 GBL_CTX_VERIFY_(expr, GBL_RESULT_ERROR_INVALID_EXPRESSION, srcLoc, __VA_ARGS__)
107
108#define GBL_CTX_VERIFY_EXPRESSION_2(src, expr)
109 GBL_CTX_VERIFY_EXPRESSION_N(src, expr, "Invalid Expression: "#expr)
110
111#define GBL_CTX_VERIFY_EXPRESSION(...)
116
117//====== VERIFY_POINTER =========
118#define GBL_CTX_VERIFY_POINTER_N(srcLoc, expr, ...)
119 GBL_CTX_VERIFY_(expr, GBL_RESULT_ERROR_INVALID_POINTER, srcLoc, __VA_ARGS__)
120
121#define GBL_CTX_VERIFY_POINTER_2(src, expr)
122 GBL_CTX_VERIFY_POINTER_N(src, expr, "Invalid Pointer")
123
124#define GBL_CTX_VERIFY_POINTER(...)
127 GBL_VA_OVERLOAD_SELECT(GBL_CTX_VERIFY_POINTER, GBL_VA_OVERLOAD_SUFFIXER_2_N, src_, __VA_ARGS__)(src_, __VA_ARGS__);
129
130//====== VERIFY_ARG =========
131#define GBL_CTX_VERIFY_ARG_N(srcLoc, expr, ...)
132 GBL_CTX_VERIFY_(expr, GBL_RESULT_ERROR_INVALID_ARG, srcLoc, __VA_ARGS__)
133
134#define GBL_CTX_VERIFY_ARG_2(src, expr)
135 GBL_CTX_VERIFY_ARG_N(src, expr, "Invalid Arg: "#expr);
136
137#define GBL_CTX_VERIFY_ARG(...)
140 GBL_VA_OVERLOAD_SELECT(GBL_CTX_VERIFY_ARG, GBL_VA_OVERLOAD_SUFFIXER_2_N, src_, __VA_ARGS__)(src_, __VA_ARGS__);
142
143//===== VERIFY_TYPE =======
144#define GBL_CTX_VERIFY_TYPE_N(srcLoc, actualType, expectedType, ...)
145 GBL_CTX_VERIFY_(GblType_check(actualType, expectedType), GBL_RESULT_ERROR_TYPE_MISMATCH, srcLoc, __VA_ARGS__)
146
147#define GBL_CTX_VERIFY_TYPE_3(srcLoc, actualType, expectedType)
148 GBL_CTX_VERIFY_TYPE_N(srcLoc, actualType, expectedType, "Type mismatch [Actual: %s, Expected: %s]", GblType_name(actualType), GblType_name(expectedType))
149
150#define GBL_CTX_VERIFY_TYPE_2(srcLoc, actualType)
151 GBL_CTX_VERIFY_(actualType != GBL_INVALID_TYPE, GBL_RESULT_ERROR_INVALID_TYPE, srcLoc, "Invalid Type");
152
153#define GBL_CTX_VERIFY_TYPE(...)
156 GBL_VA_OVERLOAD_SELECT(GBL_CTX_VERIFY_TYPE, GBL_VA_OVERLOAD_SUFFIXER_3_N, src_, __VA_ARGS__)(src_, __VA_ARGS__);
158
159//==== LAST RECORD =====
160#define GBL_CTX_VERIFY_LAST_RECORD()
162 const GblCallRecord* pRecord =
163 GblThd_callRecord(NULL);
164 if(pRecord && GBL_RESULT_ERROR(pRecord->result)) {
165 GBL_CTX_RESULT() = pRecord->result;
166 GBL_CTX_DONE();
167 }
169
170#define GBL_CTX_CLEAR_LAST_RECORD()
171 GblThd_setCallRecord(NULL, NULL)
172
173//===== C STD ERRNO =====
174
175#ifdef GBL_CONFIG_ERRNO_CHECKS
176#define GBL_CTX_ERRNO_CLEAR() errno = 0
177#else
178#define GBL_CTX_ERRNO_CLEAR()
179#endif
180
181#ifdef GBL_CONFIG_ERRNO_CHECKS
182# define GBL_CTX_PERROR(...)
183 GBL_STMT_START {
184 if(errno) GBL_UNLIKELY {
185 const GBL_RESULT code =
186 GBL_ERRNO_RESULT(errno);
187 GBL_CTX_VERIFY(
188 GBL_RESULT_SUCCESS(code),
189 code,
190 "ERRNO: %s", strerror(errno));
191 }
192 } GBL_STMT_END
193#else
194# define GBL_CTX_PERROR(...)
195#endif
196
197GBL_MAYBE_UNUSED GBL_INLINE GBL_RESULT GBL_ERRNO_RESULT(int ernum) {
198 switch(ernum) {
199 case 0: return GBL_RESULT_SUCCESS;
200 default: return GBL_RESULT_ERROR;
201 }
202}
203
204// ======= API ======
205#define GBL_CTX_INLINE_RETVAL() GBL_CTX_INLINE_RETURN_VALUE_NAME
206
207#define GBL_CTX_INLINE(MethodPrefix, ReturnType, ...)
208 GBL_INLINE ReturnType GBL_CTX_INLINE_##MethodPrefix##_(GBL_CTX_FRAME_DECLARE, ##__VA_ARGS__) {
209 ReturnType GBL_CTX_INLINE_RETURN_VALUE_NAME;
210
211#define GBL_CTX_INLINE_BEGIN(InitialRetValue)
212 GBL_CTX_INLINE_RETVAL() = InitialRetValue;
213
214
215#define GBL_CTX_INLINE_END()
216 goto GBL_CTX_END_LABEL;
217 GBL_CTX_END_LABEL: GBL_STMT_START {;} GBL_STMT_END;
218 }
219
220#define GBL_CTX_INLINE_RETURN()
221 return GBL_CTX_INLINE_RETVAL()
222
223
224#define GBL_CTX_INLINE_CALL_(MethodPrefix, srcLoc, ...)
225 GBL_CTX_INLINE_##MethodPrefix##_(GBL_CTX_FRAME() GBL_VA_ARGS(__VA_ARGS__))
226
227#define GBL_CTX_INLINE_CALL(MethodPrefix, ...)
229
230// ============== GBL EXT USERMETHODS ==========
231
232#define GBL_CTX_EXT(prefix, ...)
234 const GBL_RESULT localResult = GblContext_##prefix(GBL_CTX_CONTEXT(),
235 GBL_CTX_FRAME_NAME,
236 ##__VA_ARGS__);
237 GBL_ASSERT(!(GBL_CONFIG_ASSERT_ERROR_ENABLED &&
238 GBL_RESULT_ERROR(localResult)),
239 "Ext["#prefix"]: ERROR");
240 GBL_ASSERT(!(GBL_CONFIG_ASSERT_PARTIAL_ENABLED &&
241 GBL_RESULT_PARTIAL(localResult)),
242 "Ext["#prefix"]: ERROR");
243 GBL_UNUSED(localResult);
245
246
247GBL_MAYBE_UNUSED GBL_CTX_INLINE(MALLOC, void*, size_t size, size_t align, const char* pDebugStr) {
249 if(align == 0) {
250 align = GBL_ALIGNOF(GBL_MAX_ALIGN_T);
251 size = gblAlignedAllocSizeDefault(size);
252 }
253 GBL_ASSERT(size % align == 0);
254 GBL_CTX_EXT(memAlloc_, size, align, pDebugStr, &GBL_CTX_INLINE_RETVAL());
256 // modify/set return value based on result
258}
259
260#define GBL_CTX_MALLOC_4(src, size, align, dbgStr)
261 GBL_CTX_INLINE_CALL_(MALLOC, src, size, align, dbgStr)
262
263#define GBL_CTX_MALLOC_3(src, size, align)
264 GBL_CTX_MALLOC_4(src, size, align, GBL_NULL)
265
266#define GBL_CTX_MALLOC_2(src, size)
267 GBL_CTX_MALLOC_3(src, gblAlignedAllocSizeDefault(size), GBL_ALIGNOF(GBL_MAX_ALIGN_T))
268
269#define GBL_CTX_MALLOC(...)
271
272#define GBL_CTX_NEW_4(src, type, count, dbgStr)
273 (type*)GBL_CTX_INLINE_CALL_(MALLOC, src, gblAlignedAllocSizeDefault(sizeof(type)*count), 0, dbgStr)
274
275#define GBL_CTX_NEW_3(src, type, count)
276 GBL_CTX_NEW_4(src, type, count, GBL_NULL)
277
278#define GBL_CTX_NEW_2(src, type)
279 GBL_CTX_NEW_3(src, type, 1)
280
281#define GBL_CTX_NEW(...)
283
284GBL_MAYBE_UNUSED GBL_CTX_INLINE(REALLOC, void*, void* pData, size_t newSize, size_t newAlign) {
286
287 GBL_CTX_EXT(memRealloc_, pData, newSize, newAlign, &GBL_CTX_INLINE_RETVAL());
289 // modify/set return value based on result
291}
292
293#define GBL_CTX_REALLOC_4(src, pData, newSize, newAlign)
294 GBL_CTX_INLINE_CALL_(REALLOC, src, pData, newSize, newAlign)
295
296#define GBL_CTX_REALLOC_3(src, pData, newSize)
297 GBL_CTX_REALLOC_4(src, pData, newSize, 1)
298
299#define GBL_CTX_REALLOC(...)
301
302#define GBL_CTX_RENEW_5(src, ptr, type, count, dbgStr)
303 GBL_CTX_INLINE_CALL(REALLOC, src, ptr, sizeof(type)*count, dbgStr)
304
305#define GBL_CTX_RENEW_4(src, ptr, type, count)
306 GBL_CTX_RENEW_5(src, ptr, type, count, GBL_NULL)
307
308#define GBL_CTX_RENEW_3(src, ptr, type)
309 GBL_CTX_RENEW_4(src, ptr, type, 1)
310
311#define GBL_CTX_RENEW(...)
313
314#define GBL_CTX_FREE(pData)
316
317#define GBL_CTX_PUSH_(srcLoc, ...)
320 GblThd_logPush(NULL);
321 GBL_CTX_EXT(logPush_);
323 ++GBL_CTX_FRAME()->stackDepth;
325
326#define GBL_CTX_PUSH()
329 GBL_CTX_PUSH_(src_);
331
332#define GBL_CTX_PUSH_VERBOSE_N(srcLoc, pFmt, ...)
334 GBL_CTX_SOURCE_SCOPED(GBL_CTX_VERBOSE, srcLoc, pFmt, ##__VA_ARGS__);
335 GBL_CTX_PUSH_(srcLoc);
337
338#define GBL_CTX_PUSH_VERBOSE(...)
341 GBL_VA_OVERLOAD_SELECT(GBL_CTX_PUSH_VERBOSE, GBL_VA_OVERLOAD_SUFFIXER_1_N, src_, ##__VA_ARGS__)(src_, ##__VA_ARGS__);
343
344#define GBL_CTX_POP_2(srcLoc, count)
345 GblThd_logPop(NULL, count);
346 GBL_CTX_SOURCE_SCOPED(GBL_CTX_EXT, srcLoc, logPop_, count);
347 GBL_CTX_FRAME()->stackDepth -= count;
348
349#define GBL_CTX_POP_1(srcLoc)
350 GBL_CTX_POP_2(srcLoc, 1)
351
352#define GBL_CTX_POP(...)
357
358GBL_MAYBE_UNUSED GBL_CTX_INLINE(LOG, GBL_RESULT, GblFlags level, const char* pFmt, ...) {
359 GBL_CTX_INLINE_BEGIN(GBL_RESULT_SUCCESS);
360 va_list varArgs;
361 va_start(varArgs, pFmt);
362
363 GBL_CTX_EXT(logWrite_, level, pFmt, varArgs);
364 va_end(varArgs);
367}
368
369#define GBL_CTX_LOG_(src, level, pFmt, ...)
370 GBL_CTX_INLINE_CALL_(LOG, src, level, pFmt, ##__VA_ARGS__)
371#define GBL_CTX_LOG(level, pFmt, ...)
372 GBL_CTX_LOG_(GBL_SRC_LOC(GBL_SRC_FILE, GBL_SRC_FN, GBL_SRC_LN), level, pFmt, ##__VA_ARGS__)
373
374#define GBL_CTX_DEBUG(pFmt, ...)
375 GBL_CTX_LOG_(GBL_SRC_LOC(GBL_SRC_FILE, GBL_SRC_FN, GBL_SRC_LN), GBL_LOG_LEVEL_DEBUG, pFmt, ##__VA_ARGS__)
376
377#define GBL_CTX_VERBOSE(pFmt, ...)
378 GBL_CTX_LOG_(GBL_SRC_LOC(GBL_SRC_FILE, GBL_SRC_FN, GBL_SRC_LN), GBL_LOG_LEVEL_VERBOSE, pFmt, ##__VA_ARGS__)
379
380#define GBL_CTX_INFO(pFmt, ...)
381 GBL_CTX_LOG_(GBL_SRC_LOC(GBL_SRC_FILE, GBL_SRC_FN, GBL_SRC_LN), GBL_LOG_LEVEL_INFO, pFmt, ##__VA_ARGS__)
382
383#define GBL_CTX_WARN(pFmt, ...)
384 GBL_CTX_LOG_(GBL_SRC_LOC(GBL_SRC_FILE, GBL_SRC_FN, GBL_SRC_LN), GBL_LOG_LEVEL_WARNING, pFmt, ##__VA_ARGS__)
385
386#define GBL_CTX_ERROR(pFmt, ...)
387 GBL_CTX_LOG_(GBL_SRC_LOC(GBL_SRC_FILE, GBL_SRC_FN, GBL_SRC_LN), GBL_LOG_LEVEL_ERROR, pFmt, ##__VA_ARGS__)
388
389#define GBL_CTX_EVENT(event)
392 GBL_UNUSED(src_);
393 GblObject_sendEvent(GBL_CTX_OBJECT(), (GblEvent*)event);
395
396
397// ===================== RECORD = > ASSERT =========================
398
399// Base Enabled Logic
400#define GBL_CTX_RECORD_ASSERT_(record, test)
402 GBL_ASSERT(!test(record->result), record->message);
404
405// Base Conditional Logic
406#define GBL_CTX_RECORD_ASSERT_CONDITIONAL_(enabled, record, test)
408
409// Partial Success
410#define GBL_CTX_RECORD_ASSERT_PARTIAL(record)
411 GBL_CTX_RECORD_ASSERT_CONDITIONAL_(GBL_CONFIG_ASSERT_PARTIAL_ENABLED,
412 record, GBL_RESULT_PARTIAL)
413// Error
414#define GBL_CTX_RECORD_ASSERT_ERROR(record)
415 GBL_CTX_RECORD_ASSERT_CONDITIONAL_(GBL_CONFIG_ASSERT_ERROR_ENABLED,
416 record, GBL_RESULT_ERROR)
417
418// Unknown
419#define GBL_CTX_RECORD_ASSERT_UNKNOWN(record)
420 GBL_CTX_RECORD_ASSERT_CONDITIONAL_(GBL_CONFIG_ASSERT_UNKNOWN_ENABLED,
421 record, GBL_RESULT_UNKNOWN)
422// Both Together
423#define GBL_CTX_RECORD_ASSERT(record)
429
430
431// ========================== RECORD = > LOG ========================
432
433// Base Enabled Logic (uses a prefix prefix for all magic)
434#define GBL_CTX_RECORD_LOG_(prefix, record)
436 if(GBL_RESULT_##prefix(record->result)) GBL_UNLIKELY {
437 GBL_CTX_LOG(GBL_CONFIG_LOG_##prefix##_LEVEL,
438 "%s: %s",
439 gblResultString(record->result), record->message);
440 }
442
443
444// Base Conditional Logic
445#define GBL_CTX_RECORD_LOG_CONDITIONAL_(prefix, record)
446 GBL_MACRO_CONDITIONAL_CALL(GBL_CONFIG_LOG_##prefix##_ENABLED,
447 GBL_CTX_RECORD_LOG_, prefix, record)
448
449// Partial Success
450#define GBL_CTX_RECORD_LOG_PARTIAL(record)
451 GBL_CTX_RECORD_LOG_CONDITIONAL_(PARTIAL, record)
452
453// Error
454#define GBL_CTX_RECORD_LOG_ERROR(record)
456
457// Unknown
458#define GBL_CTX_RECORD_LOG_UNKNOWN(record)
459 GBL_CTX_RECORD_LOG_CONDITIONAL_(UNKNOWN, record)
460
461// Combined
462#define GBL_CTX_RECORD_LOG(record)
468
469
470// ================= RECORD => HANDLE::LAST_ERROR ==============
471#define GBL_CTX_RECORD_LAST_RECORD_(prefix, record)
473 if(GBL_RESULT_##prefix(record->result)) {
474 GblContext_callRecordSet_(GBL_CTX_CONTEXT(), GBL_CTX_FRAME_NAME, record);
475 GblThd_setCallRecord(NULL, record);
476 }
478
479#define GBL_CTX_RECORD_LAST_RECORD_PARTIAL(record)
480 GBL_CTX_RECORD_LAST_RECORD_(PARTIAL, record)
481
482#define GBL_CTX_RECORD_LAST_RECORD_ERROR(record)
483 GBL_CTX_RECORD_LAST_RECORD_(ERROR, record)
484
485#define GBL_CTX_RECORD_LAST_RECORD_UNKNOWN(record)
486 GBL_CTX_RECORD_LAST_RECORD_(UNKNOWN, record)
487
488#define GBL_CTX_RECORD_LAST_RECORD(record)
494
495// ================= RECORD => TOP-LEVEL DISPATCH ==============
496#define GBL_CTX_RECORD_HANDLER(record)
498 GBL_CTX_RECORD_LOG((record));
500 GBL_CTX_RECORD_ASSERT((record));
502
503#define GBL_CTX_RECORD_SET_N(file, func, line, result, ...)
506 GblCallRecord_construct(&GBL_CTX_RECORD(), result, GBL_CTX_SOURCE(), __VA_ARGS__);
510
511#define GBL_CTX_RECORD_SET_5(file, func, line, result, pFmt)
512 GBL_CTX_RECORD_SET_N(file, func, line, result, "%s", pFmt)
513
514#define GBL_CTX_RECORD_SET_4(file, func, line, result)
515 GBL_CTX_RECORD_SET_5(file, func, line, result, gblResultString(result))
516
517#define GBL_CTX_RECORD_SET(...)
519
520#define GBL_CTX_CALL_N(src, funcCall, ...)
523 GBL_MAYBE_UNUSED const GBL_RESULT localResult = (funcCall);
524 if(!GBL_RESULT_SUCCESS(localResult)) GBL_UNLIKELY {
525 GBL_CTX_RESULT() = localResult;
526 }
529
530#define GBL_CTX_CALL_2(src, funcCall)
531 GBL_CTX_CALL_N(src, funcCall, #funcCall);
532
533#define GBL_CTX_CALL(...)
536 GBL_VA_OVERLOAD_SELECT(GBL_CTX_CALL, GBL_VA_OVERLOAD_SUFFIXER_2_N, src_, __VA_ARGS__)(src_, __VA_ARGS__);
538
539#define GBL_CTX_VERIFY_CALL(...)
542 GBL_VA_OVERLOAD_SELECT(GBL_CTX_CALL, GBL_VA_OVERLOAD_SUFFIXER_2_N, src_, __VA_ARGS__)(src_, __VA_ARGS__);
543 if(!GBL_RESULT_SUCCESS(GBL_CTX_RESULT())) goto GBL_CTX_END_LABEL;
545
546
547// ================= TOP-LEVEL API UTILITIES ==============
548
549#define GBL_CTX_BEGIN_FRAME(file, func, line, pObject, frame)
550 GBL_CTX_FRAME_DECLARE = frame;
551 GblStackFrame_construct(GBL_CTX_FRAME_NAME, (GblObject*)pObject, GBL_RESULT_SUCCESS);
552 GblThd_stackFramePush(NULL, GBL_CTX_FRAME_NAME)
553
554#define GBL_CTX_BEGIN_LOG_4(file, func, line, hHandle)
555 GBL_CTX_BEGIN_FRAME(file, func, line, hHandle, ((GblStackFrame*)GBL_ALLOCA(sizeof(GblStackFrame))))
556
557#define GBL_CTX_BEGIN_LOG_N(file, func, line, hHandle, ...)
558 GBL_CTX_BEGIN_LOG_5(file, func, line, hHandle);
559 GBL_CTX_PUSH_VERBOSE(__VA_ARGS__);
560
561#define GBL_CTX_BEGIN(...)
563
564#define GBL_CTX_DONE()
565 goto GBL_CTX_END_LABEL
566
567#define GBL_CTX_END_BLOCK()
568 goto GBL_CTX_END_LABEL;
569 GBL_LABEL_EMPTY(GBL_CTX_END_LABEL);
570 if(GBL_CTX_FRAME_NAME->stackDepth)
571 GBL_CTX_POP(GBL_CTX_FRAME_NAME->stackDepth);
572 GblThd_stackFramePop(NULL)
573
574#define GBL_CTX_END()
576 return GBL_CTX_FRAME_NAME->record.result
577
578#define GBL_CTX_END_EMPTY()
579 GBL_LABEL_EMPTY(GBL_CTX_END_LABEL)
580
581#define GBL_CTX_BLOCK_6(file, func, line, hHandle, frame, block)
582 GBL_CTX_BEGIN_FRAME(file, func, line, hHandle, frame);
583 block;
585
586#define GBL_CTX_BLOCK_5(file, func, line, hHandle, block)
587 GBL_CTX_BLOCK_7(file, func, line, hHandle, ((GblStackFrame*)GBL_ALLOCA(sizeof(GblStackFrame))), block)
588
589#define GBL_CTX_BLOCK_4(file, func, line, block)
590 GBL_CTX_BLOCK_6(file, func, line, NULL, block)
591
592#define GBL_CTX_BLOCK(...)
594
596
597#endif // GIMBAL_API_H
#define GBL_MAX_ALIGN_T
#define GBL_STMT_START
#define GBL_NULL
#define GBL_LIKELY
#define GBL_MAYBE_UNUSED
#define GBL_STRUCT_INIT(type,...)
#define GBL_UNLIKELY
#define GBL_ALLOCA
#define GBL_INLINE
#define GBL_STMT_END
#define GBL_CTX_RECORD_LAST_RECORD_(prefix, record)
Definition gimbal_ctx.h:471
#define GBL_CTX_NEW(...)
Definition gimbal_ctx.h:281
#define GBL_CTX_INLINE_RETURN()
Definition gimbal_ctx.h:220
#define GBL_CTX_SOURCE()
Definition gimbal_ctx.h:27
#define GBL_CTX_RECORD_LOG_CONDITIONAL_(prefix, record)
Definition gimbal_ctx.h:445
#define GBL_SRC_FN
Definition gimbal_ctx.h:34
#define GBL_CTX_BLOCK_6(file, func, line, hHandle, frame, block)
Definition gimbal_ctx.h:581
#define GBL_CTX_INLINE_CALL(MethodPrefix,...)
Definition gimbal_ctx.h:227
#define GBL_CTX_VERIFY_ARG(...)
Definition gimbal_ctx.h:137
#define GBL_CTX_VERIFY_POINTER(...)
Definition gimbal_ctx.h:124
#define GBL_CTX_RENEW_4(src, ptr, type, count)
Definition gimbal_ctx.h:305
#define GBL_CTX_VERIFY_(expr, result, srcLoc,...)
Definition gimbal_ctx.h:85
#define GBL_CTX_RECORD_ASSERT_PARTIAL(record)
Definition gimbal_ctx.h:410
#define GBL_CTX_RECORD_SET_JMP_CND_(expr, result, label, srcLoc,...)
Definition gimbal_ctx.h:68
#define GBL_SRC_LOC
Definition gimbal_ctx.h:36
#define GBL_CTX_VERIFY_POINTER_N(srcLoc, expr,...)
Definition gimbal_ctx.h:118
#define GBL_CTX_RESULT()
Definition gimbal_ctx.h:26
#define GBL_CTX_POP(...)
Definition gimbal_ctx.h:352
#define GBL_CTX_SOURCE_LOC_PUSH(srcLoc)
Definition gimbal_ctx.h:50
#define GBL_CTX_END_BLOCK()
Definition gimbal_ctx.h:567
#define GBL_CTX_SOURCE_POP()
Definition gimbal_ctx.h:56
#define GBL_CTX_LAST_RECORD()
Definition gimbal_ctx.h:28
#define GBL_CTX_BEGIN_FRAME(file, func, line, pObject, frame)
Definition gimbal_ctx.h:549
#define GBL_CTX_PUSH_VERBOSE(...)
Definition gimbal_ctx.h:338
#define GBL_CTX_RECORD_ASSERT_UNKNOWN(record)
Definition gimbal_ctx.h:419
#define GBL_CTX_SOURCE_SCOPED(CALL, loc,...)
Definition gimbal_ctx.h:59
#define GBL_CTX_RECORD_LOG_(prefix, record)
Definition gimbal_ctx.h:434
#define GBL_CTX_STACK_FRAME_SOURCE_PUSH(pStackFrame, current)
Definition gimbal_ctx.h:41
#define GBL_CTX_CALL(...)
Definition gimbal_ctx.h:533
#define GBL_CTX_RECORD_ASSERT(record)
Definition gimbal_ctx.h:423
#define GBL_CTX_RECORD_SET_N(file, func, line, result,...)
Definition gimbal_ctx.h:503
#define GBL_CTX_FRAME_DECLARE
Definition gimbal_ctx.h:21
#define GBL_CTX_INLINE(MethodPrefix, ReturnType,...)
Definition gimbal_ctx.h:207
#define GBL_CTX_RECORD_LOG(record)
Definition gimbal_ctx.h:462
#define GBL_CTX_RECORD_ASSERT_(record, test)
Definition gimbal_ctx.h:400
#define GBL_CTX_RECORD_LAST_RECORD_UNKNOWN(record)
Definition gimbal_ctx.h:485
#define GBL_CTX_FRAME()
Definition gimbal_ctx.h:22
#define GBL_CTX_RECORD_LAST_RECORD_ERROR(record)
Definition gimbal_ctx.h:482
#define GBL_CTX_VERIFY_TYPE(...)
Definition gimbal_ctx.h:153
#define GBL_CTX_POP_2(srcLoc, count)
Definition gimbal_ctx.h:344
#define GBL_CTX_VERBOSE(pFmt,...)
Definition gimbal_ctx.h:377
#define GBL_CTX_VERIFY_ARG_N(srcLoc, expr,...)
Definition gimbal_ctx.h:131
#define GBL_CTX_VERIFY_N(srcLoc, expr, result,...)
Definition gimbal_ctx.h:91
#define GBL_SOURCE_LOCATION(FILE, FUNCTION, LINE)
Definition gimbal_ctx.h:39
#define GBL_CTX_EXT(prefix,...)
Definition gimbal_ctx.h:232
#define GBL_CTX_VERIFY_TYPE_N(srcLoc, actualType, expectedType,...)
Definition gimbal_ctx.h:144
#define GBL_CTX_INLINE_END()
Definition gimbal_ctx.h:215
#define GBL_CTX_RECORD_LAST_RECORD_PARTIAL(record)
Definition gimbal_ctx.h:479
#define GBL_CTX_RECORD_LAST_RECORD(record)
Definition gimbal_ctx.h:488
#define GBL_CTX_STACK_FRAME_SOURCE_POP(pStackFrame)
Definition gimbal_ctx.h:44
#define GBL_CTX_REALLOC_4(src, pData, newSize, newAlign)
Definition gimbal_ctx.h:293
#define GBL_CTX_NEW_4(src, type, count, dbgStr)
Definition gimbal_ctx.h:272
#define GBL_CTX_BLOCK(...)
Definition gimbal_ctx.h:592
#define GBL_CTX_RECORD_HANDLER(record)
Definition gimbal_ctx.h:496
#define GBL_CTX_RECORD_LOG_PARTIAL(record)
Definition gimbal_ctx.h:450
#define GBL_CTX_RECORD()
Definition gimbal_ctx.h:25
#define GBL_CTX_PUSH_(srcLoc,...)
Definition gimbal_ctx.h:317
#define GBL_CTX_RECORD_SET(...)
Definition gimbal_ctx.h:517
#define GBL_CTX_CALL_N(src, funcCall,...)
Definition gimbal_ctx.h:520
#define GBL_CTX_INLINE_BEGIN(InitialRetValue)
Definition gimbal_ctx.h:211
#define GBL_CTX_RECORD_ASSERT_ERROR(record)
Definition gimbal_ctx.h:414
#define GBL_CTX_DONE()
Definition gimbal_ctx.h:564
#define GBL_CTX_VERIFY_EXPRESSION(...)
Definition gimbal_ctx.h:111
#define GBL_CTX_RECORD_LOG_ERROR(record)
Definition gimbal_ctx.h:454
#define GBL_CTX_MALLOC_3(src, size, align)
Definition gimbal_ctx.h:263
#define GBL_CTX_INLINE_CALL_(MethodPrefix, srcLoc,...)
Definition gimbal_ctx.h:224
#define GBL_CTX_LOG_(src, level, pFmt,...)
Definition gimbal_ctx.h:369
#define GBL_CTX_MALLOC_4(src, size, align, dbgStr)
Definition gimbal_ctx.h:260
#define GBL_SRC_LN
Definition gimbal_ctx.h:35
#define GBL_CTX_VERIFY(...)
Definition gimbal_ctx.h:97
#define GBL_CTX_NEW_3(src, type, count)
Definition gimbal_ctx.h:275
#define GBL_CTX_MALLOC(...)
Definition gimbal_ctx.h:269
#define GBL_CTX_REALLOC(...)
Definition gimbal_ctx.h:299
#define GBL_SRC_FILE
Definition gimbal_ctx.h:33
#define GBL_CTX_VERIFY_EXPRESSION_N(srcLoc, expr,...)
Definition gimbal_ctx.h:105
#define GBL_CTX_RENEW_5(src, ptr, type, count, dbgStr)
Definition gimbal_ctx.h:302
#define GBL_CTX_LOG(level, pFmt,...)
Definition gimbal_ctx.h:371
#define GBL_CTX_CONTEXT()
Definition gimbal_ctx.h:23
#define GblSrcLoc
Definition gimbal_ctx.h:37
#define GBL_CTX_INLINE_RETVAL()
Definition gimbal_ctx.h:205
#define GBL_CTX_RECORD_ASSERT_CONDITIONAL_(enabled, record, test)
Definition gimbal_ctx.h:406
#define GBL_CTX_RECORD_SET_5(file, func, line, result, pFmt)
Definition gimbal_ctx.h:511
#define GBL_CTX_RECORD_LOG_UNKNOWN(record)
Definition gimbal_ctx.h:458
#define GBL_CTX_OBJECT()
Definition gimbal_ctx.h:24
#define GBL_DECLS_BEGIN
#define GBL_UNUSED(...)
#define GBL_VA_OVERLOAD_CALL(BASE, SUFFIXER,...)
#define GBL_IDENTITY(A)
#define GBL_VA_OVERLOAD_SELECT(BASE, SUFFIXER,...)
#define GBL_VA_OVERLOAD_SUFFIXER_5_N(...)
#define GBL_MACRO_CONDITIONAL_CALL(enabled,...)
#define GBL_VA_OVERLOAD_SUFFIXER_3_N(...)
#define GBL_VA_OVERLOAD_SUFFIXER_4_N(...)
#define GBL_VA_OVERLOAD_SUFFIXER_1_N(...)
#define GBL_VA_OVERLOAD_SUFFIXER_2_N(...)
#define GBL_VA_OVERLOAD_SUFFIXER_ARGC(...)
#define GBL_VA_ARGS(...)
#define GBL_ASSERT(...)
#define GBL_LABEL_EMPTY(name)
#define GBL_RESULT_PARTIAL(value)
#define GBL_RESULT_ERROR(value)
#define GBL_RESULT_SUCCESS(value)
#define GBL_RESULT_UNKNOWN(value)
#define GBL_INVALID_TYPE
GblType UUID of the invalid type.
Definition gimbal_type.h:31
uint32_t GblFlags
Standard-sized flags type, 32-bits across platforms.