LCOV - code coverage report
Current view: top level - acl/common - log_inner.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 1 1
Test Date: 2026-07-28 10:53:01 Functions: 100.0 % 1 1

            Line data    Source code
       1              : /**
       2              :  * Copyright (c) 2025 Huawei Technologies Co., Ltd.
       3              :  * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
       4              :  * CANN Open Software License Agreement Version 2.0 (the "License").
       5              :  * Please refer to the License for details. You may not use this file except in compliance with the License.
       6              :  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
       7              :  * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
       8              :  * See LICENSE in the root of the software repository for the full text of the License.
       9              :  */
      10              : 
      11              : #ifndef ACL_COMMON_LOG_INNER_H_
      12              : #define ACL_COMMON_LOG_INNER_H_
      13              : 
      14              : #include <string>
      15              : #include <vector>
      16              : #include "dlog_pub.h"
      17              : #include "mmpa/mmpa_api.h"
      18              : #include "acl/acl_base.h"
      19              : #include "common/error_codes_inner.h"
      20              : 
      21              : #ifndef char_t
      22              : using char_t = char;
      23              : #endif
      24              : 
      25              : #ifndef float32_t
      26              : using float32_t = float;
      27              : #endif
      28              : 
      29              : namespace acl {
      30              : constexpr int32_t ACL_MODE_ID = static_cast<int32_t>(ASCENDCL);
      31              : constexpr int32_t APP_MODE_ID = static_cast<int32_t>(APP);
      32              : constexpr uint16_t ACL_MODE_ID_U16 = static_cast<uint16_t>(ASCENDCL);
      33              : constexpr uint16_t APP_MODE_ID_U16 = static_cast<uint16_t>(APP);
      34              : constexpr const char_t* const ACL_MODULE_NAME = "ASCENDCL";
      35              : constexpr const char_t* const INVALID_PARAM_MSG = "EH0001";
      36              : constexpr const char_t* const INVALID_NULL_POINTER_MSG = "EH0002";
      37              : constexpr const char_t* const INVALID_PATH_MSG = "EH0003";
      38              : constexpr const char_t* const INVALID_FILE_MSG = "EH0004";
      39              : constexpr const char_t* const INVALID_AIPP_MSG = "EH0005";
      40              : constexpr const char_t* const UNSUPPORTED_FEATURE_MSG = "EH0006";
      41              : constexpr const char_t* const INVALID_VALUE_MSG = "EH0007";
      42              : constexpr const char_t* const NULL_POINTER_FUNC_MSG = "EH0008";
      43              : constexpr const char_t* const INVALID_PARAM_REASON_MSG = "EH0009";
      44              : constexpr const char_t* const ALLOC_MEMORY_FAILED_MSG = "EH0010";
      45              : constexpr const char_t* const UNSUPPORTED_SYSTEM_MSG = "EH0011";
      46              : constexpr const char_t* const INVALID_PARAM_NO_VALUE_MSG = "EH0012";
      47              : constexpr const char_t* const STANDARD_FUNC_FAILED_MSG = "EH0013";
      48              : constexpr const char_t* const INVALID_NULL_POINTER_AT_SAME_TIME_MSG = "EH0014";
      49              : 
      50              : // first stage
      51              : constexpr const char_t* const ACL_STAGE_SET = "SET";
      52              : constexpr const char_t* const ACL_STAGE_GET = "GET";
      53              : constexpr const char_t* const ACL_STAGE_CREATE = "CREATE";
      54              : constexpr const char_t* const ACL_STAGE_DESTROY = "DESTROY";
      55              : constexpr const char_t* const ACL_STAGE_BLAS = "BLAS";
      56              : constexpr const char_t* const ACL_STAGE_INFER = "INFER";
      57              : constexpr const char_t* const ACL_STAGE_COMP = "COMP";
      58              : constexpr const char_t* const ACL_STAGE_LOAD = "LOAD";
      59              : constexpr const char_t* const ACL_STAGE_UNLOAD = "UNLOAD";
      60              : constexpr const char_t* const ACL_STAGE_EXEC = "EXEC";
      61              : constexpr const char_t* const ACL_STAGE_COMP_AND_EXEC = "COMP_AND_EXEC";
      62              : constexpr const char_t* const ACL_STAGE_DUMP = "DUMP";
      63              : constexpr const char_t* const ACL_STAGE_DVPP = "DVPP";
      64              : constexpr const char_t* const ACL_STAGE_TDT = "TDT";
      65              : constexpr const char_t* const ACL_STAGE_INIT = "INIT";
      66              : constexpr const char_t* const ACL_STAGE_FINAL = "FINAL";
      67              : constexpr const char_t* const ACL_STAGE_QUEUE = "QUEUE";
      68              : constexpr const char_t* const ACL_STAGE_MBUF = "MBUF";
      69              : // second stage
      70              : constexpr const char_t* const ACL_STAGE_DEFAULT = "DEFAULT";
      71              : 
      72              : constexpr size_t MAX_LOG_STRING = 1024U;
      73              : 
      74              : constexpr size_t MAX_ERROR_STRING = 128U;
      75              : 
      76         6786 : inline const char_t* format_cast(const char_t* const src) { return static_cast<const char_t*>(src); }
      77              : 
      78              : ACL_FUNC_VISIBILITY std::string AclGetErrorFormatMessage(const mmErrorMsg errnum);
      79              : 
      80              : class ACL_FUNC_VISIBILITY AclLog {
      81              : public:
      82              :     static bool IsLogOutputEnable(const aclLogLevel logLevel);
      83              :     static mmPid_t GetTid();
      84              :     static void ACLSaveLog(const aclLogLevel logLevel, const char_t* const strLog);
      85              :     static bool IsEventLogOutputEnable();
      86              : 
      87              : private:
      88              :     static aclLogLevel GetCurLogLevel();
      89              :     static bool isEnableEvent_;
      90              : };
      91              : 
      92              : class ACL_FUNC_VISIBILITY AclErrorLogManager {
      93              : public:
      94              :     static std::string FormatStr(const char_t* const fmt, ...);
      95              : #if !defined(ENABLE_DVPP_INTERFACE) || defined(RUN_TEST)
      96              :     static void ReportInputError(
      97              :         const char* errorCode, const std::vector<const char*>& key = {}, const std::vector<const char*>& val = {});
      98              : #else
      99              : #endif
     100              :     static void ReportInputErrorWithChar(
     101              :         const char_t* const errorCode, const char_t* const argNames[], const char_t* const argVals[],
     102              :         const size_t size);
     103              :     static void ReportInnerError(const char_t* const fmt, ...);
     104              :     static void ReportCallError(const char_t* const fmt, ...);
     105              :     static std::string GetFuncNameWithoutImplSuffix(const char_t* funcName);
     106              : };
     107              : } // namespace acl
     108              : 
     109              : #define UNLIKELY(expr) (expr)
     110              : 
     111              : #ifdef RUN_TEST
     112              : #define ACL_LOG_INFO(fmt, ...)                                                                                         \
     113              :     do {                                                                                                               \
     114              :         if (acl::AclLog::IsLogOutputEnable(ACL_INFO)) {                                                                \
     115              :             constexpr const char_t* const funcName = __FUNCTION__;                                                     \
     116              :             printf(                                                                                                    \
     117              :                 "INFO %d %s:%s:%d: " #fmt "\n", acl::AclLog::GetTid(), acl::format_cast(funcName), __FILE__, __LINE__, \
     118              :                 ##__VA_ARGS__);                                                                                        \
     119              :         }                                                                                                              \
     120              :     } while (false)
     121              : #define ACL_LOG_DEBUG(fmt, ...)                                                                               \
     122              :     do {                                                                                                      \
     123              :         if (acl::AclLog::IsLogOutputEnable(ACL_DEBUG)) {                                                      \
     124              :             constexpr const char_t* const funcName = __FUNCTION__;                                            \
     125              :             printf(                                                                                           \
     126              :                 "DEBUG %d %s:%s:%d: " #fmt "\n", acl::AclLog::GetTid(), acl::format_cast(funcName), __FILE__, \
     127              :                 __LINE__, ##__VA_ARGS__);                                                                     \
     128              :         }                                                                                                     \
     129              :     } while (false)
     130              : #define ACL_LOG_WARN(fmt, ...)                                                                                         \
     131              :     do {                                                                                                               \
     132              :         if (acl::AclLog::IsLogOutputEnable(ACL_WARNING)) {                                                             \
     133              :             constexpr const char_t* const funcName = __FUNCTION__;                                                     \
     134              :             printf(                                                                                                    \
     135              :                 "WARN %d %s:%s:%d: " #fmt "\n", acl::AclLog::GetTid(), acl::format_cast(funcName), __FILE__, __LINE__, \
     136              :                 ##__VA_ARGS__);                                                                                        \
     137              :         }                                                                                                              \
     138              :     } while (false)
     139              : #define ACL_LOG_ERROR(fmt, ...)                                                                                   \
     140              :     do {                                                                                                          \
     141              :         constexpr const char_t* const funcName = __FUNCTION__;                                                    \
     142              :         printf(                                                                                                   \
     143              :             "ERROR %d %s:%s:%d:" fmt "\n", acl::AclLog::GetTid(), acl::format_cast(funcName), __FILE__, __LINE__, \
     144              :             ##__VA_ARGS__);                                                                                       \
     145              :     } while (false)
     146              : #define ACL_LOG_INNER_ERROR(fmt, ...)                                                                             \
     147              :     do {                                                                                                          \
     148              :         constexpr const char_t* const funcName = __FUNCTION__;                                                    \
     149              :         printf(                                                                                                   \
     150              :             "ERROR %d %s:%s:%d:" fmt "\n", acl::AclLog::GetTid(), acl::format_cast(funcName), __FILE__, __LINE__, \
     151              :             ##__VA_ARGS__);                                                                                       \
     152              :     } while (false)
     153              : #define ACL_LOG_CALL_ERROR(fmt, ...)                                                                              \
     154              :     do {                                                                                                          \
     155              :         constexpr const char_t* const funcName = __FUNCTION__;                                                    \
     156              :         printf(                                                                                                   \
     157              :             "ERROR %d %s:%s:%d:" fmt "\n", acl::AclLog::GetTid(), acl::format_cast(funcName), __FILE__, __LINE__, \
     158              :             ##__VA_ARGS__);                                                                                       \
     159              :     } while (false)
     160              : #define ACL_LOG_EVENT(fmt, ...)                                                                               \
     161              :     do {                                                                                                      \
     162              :         if (acl::AclLog::IsEventLogOutputEnable()) {                                                          \
     163              :             constexpr const char_t* const funcName = __FUNCTION__;                                            \
     164              :             printf(                                                                                           \
     165              :                 "EVENT %d %s:%s:%d: " #fmt "\n", acl::AclLog::GetTid(), acl::format_cast(funcName), __FILE__, \
     166              :                 __LINE__, ##__VA_ARGS__);                                                                     \
     167              :         }                                                                                                     \
     168              :     } while (false)
     169              : #else
     170              : #define ACL_LOG_INFO(fmt, ...)                                                                                        \
     171              :     do {                                                                                                              \
     172              :         constexpr const char_t* const funcName = __FUNCTION__;                                                        \
     173              :         dlog_info(acl::ACL_MODE_ID, "%d %s: " fmt, acl::AclLog::GetTid(), acl::format_cast(funcName), ##__VA_ARGS__); \
     174              :     } while (false)
     175              : #define ACL_LOG_DEBUG(fmt, ...)                                                                                        \
     176              :     do {                                                                                                               \
     177              :         constexpr const char_t* const funcName = __FUNCTION__;                                                         \
     178              :         dlog_debug(acl::ACL_MODE_ID, "%d %s: " fmt, acl::AclLog::GetTid(), acl::format_cast(funcName), ##__VA_ARGS__); \
     179              :     } while (false)
     180              : #define ACL_LOG_WARN(fmt, ...)                                                                                        \
     181              :     do {                                                                                                              \
     182              :         constexpr const char_t* const funcName = __FUNCTION__;                                                        \
     183              :         dlog_warn(acl::ACL_MODE_ID, "%d %s: " fmt, acl::AclLog::GetTid(), acl::format_cast(funcName), ##__VA_ARGS__); \
     184              :     } while (false)
     185              : #define ACL_LOG_ERROR(fmt, ...)                                                                                       \
     186              :     do {                                                                                                              \
     187              :         constexpr const char_t* const funcName = __FUNCTION__;                                                        \
     188              :         dlog_error(acl::ACL_MODE_ID, "%d %s:" fmt, acl::AclLog::GetTid(), acl::format_cast(funcName), ##__VA_ARGS__); \
     189              :     } while (false)
     190              : #define ACL_LOG_INNER_ERROR(fmt, ...)                                                                                 \
     191              :     do {                                                                                                              \
     192              :         constexpr const char_t* const funcName = __FUNCTION__;                                                        \
     193              :         dlog_error(acl::ACL_MODE_ID, "%d %s:" fmt, acl::AclLog::GetTid(), acl::format_cast(funcName), ##__VA_ARGS__); \
     194              :         acl::AclErrorLogManager::ReportInnerError((fmt), ##__VA_ARGS__);                                              \
     195              :     } while (false)
     196              : #define ACL_LOG_CALL_ERROR(fmt, ...)                                                                                  \
     197              :     do {                                                                                                              \
     198              :         constexpr const char_t* const funcName = __FUNCTION__;                                                        \
     199              :         dlog_error(acl::ACL_MODE_ID, "%d %s:" fmt, acl::AclLog::GetTid(), acl::format_cast(funcName), ##__VA_ARGS__); \
     200              :         acl::AclErrorLogManager::ReportCallError((fmt), ##__VA_ARGS__);                                               \
     201              :     } while (false)
     202              : #define ACL_LOG_EVENT(fmt, ...)                                                                                        \
     203              :     do {                                                                                                               \
     204              :         if (acl::AclLog::IsEventLogOutputEnable()) {                                                                   \
     205              :             constexpr const char_t* const funcName = __FUNCTION__;                                                     \
     206              :             dlog_info(                                                                                                 \
     207              :                 (acl::ACL_MODE_ID | (RUN_LOG_MASK)), "%d %s: " fmt, acl::AclLog::GetTid(), acl::format_cast(funcName), \
     208              :                 ##__VA_ARGS__);                                                                                        \
     209              :         }                                                                                                              \
     210              :     } while (false)
     211              : #endif
     212              : 
     213              : #define OFFSET_OF_MEMBER(type, member) reinterpret_cast<size_t>(&((reinterpret_cast<type*>(0))->member))
     214              : 
     215              : #define ACL_REQUIRES_OK(expr)          \
     216              :     do {                               \
     217              :         const aclError __ret = (expr); \
     218              :         if (__ret != ACL_SUCCESS) {    \
     219              :             return __ret;              \
     220              :         }                              \
     221              :     } while (false)
     222              : 
     223              : #define ACL_REQUIRES_OK_RETURN_NULL(expr) \
     224              :     do {                                  \
     225              :         const aclError __ret = (expr);    \
     226              :         if (__ret != ACL_SUCCESS) {       \
     227              :             return nullptr;               \
     228              :         }                                 \
     229              :     } while (false)
     230              : 
     231              : #define ACL_REQUIRES_EOK(expr, interface)                                                  \
     232              :     do {                                                                                   \
     233              :         const auto __ret = (expr);                                                         \
     234              :         if (__ret != EOK) {                                                                \
     235              :             ACL_LOG_INNER_ERROR("call api [%s] failed, retCode is %d", #interface, __ret); \
     236              :             return ACL_ERROR_FAILURE;                                                      \
     237              :         }                                                                                  \
     238              :     } while (false)
     239              : 
     240              : #define ACL_REQUIRES_OK_WITH_INNER_MESSAGE(expr, ...) \
     241              :     do {                                              \
     242              :         const aclError __ret = (expr);                \
     243              :         if (__ret != ACL_SUCCESS) {                   \
     244              :             ACL_LOG_INNER_ERROR(__VA_ARGS__);         \
     245              :             return __ret;                             \
     246              :         }                                             \
     247              :     } while (false)
     248              : 
     249              : #define ACL_REQUIRES_CALL_GE_OK(expr, ...)   \
     250              :     do {                                     \
     251              :         const auto __ret = (expr);           \
     252              :         if (__ret != ge::SUCCESS) {          \
     253              :             ACL_LOG_CALL_ERROR(__VA_ARGS__); \
     254              :             return __ret;                    \
     255              :         }                                    \
     256              :     } while (false)
     257              : 
     258              : #define ACL_REQUIRES_CALL_RTS_OK(expr, interface)                                                        \
     259              :     do {                                                                                                 \
     260              :         const rtError_t __ret = (expr);                                                                  \
     261              :         if (__ret != RT_ERROR_NONE) {                                                                    \
     262              :             if (__ret == ACL_ERROR_RT_FEATURE_NOT_SUPPORT) {                                             \
     263              :                 ACL_LOG_WARN("rts api [%s] is not supported currently,", #interface);                    \
     264              :                 return __ret;                                                                            \
     265              :             }                                                                                            \
     266              :             ACL_LOG_CALL_ERROR("[Call][Rts]call rts api [%s] failed, retCode is %d", #interface, __ret); \
     267              :             return __ret;                                                                                \
     268              :         }                                                                                                \
     269              :     } while (false)
     270              : 
     271              : #define ACL_REQUIRES_RTS_OK_WARN_NOT_SUPPORT(expr, interface)                         \
     272              :     do {                                                                              \
     273              :         const rtError_t __ret = (expr);                                               \
     274              :         if (__ret != RT_ERROR_NONE) {                                                 \
     275              :             if (__ret == ACL_ERROR_RT_FEATURE_NOT_SUPPORT) {                          \
     276              :                 ACL_LOG_WARN("rts api [%s] is not supported currently,", #interface); \
     277              :             }                                                                         \
     278              :             return __ret;                                                             \
     279              :         }                                                                             \
     280              :     } while (false)
     281              : 
     282              : #define ACL_REQUIRES_RTS_OK(expr)              \
     283              :     do {                                       \
     284              :         const rtError_t __ret = (expr);        \
     285              :         if (__ret != RT_ERROR_NONE) {          \
     286              :             return ACL_GET_ERRCODE_RTS(__ret); \
     287              :         }                                      \
     288              :     } while (false)
     289              : 
     290              : #define ACL_REQUIRES_CALL_HIMPI_OK(expr, interface)                                                          \
     291              :     do {                                                                                                     \
     292              :         const int32_t __ret = (expr);                                                                        \
     293              :         if (__ret != 0) {                                                                                    \
     294              :             ACL_LOG_CALL_ERROR("[Call][Himpi]call himpi api [%s] failed, retCode is %d", #interface, __ret); \
     295              :             return __ret;                                                                                    \
     296              :         }                                                                                                    \
     297              :     } while (false)
     298              : 
     299              : // Validate whether the expr value is true
     300              : #define ACL_REQUIRES_TRUE(expr, errCode, errDesc) \
     301              :     do {                                          \
     302              :         const bool __ret = (expr);                \
     303              :         if (!__ret) {                             \
     304              :             ACL_LOG_ERROR(errDesc);               \
     305              :             return (errCode);                     \
     306              :         }                                         \
     307              :     } while (false)
     308              : 
     309              : #define ACL_CHECK_RESERVED_PARAM_REPORT_RET(param, expect, ret)                                                \
     310              :     do {                                                                                                       \
     311              :         if ((param) != (expect)) {                                                                             \
     312              :             const std::string paramVal = std::to_string(param);                                                \
     313              :             const std::string expectVal = std::to_string(static_cast<long long>(expect));                      \
     314              :             ACL_LOG_ERROR(                                                                                     \
     315              :                 "[Check][PARAM]%s is a reserved parameter and must be %s, current value=%s", #param,           \
     316              :                 expectVal.c_str(), paramVal.c_str());                                                          \
     317              :             std::string errMsg = acl::AclErrorLogManager::FormatStr(                                           \
     318              :                 "%s is a reserved parameter and must be %s", #param, expectVal.c_str());                       \
     319              :             std::string funcName = acl::AclErrorLogManager::GetFuncNameWithoutImplSuffix(__func__);            \
     320              :             acl::AclErrorLogManager::ReportInputError(                                                         \
     321              :                 acl::INVALID_PARAM_REASON_MSG, std::vector<const char*>({"func", "value", "param", "reason"}), \
     322              :                 std::vector<const char*>({funcName.c_str(), paramVal.c_str(), #param, errMsg.c_str()}));       \
     323              :             return ret;                                                                                        \
     324              :         }                                                                                                      \
     325              :     } while (false)
     326              : 
     327              : #define ACL_CHECK_INVALID_PARAM_WITH_REASON(condition, param, reason)                                          \
     328              :     do {                                                                                                       \
     329              :         if (condition) {                                                                                       \
     330              :             const std::string paramVal = std::to_string(param);                                                \
     331              :             ACL_LOG_ERROR("[Check][PARAM]%s is invalid, %s. value=%s", #param, (reason), paramVal.c_str());    \
     332              :             std::string funcName = acl::AclErrorLogManager::GetFuncNameWithoutImplSuffix(__func__);            \
     333              :             acl::AclErrorLogManager::ReportInputError(                                                         \
     334              :                 acl::INVALID_PARAM_REASON_MSG, std::vector<const char*>({"func", "value", "param", "reason"}), \
     335              :                 std::vector<const char*>({funcName.c_str(), paramVal.c_str(), #param, (reason)}));             \
     336              :             return ACL_ERROR_INVALID_PARAM;                                                                    \
     337              :         }                                                                                                      \
     338              :     } while (false)
     339              : 
     340              : #define ACL_CHECK_INVALID_PARAM_WITH_REASON_AND_FUNC_DESC(condition, param, reason, funcDesc)                  \
     341              :     do {                                                                                                       \
     342              :         if (condition) {                                                                                       \
     343              :             const std::string paramVal = std::to_string(param);                                                \
     344              :             ACL_LOG_ERROR("[Check][PARAM]%s is invalid, %s. value=%s", #param, (reason), paramVal.c_str());    \
     345              :             acl::AclErrorLogManager::ReportInputError(                                                         \
     346              :                 acl::INVALID_PARAM_REASON_MSG, std::vector<const char*>({"func", "value", "param", "reason"}), \
     347              :                 std::vector<const char*>({(funcDesc), paramVal.c_str(), #param, (reason)}));                   \
     348              :             return ACL_ERROR_INVALID_PARAM;                                                                    \
     349              :         }                                                                                                      \
     350              :     } while (false)
     351              : 
     352              : #define ACL_CHECK_INVALID_PARAM_WITH_REASON_RET(condition, param, reason, ret)                                 \
     353              :     do {                                                                                                       \
     354              :         if (condition) {                                                                                       \
     355              :             const std::string paramVal = std::to_string(param);                                                \
     356              :             ACL_LOG_ERROR("[Check][PARAM]%s is invalid, %s. value=%s", #param, (reason), paramVal.c_str());    \
     357              :             std::string funcName = acl::AclErrorLogManager::GetFuncNameWithoutImplSuffix(__func__);            \
     358              :             acl::AclErrorLogManager::ReportInputError(                                                         \
     359              :                 acl::INVALID_PARAM_REASON_MSG, std::vector<const char*>({"func", "value", "param", "reason"}), \
     360              :                 std::vector<const char*>({funcName.c_str(), paramVal.c_str(), #param, (reason)}));             \
     361              :             return (ret);                                                                                      \
     362              :         }                                                                                                      \
     363              :     } while (false)
     364              : 
     365              : #define ACL_CHECK_INVALID_PARAM_WITH_REASON_RET_AND_FUNC_DESC(condition, param, reason, ret, funcDesc)         \
     366              :     do {                                                                                                       \
     367              :         if (condition) {                                                                                       \
     368              :             const std::string paramVal = std::to_string(param);                                                \
     369              :             ACL_LOG_ERROR("[Check][PARAM]%s is invalid, %s. value=%s", #param, (reason), paramVal.c_str());    \
     370              :             acl::AclErrorLogManager::ReportInputError(                                                         \
     371              :                 acl::INVALID_PARAM_REASON_MSG, std::vector<const char*>({"func", "value", "param", "reason"}), \
     372              :                 std::vector<const char*>({(funcDesc), paramVal.c_str(), #param, (reason)}));                   \
     373              :             return (ret);                                                                                      \
     374              :         }                                                                                                      \
     375              :     } while (false)
     376              : 
     377              : #define ACL_CHECK_INVALID_PARAM_WITH_REASON_DESC_RET(condition, paramVal, paramName, reason, ret)              \
     378              :     do {                                                                                                       \
     379              :         if (condition) {                                                                                       \
     380              :             ACL_LOG_ERROR("[Check][PARAM]%s is invalid, %s. value=%s", (paramName), (reason), (paramVal));     \
     381              :             std::string funcName = acl::AclErrorLogManager::GetFuncNameWithoutImplSuffix(__func__);            \
     382              :             acl::AclErrorLogManager::ReportInputError(                                                         \
     383              :                 acl::INVALID_PARAM_REASON_MSG, std::vector<const char*>({"func", "value", "param", "reason"}), \
     384              :                 std::vector<const char*>({funcName.c_str(), (paramVal), (paramName), (reason)}));              \
     385              :             return (ret);                                                                                      \
     386              :         }                                                                                                      \
     387              :     } while (false)
     388              : 
     389              : #define ACL_CHECK_INVALID_VALUE_WITH_EXPECT(condition, param, expect)                                             \
     390              :     do {                                                                                                          \
     391              :         if (!(condition)) {                                                                                       \
     392              :             const std::string paramVal = std::to_string(param);                                                   \
     393              :             ACL_LOG_ERROR("[Check][PARAM]%s is invalid, must be %s. value=%s", #param, expect, paramVal.c_str()); \
     394              :             std::string funcName = acl::AclErrorLogManager::GetFuncNameWithoutImplSuffix(__func__);               \
     395              :             acl::AclErrorLogManager::ReportInputError(                                                            \
     396              :                 acl::INVALID_VALUE_MSG, std::vector<const char*>({"func", "value", "param", "expect"}),           \
     397              :                 std::vector<const char*>({funcName.c_str(), paramVal.c_str(), #param, expect}));                  \
     398              :             return ACL_ERROR_INVALID_PARAM;                                                                       \
     399              :         }                                                                                                         \
     400              :     } while (false)
     401              : 
     402              : #define ACL_CHECK_INVALID_VALUE_WITH_EXPECT_RET(condition, param, expect, ret)                                    \
     403              :     do {                                                                                                          \
     404              :         if (!(condition)) {                                                                                       \
     405              :             const std::string paramVal = std::to_string(param);                                                   \
     406              :             ACL_LOG_ERROR("[Check][PARAM]%s is invalid, must be %s. value=%s", #param, expect, paramVal.c_str()); \
     407              :             std::string funcName = acl::AclErrorLogManager::GetFuncNameWithoutImplSuffix(__func__);               \
     408              :             acl::AclErrorLogManager::ReportInputError(                                                            \
     409              :                 acl::INVALID_VALUE_MSG, std::vector<const char*>({"func", "value", "param", "expect"}),           \
     410              :                 std::vector<const char*>({funcName.c_str(), paramVal.c_str(), #param, expect}));                  \
     411              :             return ret;                                                                                           \
     412              :         }                                                                                                         \
     413              :     } while (false)
     414              : 
     415              : #define ACL_CHECK_INVALID_VALUE_WITH_DESC(condition, paramVal, paramName, expect, ret)                             \
     416              :     do {                                                                                                           \
     417              :         if (!(condition)) {                                                                                        \
     418              :             ACL_LOG_ERROR("[Check][PARAM]%s is invalid, must be %s. value=%s", (paramName), (expect), (paramVal)); \
     419              :             std::string funcName = acl::AclErrorLogManager::GetFuncNameWithoutImplSuffix(__func__);                \
     420              :             acl::AclErrorLogManager::ReportInputError(                                                             \
     421              :                 acl::INVALID_VALUE_MSG, std::vector<const char*>({"func", "value", "param", "expect"}),            \
     422              :                 std::vector<const char*>({funcName.c_str(), (paramVal), (paramName), (expect)}));                  \
     423              :             return (ret);                                                                                          \
     424              :         }                                                                                                          \
     425              :     } while (false)
     426              : 
     427              : #define ACL_CHECK_INVALID_VALUE_WITH_DESC_AND_FUNC_DESC(condition, paramVal, paramName, expect, ret, funcDesc)     \
     428              :     do {                                                                                                           \
     429              :         if (!(condition)) {                                                                                        \
     430              :             ACL_LOG_ERROR("[Check][PARAM]%s is invalid, must be %s. value=%s", (paramName), (expect), (paramVal)); \
     431              :             acl::AclErrorLogManager::ReportInputError(                                                             \
     432              :                 acl::INVALID_VALUE_MSG, std::vector<const char*>({"func", "value", "param", "expect"}),            \
     433              :                 std::vector<const char*>({(funcDesc), (paramVal), (paramName), (expect)}));                        \
     434              :             return (ret);                                                                                          \
     435              :         }                                                                                                          \
     436              :     } while (false)
     437              : 
     438              : #define ACL_REQUIRES_PARAM_EQUAL_REPORT(param, expect)                                                             \
     439              :     do {                                                                                                           \
     440              :         if ((param) != (expect)) {                                                                                 \
     441              :             const std::string paramVal = std::to_string(param);                                                    \
     442              :             ACL_LOG_ERROR("[Check][PARAM]%s is invalid, must be %s. value=%s", #param, #expect, paramVal.c_str()); \
     443              :             std::string funcName = acl::AclErrorLogManager::GetFuncNameWithoutImplSuffix(__func__);                \
     444              :             acl::AclErrorLogManager::ReportInputError(                                                             \
     445              :                 acl::INVALID_VALUE_MSG, std::vector<const char*>({"func", "value", "param", "expect"}),            \
     446              :                 std::vector<const char*>({funcName.c_str(), paramVal.c_str(), #param, #expect}));                  \
     447              :             return ACL_ERROR_INVALID_PARAM;                                                                        \
     448              :         }                                                                                                          \
     449              :     } while (false)
     450              : 
     451              : #ifndef ENABLE_DVPP_INTERFACE
     452              : #define ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(val)                                                \
     453              :     do {                                                                                            \
     454              :         if (UNLIKELY((val) == nullptr)) {                                                           \
     455              :             ACL_LOG_ERROR("[Check][%s]param must not be null.", #val);                              \
     456              :             std::string funcName = acl::AclErrorLogManager::GetFuncNameWithoutImplSuffix(__func__); \
     457              :             acl::AclErrorLogManager::ReportInputError(                                              \
     458              :                 acl::NULL_POINTER_FUNC_MSG, {"func", "param"}, {funcName.c_str(), #val});           \
     459              :             return ACL_ERROR_INVALID_PARAM;                                                         \
     460              :         }                                                                                           \
     461              :     } while (false)
     462              : #else
     463              : #define ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(val)                                                            \
     464              :     do {                                                                                                        \
     465              :         if (UNLIKELY((val) == nullptr)) {                                                                       \
     466              :             ACL_LOG_ERROR("[Check][%s]param must not be null.", #val);                                          \
     467              :             const char_t* argList[] = {"func", "param"};                                                        \
     468              :             std::string funcName = acl::AclErrorLogManager::GetFuncNameWithoutImplSuffix(__func__);             \
     469              :             const char_t* argVal[] = {funcName.c_str(), #val};                                                  \
     470              :             acl::AclErrorLogManager::ReportInputErrorWithChar(acl::NULL_POINTER_FUNC_MSG, argList, argVal, 2U); \
     471              :             return ACL_ERROR_INVALID_PARAM;                                                                     \
     472              :         }                                                                                                       \
     473              :     } while (false)
     474              : #endif
     475              : 
     476              : #ifndef ENABLE_DVPP_INTERFACE
     477              : #define ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT_AND_FUNC_DESC(val, funcDesc)        \
     478              :     do {                                                                            \
     479              :         if (UNLIKELY((val) == nullptr)) {                                           \
     480              :             ACL_LOG_ERROR("[Check][%s]param must not be null.", #val);              \
     481              :             acl::AclErrorLogManager::ReportInputError(                              \
     482              :                 acl::NULL_POINTER_FUNC_MSG, {"func", "param"}, {(funcDesc), #val}); \
     483              :             return ACL_ERROR_INVALID_PARAM;                                         \
     484              :         }                                                                           \
     485              :     } while (false)
     486              : #else
     487              : #define ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT_AND_FUNC_DESC(val, funcDesc)                                    \
     488              :     do {                                                                                                        \
     489              :         if (UNLIKELY((val) == nullptr)) {                                                                       \
     490              :             ACL_LOG_ERROR("[Check][%s]param must not be null.", #val);                                          \
     491              :             const char_t* argList[] = {"func", "param"};                                                        \
     492              :             const char_t* argVal[] = {(funcDesc), #val};                                                        \
     493              :             acl::AclErrorLogManager::ReportInputErrorWithChar(acl::NULL_POINTER_FUNC_MSG, argList, argVal, 2U); \
     494              :             return ACL_ERROR_INVALID_PARAM;                                                                     \
     495              :         }                                                                                                       \
     496              :     } while (false)
     497              : #endif
     498              : 
     499              : #define ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT_WITH_PRAM_NAME(val, name)                           \
     500              :     do {                                                                                            \
     501              :         if (UNLIKELY((val) == nullptr)) {                                                           \
     502              :             ACL_LOG_ERROR("[Check][%s]param must not be null.", #val);                              \
     503              :             std::string funcName = acl::AclErrorLogManager::GetFuncNameWithoutImplSuffix(__func__); \
     504              :             acl::AclErrorLogManager::ReportInputError(                                              \
     505              :                 acl::NULL_POINTER_FUNC_MSG, {"func", "param"}, {funcName.c_str(), (name)});         \
     506              :             return ACL_ERROR_INVALID_PARAM;                                                         \
     507              :         }                                                                                           \
     508              :     } while (false)
     509              : 
     510              : #define ACL_REQUIRES_NOT_NULL(val)                                     \
     511              :     do {                                                               \
     512              :         if (UNLIKELY((val) == nullptr)) {                              \
     513              :             ACL_LOG_ERROR("[Check][%s]param must not be null.", #val); \
     514              :             return ACL_ERROR_INVALID_PARAM;                            \
     515              :         }                                                              \
     516              :     } while (false)
     517              : 
     518              : #define ACL_REQUIRES_NOT_NULL_WITH_INNER_REPORT(val)                         \
     519              :     do {                                                                     \
     520              :         if (UNLIKELY((val) == nullptr)) {                                    \
     521              :             ACL_LOG_INNER_ERROR("[Check][%s]param must not be null.", #val); \
     522              :             return ACL_ERROR_INVALID_PARAM;                                  \
     523              :         }                                                                    \
     524              :     } while (false)
     525              : 
     526              : #define ACL_REQUIRES_NOT_NULL_RET_NULL(val)                            \
     527              :     do {                                                               \
     528              :         if (UNLIKELY((val) == nullptr)) {                              \
     529              :             ACL_LOG_ERROR("[Check][%s]param must not be null.", #val); \
     530              :             return nullptr;                                            \
     531              :         }                                                              \
     532              :     } while (false)
     533              : 
     534              : #define ACL_CHECK_INVALID_PARAM_NO_VALUE(condition, paramName, reason)                                               \
     535              :     do {                                                                                                             \
     536              :         if (!(condition)) {                                                                                          \
     537              :             const char_t* argList[] = {"func", "param", "reason"};                                                   \
     538              :             std::string funcName = acl::AclErrorLogManager::GetFuncNameWithoutImplSuffix(__func__);                  \
     539              :             const char_t* argVal[] = {funcName.c_str(), (paramName), (reason)};                                      \
     540              :             acl::AclErrorLogManager::ReportInputErrorWithChar(acl::INVALID_PARAM_NO_VALUE_MSG, argList, argVal, 3U); \
     541              :             return ACL_ERROR_INVALID_PARAM;                                                                          \
     542              :         }                                                                                                            \
     543              :     } while (false)
     544              : 
     545              : #define ACL_CHECK_INVALID_FILE_MSG_RET(condition, path, reason, ret)                 \
     546              :     do {                                                                             \
     547              :         if (condition) {                                                             \
     548              :             ACL_LOG_ERROR("[Check][File]file %s is invalid, %s", path, reason);      \
     549              :             acl::AclErrorLogManager::ReportInputError(                               \
     550              :                 acl::INVALID_FILE_MSG, std::vector<const char*>({"path", "reason"}), \
     551              :                 std::vector<const char*>({path, reason}));                           \
     552              :             return ret;                                                              \
     553              :         }                                                                            \
     554              :     } while (false)
     555              : 
     556              : #define ACL_REQUIRES_NOT_NULL_RET_NULL_INPUT_REPORT(val)                                            \
     557              :     do {                                                                                            \
     558              :         if (UNLIKELY((val) == nullptr)) {                                                           \
     559              :             ACL_LOG_ERROR("[Check][%s]param must not be null.", #val);                              \
     560              :             std::string funcName = acl::AclErrorLogManager::GetFuncNameWithoutImplSuffix(__func__); \
     561              :             acl::AclErrorLogManager::ReportInputError(                                              \
     562              :                 acl::NULL_POINTER_FUNC_MSG, {"func", "param"}, {funcName.c_str(), #val});           \
     563              :             return nullptr;                                                                         \
     564              :         }                                                                                           \
     565              :     } while (false)
     566              : 
     567              : #define ACL_REQUIRES_NOT_NULL_RET_INPUT_REPORT(val, ret)                                            \
     568              :     do {                                                                                            \
     569              :         if (UNLIKELY((val) == nullptr)) {                                                           \
     570              :             ACL_LOG_ERROR("[Check][%s]param must not be null.", #val);                              \
     571              :             std::string funcName = acl::AclErrorLogManager::GetFuncNameWithoutImplSuffix(__func__); \
     572              :             acl::AclErrorLogManager::ReportInputError(                                              \
     573              :                 acl::NULL_POINTER_FUNC_MSG, {"func", "param"}, {funcName.c_str(), #val});           \
     574              :             return (ret);                                                                           \
     575              :         }                                                                                           \
     576              :     } while (false)
     577              : 
     578              : #define ACL_REQUIRES_NOT_NULL_RET_INPUT_REPORT_WITH_FUNC_DESC(val, ret, funcDesc)   \
     579              :     do {                                                                            \
     580              :         if (UNLIKELY((val) == nullptr)) {                                           \
     581              :             ACL_LOG_ERROR("[Check][%s]param must not be null.", #val);              \
     582              :             acl::AclErrorLogManager::ReportInputError(                              \
     583              :                 acl::NULL_POINTER_FUNC_MSG, {"func", "param"}, {(funcDesc), #val}); \
     584              :             return (ret);                                                           \
     585              :         }                                                                           \
     586              :     } while (false)
     587              : 
     588              : #define ACL_CHECK_MALLOC_RESULT_REPORT_RET(val, size, allocInterface, ret)                                \
     589              :     do {                                                                                                  \
     590              :         if ((val) == nullptr) {                                                                           \
     591              :             const std::string sizeVal = std::to_string(size);                                             \
     592              :             ACL_LOG_ERROR("[Check][Malloc]Allocate memory for [%s] failed, bufferSize=%zu.", #val, size); \
     593              :             acl::AclErrorLogManager::ReportInputError(                                                    \
     594              :                 acl::ALLOC_MEMORY_FAILED_MSG, std::vector<const char*>({"buf_size", "alloc_interface"}),  \
     595              :                 std::vector<const char*>({sizeVal.c_str(), allocInterface}));                             \
     596              :             return ret;                                                                                   \
     597              :         }                                                                                                 \
     598              :     } while (false)
     599              : 
     600              : #define ACL_REQUIRES_NOT_NULL_RET_VOID(val)                            \
     601              :     do {                                                               \
     602              :         if (UNLIKELY((val) == nullptr)) {                              \
     603              :             ACL_LOG_ERROR("[Check][%s]param must not be null.", #val); \
     604              :             return;                                                    \
     605              :         }                                                              \
     606              :     } while (false)
     607              : 
     608              : #define ACL_CHECK_RANGE_INT(val, min, max)                                                                    \
     609              :     do {                                                                                                      \
     610              :         if (((val) < (min)) || ((val) > (max))) {                                                             \
     611              :             ACL_LOG_ERROR(                                                                                    \
     612              :                 "[Check][%s]param:[%d] must be in range of [%d] and [%d]", #val, (static_cast<int32_t>(val)), \
     613              :                 (static_cast<int32_t>(min)), (static_cast<int32_t>(max)));                                    \
     614              :             return ACL_ERROR_INVALID_PARAM;                                                                   \
     615              :         }                                                                                                     \
     616              :     } while (false)
     617              : 
     618              : #define ACL_CHECK_LESS_UINT(val, max)                                                                         \
     619              :     do {                                                                                                      \
     620              :         if ((val) > (max)) {                                                                                  \
     621              :             ACL_LOG_ERROR(                                                                                    \
     622              :                 "[Check][%s]param:[%u] must be in range of [0] and [%u]", #val, (static_cast<uint32_t>(val)), \
     623              :                 (static_cast<uint32_t>(max)));                                                                \
     624              :             return ACL_ERROR_INVALID_PARAM;                                                                   \
     625              :         }                                                                                                     \
     626              :     } while (false)
     627              : 
     628              : #define ACL_CHECK_RANGE_FLOAT(val, min, max)                                                                          \
     629              :     do {                                                                                                              \
     630              :         if (((val) < (min)) || ((val) > (max))) {                                                                     \
     631              :             ACL_LOG_ERROR(                                                                                            \
     632              :                 "[Check][%s]param:[%.2f] must be in range of [%.2f] and [%.2f]", #val, (static_cast<float64_t>(val)), \
     633              :                 (static_cast<float64_t>(min)), (static_cast<float64_t>(max)));                                        \
     634              :             return ACL_ERROR_INVALID_PARAM;                                                                           \
     635              :         }                                                                                                             \
     636              :     } while (false)
     637              : 
     638              : #define ACL_CHECK_MALLOC_RESULT(val)                                                      \
     639              :     do {                                                                                  \
     640              :         if ((val) == nullptr) {                                                           \
     641              :             ACL_LOG_INNER_ERROR("[Check][Malloc]Allocate memory for [%s] failed.", #val); \
     642              :             return ACL_ERROR_BAD_ALLOC;                                                   \
     643              :         }                                                                                 \
     644              :     } while (false)
     645              : 
     646              : #define ACL_REQUIRES_NON_NEGATIVE(val)                                     \
     647              :     do {                                                                   \
     648              :         if ((val) < 0) {                                                   \
     649              :             ACL_LOG_ERROR("[Check][%s]param must be non-negative.", #val); \
     650              :             return ACL_ERROR_INVALID_PARAM;                                \
     651              :         }                                                                  \
     652              :     } while (false)
     653              : 
     654              : #define ACL_REQUIRES_POSITIVE_REPORT(val)                                                                         \
     655              :     do {                                                                                                          \
     656              :         if ((val) <= 0) {                                                                                         \
     657              :             ACL_LOG_ERROR("[Check][%s]param must be positive.", #val);                                            \
     658              :             const std::string valStr = std::to_string(val);                                                       \
     659              :             std::string funcName = acl::AclErrorLogManager::GetFuncNameWithoutImplSuffix(__func__);               \
     660              :             acl::AclErrorLogManager::ReportInputError(                                                            \
     661              :                 acl::INVALID_VALUE_MSG, std::vector<const char*>({"func", "value", "param", "expect"}),           \
     662              :                 std::vector<const char*>({funcName.c_str(), valStr.c_str(), #val, "must be greater than zero"})); \
     663              :             return ACL_ERROR_INVALID_PARAM;                                                                       \
     664              :         }                                                                                                         \
     665              :     } while (false)
     666              : 
     667              : #define ACL_REQUIRES_POSITIVE_REPORT_WITH_FUNC_DESC(val, funcDesc)                                          \
     668              :     do {                                                                                                    \
     669              :         if ((val) <= 0) {                                                                                   \
     670              :             ACL_LOG_ERROR("[Check][%s]param must be positive.", #val);                                      \
     671              :             const std::string valStr = std::to_string(val);                                                 \
     672              :             acl::AclErrorLogManager::ReportInputError(                                                      \
     673              :                 acl::INVALID_VALUE_MSG, std::vector<const char*>({"func", "value", "param", "expect"}),     \
     674              :                 std::vector<const char*>({(funcDesc), valStr.c_str(), #val, "must be greater than zero"})); \
     675              :             return ACL_ERROR_INVALID_PARAM;                                                                 \
     676              :         }                                                                                                   \
     677              :     } while (false)
     678              : 
     679              : #define ACL_REQUIRES_POSITIVE(val)                                     \
     680              :     do {                                                               \
     681              :         if ((val) <= 0) {                                              \
     682              :             ACL_LOG_ERROR("[Check][%s]param must be positive.", #val); \
     683              :             return ACL_ERROR_INVALID_PARAM;                            \
     684              :         }                                                              \
     685              :     } while (false)
     686              : 
     687              : #define ACL_REQUIRES_POSITIVE_RET_NULL(val)                            \
     688              :     do {                                                               \
     689              :         if ((val) <= 0) {                                              \
     690              :             ACL_LOG_ERROR("[Check][%s]param must be positive.", #val); \
     691              :             return nullptr;                                            \
     692              :         }                                                              \
     693              :     } while (false)
     694              : 
     695              : #define ACL_DELETE(memory)  \
     696              :     do {                    \
     697              :         delete (memory);    \
     698              :         (memory) = nullptr; \
     699              :     } while (false)
     700              : 
     701              : #define ACL_DELETE_ARRAY(memory)                   \
     702              :     do {                                           \
     703              :         if ((memory) != nullptr) {                 \
     704              :             delete[] static_cast<char_t*>(memory); \
     705              :             (memory) = nullptr;                    \
     706              :         }                                          \
     707              :     } while (false)
     708              : 
     709              : #define ACL_CHECK_WITH_MESSAGE_AND_RETURN(exp, ret, ...) \
     710              :     do {                                                 \
     711              :         if (!(exp)) {                                    \
     712              :             ACL_LOG_ERROR(__VA_ARGS__);                  \
     713              :             return (ret);                                \
     714              :         }                                                \
     715              :     } while (false)
     716              : 
     717              : #define ACL_CHECK_WITH_INNER_MESSAGE_AND_RETURN(exp, ret, ...) \
     718              :     do {                                                       \
     719              :         if (!(exp)) {                                          \
     720              :             ACL_LOG_INNER_ERROR(__VA_ARGS__);                  \
     721              :             return (ret);                                      \
     722              :         }                                                      \
     723              :     } while (false)
     724              : 
     725              : #define ACL_DELETE_AND_SET_NULL(var) \
     726              :     do {                             \
     727              :         if ((var) != nullptr) {      \
     728              :             delete (var);            \
     729              :             (var) = nullptr;         \
     730              :         }                            \
     731              :     } while (false)
     732              : 
     733              : #define ACL_DELETE_ARRAY_AND_SET_NULL(var) \
     734              :     do {                                   \
     735              :         if ((var) != nullptr) {            \
     736              :             delete[] (var);                \
     737              :             (var) = nullptr;               \
     738              :         }                                  \
     739              :     } while (false)
     740              : 
     741              : #define ACL_FREE(var)           \
     742              :     do {                        \
     743              :         if ((var) != nullptr) { \
     744              :             free(var);          \
     745              :             (var) = nullptr;    \
     746              :         }                       \
     747              :     } while (false)
     748              : 
     749              : #define ACL_ALIGN_FREE(var)     \
     750              :     do {                        \
     751              :         if ((var) != nullptr) { \
     752              :             mmAlignFree(var);   \
     753              :             (var) = nullptr;    \
     754              :         }                       \
     755              :     } while (false)
     756              : 
     757              : // If make_shared is abnormal, print the log and execute the statement
     758              : #define ACL_MAKE_SHARED(expr0, expr1)                            \
     759              :     try {                                                        \
     760              :         (expr0);                                                 \
     761              :     } catch (const std::bad_alloc&) {                            \
     762              :         ACL_LOG_INNER_ERROR("[Make][Shared]Make shared failed"); \
     763              :         expr1;                                                   \
     764              :     }
     765              : 
     766              : #define RETURN_NULL_WITH_ALIGN_FREE(newAddr, mallocAddr)           \
     767              :     do {                                                           \
     768              :         if ((newAddr) == nullptr) {                                \
     769              :             ACL_LOG_INNER_ERROR("[Malloc][Mem]new memory failed"); \
     770              :             mmAlignFree(mallocAddr);                               \
     771              :             return nullptr;                                        \
     772              :         }                                                          \
     773              :     } while (false)
     774              : 
     775              : #define ACL_CHECK_INT32_EQUAL(leftValue, rightValue)                               \
     776              :     do {                                                                           \
     777              :         if ((leftValue) != (rightValue)) {                                         \
     778              :             ACL_LOG_INFO("[%d] is not equal to [%d].", (leftValue), (rightValue)); \
     779              :             return false;                                                          \
     780              :         }                                                                          \
     781              :     } while (false)
     782              : 
     783              : #define ACL_REQUIRES_EQ(x, y)                                                                        \
     784              :     do {                                                                                             \
     785              :         const auto& xv = (x);                                                                        \
     786              :         const auto& yv = (y);                                                                        \
     787              :         if (xv != yv) {                                                                              \
     788              :             std::stringstream ss;                                                                    \
     789              :             ss << "Assert (" << #x << " == " << #y << ") failed, expect " << yv << " actual " << xv; \
     790              :             ACL_LOG_INNER_ERROR("%s", ss.str().c_str());                                             \
     791              :             return ACL_ERROR_INVALID_PARAM;                                                          \
     792              :         }                                                                                            \
     793              :     } while (false)
     794              : 
     795              : #define ACL_REQUIRES_LE(x, y)                                                                                       \
     796              :     do {                                                                                                            \
     797              :         const auto& xv = (x);                                                                                       \
     798              :         const auto& yv = (y);                                                                                       \
     799              :         if (!(xv <= yv)) {                                                                                          \
     800              :             std::stringstream ss;                                                                                   \
     801              :             ss << "Assert (" << #x << " <= " << #y << ") failed, left value is " << xv << " right value is " << yv; \
     802              :             ACL_LOG_INNER_ERROR("%s", ss.str().c_str());                                                            \
     803              :             return ACL_ERROR_INVALID_PARAM;                                                                         \
     804              :         }                                                                                                           \
     805              :     } while (false)
     806              : 
     807              : #define ACL_CHECK_UINT32_GREATER(leftValue, rightValue)                                                        \
     808              :     do {                                                                                                       \
     809              :         if ((leftValue) < (rightValue)) {                                                                      \
     810              :             ACL_LOG_ERROR(                                                                                     \
     811              :                 "left value [%u] can not be smaller than right value [%u].", static_cast<uint32_t>(leftValue), \
     812              :                 static_cast<uint32_t>(rightValue));                                                            \
     813              :             return ACL_ERROR_INVALID_PARAM;                                                                    \
     814              :         }                                                                                                      \
     815              :     } while (false)
     816              : 
     817              : #define ACL_CHECK_FILE_OPEN_FAILED(condition, path, reasonPrefix, ret)                                            \
     818              :     do {                                                                                                          \
     819              :         if (!(condition)) {                                                                                       \
     820              :             const std::string errReason = strerror(errno);                                                        \
     821              :             std::string errMsg = acl::AclErrorLogManager::FormatStr("%s, %s", (reasonPrefix), errReason.c_str()); \
     822              :             ACL_LOG_ERROR("[Check]Open file [%s] failed, reason is [%s].", path, errReason.c_str());              \
     823              :             acl::AclErrorLogManager::ReportInputError(                                                            \
     824              :                 acl::INVALID_FILE_MSG, std::vector<const char*>({"path", "reason"}),                              \
     825              :                 std::vector<const char*>({path, errMsg.c_str()}));                                                \
     826              :             return ret;                                                                                           \
     827              :         }                                                                                                         \
     828              :     } while (false)
     829              : 
     830              : #endif // ACL_COMMON_LOG_H_
        

Generated by: LCOV version 2.0-1