You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
1.7 KiB
69 lines
1.7 KiB
/*
|
|
* Copyright (c) Hisilicon Technologies Co., Ltd. 2019-2021. All rights reserved.
|
|
* Description: adp head.
|
|
* Author: Hisilicon
|
|
* Create: 2019-11-01
|
|
*/
|
|
|
|
#ifndef __ADP_COMMON_EXT_H__
|
|
#define __ADP_COMMON_EXT_H__
|
|
|
|
#include <stdio.h>
|
|
#include <unistd.h>
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
#include <fcntl.h>
|
|
|
|
#include "td_type.h"
|
|
|
|
#if defined(ANDROID)
|
|
extern void log_print(const char *format, ...);
|
|
#endif
|
|
|
|
#ifdef CONFIG_SUPPORT_CA_RELEASE
|
|
#define SAMPLE_COMMON_PRINTF
|
|
#else
|
|
#if defined(ANDROID)
|
|
#define SAMPLE_COMMON_PRINTF log_print
|
|
#else
|
|
#define SAMPLE_COMMON_PRINTF printf
|
|
#endif
|
|
#endif
|
|
|
|
#define adp_api_run(api, ret) do { \
|
|
td_s32 _err_code; \
|
|
_err_code = api; \
|
|
if (_err_code != 0) { \
|
|
(ret) |= _err_code; \
|
|
SAMPLE_COMMON_PRINTF("\033[0;31m" "[Function: %s line: %d] %s failed ret = 0x%x \n" "\033[0m", \
|
|
__FUNCTION__, __LINE__, # api, _err_code); \
|
|
} \
|
|
} while (0)
|
|
|
|
#define adp_api_run_return(api) do { \
|
|
td_s32 _err_code; \
|
|
_err_code = api; \
|
|
if (_err_code != 0) { \
|
|
SAMPLE_COMMON_PRINTF("\033[0;31m" "[Function: %s line: %d] %s failed ret = 0x%x \n" "\033[0m", \
|
|
__FUNCTION__, __LINE__, # api, _err_code); \
|
|
return TD_FAILURE; \
|
|
} \
|
|
} while (0)
|
|
|
|
#define adp_api_err_print(ret) do { \
|
|
SAMPLE_COMMON_PRINTF("\033[0;31m" " [Function: %s line: %d] ret = 0x%x \n" "\033[0m", \
|
|
__FUNCTION__, __LINE__, (ret)); \
|
|
} while (0) \
|
|
|
|
#define print_smp(fmt...) SAMPLE_COMMON_PRINTF(fmt)
|
|
|
|
#define sample_run(api, ret) do { \
|
|
td_s32 l_ret = api; \
|
|
if (l_ret != TD_SUCCESS) { \
|
|
print_smp("run %s failed, ERRNO:%#x.\n", # api, l_ret); \
|
|
} \
|
|
(ret) = l_ret; \
|
|
} while (0)
|
|
|
|
#endif
|