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.
77 lines
1.9 KiB
77 lines
1.9 KiB
4 months ago
|
/*
|
||
|
* 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)
|
||
|
|
||
|
#ifdef ANDROID
|
||
|
#define SAMPLE_GET_INPUTCMD(input_cmd) do { \
|
||
|
read(0, input_cmd, sizeof(input_cmd)); \
|
||
|
} while (0)
|
||
|
#else
|
||
|
#define SAMPLE_GET_INPUTCMD(input_cmd) fgets((char *)(input_cmd), (sizeof(input_cmd) - 1), stdin)
|
||
|
#endif
|
||
|
|
||
|
#endif
|