📄 macros.h
字号:
} \
#define TB640_FSK_SERVICE_FUNCTION_POST() \
result = TBXAsyncPostRequest ( \
pAdapterInfo->ahOperationLib [pTrunkInfo->un32OpLibIdx], \
pAsyncRequest); \
if (TBX_RESULT_FAILURE(result)) \
{ \
TBX_EXIT_ERROR(result, 0, "Unable to post request"); \
} \
TBX_EXIT_SUCCESS (TBX_RESULT_OK); \
}
#define TB640_FSK_SERVICE_FUNCTION_POST_EVENT() \
result = TBXAsyncPostRequest ( \
pAdapterInfo->ahOperationLib [pTrunkInfo->un32OpLibIdx], \
pAsyncRequest); \
if (TBX_RESULT_FAILURE(result)) \
{ \
TBX_EXIT_ERROR(result, 0, "Unable to post request"); \
} \
TBX_EXIT_SUCCESS (TBX_RESULT_OK); \
} \
\
ERROR_HANDLING \
{ \
TB640_FSK_LOG (TRACE_LEVEL_ALWAYS, "%s (Result = 0x%08X, %s, line %d)\n", \
TBX_ERROR_DESCRIPTION, TBX_ERROR_RESULT, __FILE__, TBX_ERROR_LINE); \
if (pAsyncRequest != NULL) \
{ \
TBXAsyncDestroyRequest(pAdapterInfo->ahOperationLib [pTrunkInfo->un32OpLibIdx], \
pAsyncRequest); \
pAsyncRequest = NULL; \
} \
} \
\
CLEANUP \
{ \
} \
\
RETURN; \
#define TB640_FSK_SET_TIMEOUT(__Timeout__) \
{ \
in_pCallContext->fTimeoutOccured = TBX_FALSE; \
TBXAsyncModifyOp ( \
pAdapterInfo->ahOperationLib [pTrunkInfo->un32OpLibIdx], \
in_pCallContext->pOpContext, \
0, \
(__Timeout__)); \
}
/* Inline function to output an error trace onto the display */
static INLINE void TB640_FSK_DISPLAY_OUTPUT (PTBX_CHAR __pString__, va_list __var__)
{
TBXCli_vfprintf (stdout, __pString__, __var__);
}
/* Inline function to output a trace into the logfile */
static INLINE void TB640_FSK_FILE_OUTPUT(PTBX_CHAR __pString__, va_list __var__)
{
if ((g_AppContext != NULL) && (g_AppContext->pLogFile != NULL))
{
vfprintf (g_AppContext->pLogFile, __pString__, __var__);
}
}
/* Inline to output a trace into the logfile and/or to the display */
static INLINE void TB640_FSK_LOG(TBX_UINT32 __level__,PTBX_CHAR __pString__, ...)
{
if (g_AppContext != NULL)
{
unsigned char * pChar;
int length;
va_list marker;
va_start (marker, __pString__);
if (g_AppContext->un32DisplayLogLevel <= __level__)
{
/* Print into a memory buffer instead of output display ? */
if (g_fPrintInErrorBuffer)
{
TBX_SEM_GET (g_AppContext->DisplaySem, TBX_SEM_WAIT_FOREVER);
g_un32ErrorLineId++;
/* Write the string at the "write index" location */
sprintf ((PTBX_CHAR)&(g_aszErrorLines[g_un32ErrorLineWriteIndex][0]), "%d- ", g_un32ErrorLineId);
length = strlen((PTBX_CHAR)&(g_aszErrorLines[g_un32ErrorLineWriteIndex][0]));
VSNPRINTF ((PTBX_CHAR)&(g_aszErrorLines[g_un32ErrorLineWriteIndex][length]), (TB640_FSK_CLI_MAX_ERROR_LINE_SIZE - length - 1),__pString__, marker);
/* Remove trailing '\n' */
length = strlen ((PTBX_CHAR)&(g_aszErrorLines[g_un32ErrorLineWriteIndex][0]));
pChar = (unsigned char *)&(g_aszErrorLines[g_un32ErrorLineWriteIndex][length-1]);
if ((*pChar == 0x0A) || (*pChar == 0x0D))
*pChar = 0x00;
pChar--;
if ((*pChar == 0x0A) || (*pChar == 0x0D))
*pChar = 0x00;
/* Increment the write pointer */
if (++g_un32ErrorLineWriteIndex >= TB640_FSK_CLI_MAX_NB_ERROR_LINES)
{
g_un32ErrorLineWriteIndex = 0;
}
/* Check for collision with read pointer */
if (g_un32ErrorLineWriteIndex == g_un32ErrorLineReadIndex)
{
/* Increment the read pointer */
if (++g_un32ErrorLineReadIndex >= TB640_FSK_CLI_MAX_NB_ERROR_LINES)
{
g_un32ErrorLineReadIndex = 0;
}
}
TBX_SEM_GIV (g_AppContext->DisplaySem);
}
else
{
TB640_FSK_DISPLAY_OUTPUT(__pString__,marker);
}
}
if (g_AppContext->un32FileLogLevel <= __level__)
{
TB640_FSK_FILE_OUTPUT(__pString__,marker);
}
va_end (marker);
}
}
/* Inline to output a trace into the logfile (no level checking) */
static INLINE void TB640_FSK_FILE_PRINT(PTBX_CHAR __pString__, ...)
{
va_list marker;
va_start (marker, __pString__);
TB640_FSK_FILE_OUTPUT(__pString__,marker);
va_end (marker);
}
/* Inline to output a trace onto the display (no level checking) */
static INLINE void TB640_FSK_DISPLAY_PRINT(PTBX_CHAR __pString__, ...)
{
va_list marker;
va_start (marker, __pString__);
TB640_FSK_DISPLAY_OUTPUT(__pString__,marker);
va_end (marker);
}
/* Create a "application context" to be used with operation library */
#define TB640_FSK_CREATE_APP_CONTEXT(__AdapterIdx__,__OpLibIdx__) \
((PTBX_VOID)(TBX_ADDR)((((__AdapterIdx__) << 16) & 0xFFFF0000) | (((__OpLibIdx__)) & 0x0000FFFF)))
#define TB640_FSK_CREATE_REQ_CONTEXT(__AdapterIdx__,__TrkIdx__, __ResIdx__) \
((TBX_UINT64)((((__AdapterIdx__) << 24) & 0xFF000000) | (((__TrkIdx__)<<16) & 0x00FF0000) | (((__ResIdx__)) & 0x0000FFFF)))
#define TB640_FSK_PARSE_RSP_CONTEXT(__hMsg__, __AdapterIdx__,__TrkIdx__,__ResIdx__) \
{ \
TBX_UINT32 un32Ctx = ((TBX_UINT32)TBX_MSG_USER_CONTEXT2_GET(hMsg)); \
TBX_UINT32 Dummy; \
(__AdapterIdx__) = ((un32Ctx)&0xFF000000) >> 24; \
(__TrkIdx__) = ((un32Ctx)&0x00FF0000) >> 16; \
(__ResIdx__) = ((un32Ctx)&0x0000FFFF) >> 0; \
(void)Dummy; \
}
/* Retrieve the "application context" to be used with operation library */
#define TB640_FSK_RETRIEVE_APP_CONTEXT(__OpLibContext__, __AdapterIdx__, __OpLibIdx__) \
{ \
(__AdapterIdx__) = (((TBX_UINT32)(TBX_ADDR)(__OpLibContext__)) & 0xFFFF0000) >> 16; \
(__OpLibIdx__) = (((TBX_UINT32)(TBX_ADDR)(__OpLibContext__)) & 0x0000FFFF); \
}
#define TB640_FSK_UPDATE_STATS(__StatsEntry__,__Value__) \
TBX_SEM_GET (g_StressStatsSem, TBX_SEM_WAIT_FOREVER); \
if (g_StressStats.fStatsActivated == TBX_TRUE) \
g_StressStats.__StatsEntry__ = __Value__; \
TBX_SEM_GIV (g_StressStatsSem)
#define TB640_FSK_INCREMENT_STATS(__StatsEntry__,__Value__) \
TBX_SEM_GET (g_StressStatsSem, TBX_SEM_WAIT_FOREVER); \
if (g_StressStats.fStatsActivated == TBX_TRUE) \
g_StressStats.__StatsEntry__ += __Value__; \
TBX_SEM_GIV (g_StressStatsSem)
#define TB640_FSK_INCREMENT_TRANSIANT_CALL(__Value__) \
TBX_SEM_GET (g_AppContext->TransientCallsSem, TBX_SEM_WAIT_FOREVER); \
g_AppContext->un32TransientCalls += (__Value__); \
TBX_SEM_GIV (g_AppContext->TransientCallsSem)
#define TB640_FSK_DECREMENT_TRANSIANT_CALL(__Value__) \
TBX_SEM_GET (g_AppContext->TransientCallsSem, TBX_SEM_WAIT_FOREVER); \
g_AppContext->un32TransientCalls -= (__Value__); \
TBX_SEM_GIV (g_AppContext->TransientCallsSem)
/*
* Lock / unlock functions
*/
#ifdef WIN32
#define CurrentThreadId GetCurrentThreadId
#else
#define CurrentThreadId pthread_self
#endif
/* Macro that locks the lock for the specified adapter / trunk */
#define TB640FskLock( _un32AdapterIdx, _un32TrunkIdx ) \
{ \
PTB640_FSK_ADAPTER_INFO pAdapterInfo; \
PTB640_FSK_TRUNK_INFO pTrunkInfo; \
\
/* Validation */ \
if( (_un32AdapterIdx) >= g_AppContext->un32NbAdapter ) \
{ \
TB640_FSK_LOG \
( \
TRACE_LEVEL_ALWAYS, \
"ERROR Can't lock semaphore, invalid adapter index %u\n" \
" Thread %u, line %d of file %s\n", \
(unsigned int)(_un32AdapterIdx), \
(unsigned int)(CurrentThreadId()), \
(unsigned int)(__LINE__), \
__FILE__ \
); \
} \
else if( (_un32TrunkIdx) >= TB640_FSK_MAX_SUPPORTED_TRUNKS_PER_ADAPTER ) \
{ \
TB640_FSK_LOG \
( \
TRACE_LEVEL_ALWAYS, \
"ERROR Can't lock semaphore, invalid trunk index %u\n" \
" Thread %u, line %d of file %s\n", \
(unsigned int)(_un32TrunkIdx), \
(unsigned int)(CurrentThreadId()), \
(unsigned int)(__LINE__), \
__FILE__ \
); \
} \
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -