GL CHOCO ENGINE
Loading...
Searching...
No Matches
choco_macros.h
Go to the documentation of this file.
1
16#ifndef GLCE_ENGINE_BASE_CHOCO_MACROS_H
17#define GLCE_ENGINE_BASE_CHOCO_MACROS_H
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23#include <stddef.h>
24
25#include "choco_message.h"
26
27#ifdef __clang__
32 #define NO_COVERAGE __attribute__((no_profile_instrument_function))
33#else
34 #define NO_COVERAGE
35#endif
36
41#define KIB ((size_t)(1ULL << 10))
42
47#define MIB ((size_t)(1ULL << 20))
48
53#define GIB ((size_t)(1ULL << 30))
54
61#define IS_POWER_OF_TWO(val_) ( ((size_t)(val_) != 0u) && ( (((size_t)(val_) & ((size_t)(val_) - 1u)) == 0u)))
62
86#define IF_ARG_NULL_GOTO_CLEANUP(ptr_, return_variable_, rslt_code_, rslt_str_, function_name_, variable_name_) \
87 do { \
88 if(NULL == ptr_) { \
89 ERROR_MESSAGE("%s(%s) - Argument %s requires a valid pointer.", function_name_, rslt_str_, variable_name_); \
90 return_variable_ = rslt_code_; \
91 goto cleanup; \
92 } \
93 } while(0); \
94
118#define IF_ARG_NOT_NULL_GOTO_CLEANUP(ptr_, return_variable_, rslt_code_, rslt_str_, function_name_, variable_name_) \
119 do { \
120 if(NULL != ptr_) { \
121 ERROR_MESSAGE("%s(%s) - Argument %s requires a null pointer.", function_name_, rslt_str_, variable_name_); \
122 return_variable_ = rslt_code_; \
123 goto cleanup; \
124 } \
125 } while(0); \
126
151#define IF_ALLOC_FAIL_GOTO_CLEANUP(ptr_, return_variable_, rslt_code_, function_name_, variable_name_) \
152 do { \
153 if(NULL == ptr_) { \
154 ERROR_MESSAGE("%s(NO_MEMORY) - Failed to allocate %s memory.", function_name_, variable_name_); \
155 return_variable_ = rslt_code_; \
156 goto cleanup; \
157 } \
158 } while(0); \
159
183#define IF_ARG_FALSE_GOTO_CLEANUP(is_valid_, return_variable_, rslt_code_, rslt_str_, function_name_, variable_name_) \
184 do { \
185 if(!(is_valid_)) { \
186 ERROR_MESSAGE("%s(%s) - Argument %s is not valid.", function_name_, rslt_str_, variable_name_); \
187 return_variable_ = rslt_code_; \
188 goto cleanup; \
189 } \
190 } while(0); \
191
192#ifdef __cplusplus
193}
194#endif
195#endif
stdout, stderrへの色付きメッセージ出力機能APIの定義