Reputation: 35
The problem is, that I don't quite understand what the following definition does. Can somebody explain it to me?
#define Vpc3MemSet_( _pToVpc3Memory, _bValue, _wLength )\
Vpc3MemSet( _pToVpc3Memory, _bValue, _wLength )
Upvotes: 1
Views: 132
Reputation: 35
One more thing, however. This is the whole #define sequence:
#if VPC3_SERIAL_MODE
#define CopyToVpc3_( _pToVpc3Memory, _pLocalMemory, _wLength )\
CopyToVpc3( _pToVpc3Memory, _pLocalMemory, _wLength )
#define CopyFromVpc3_( _pLocalMemory, _pToVpc3Memory, _wLength )\
CopyFromVpc3( _pLocalMemory, _pToVpc3Memory, _wLength )
#define Vpc3MemSet_( _pToVpc3Memory, _bValue, _wLength )\
Vpc3MemSet( _pToVpc3Memory, _bValue, _wLength )
#define Vpc3MemCmp_( _pToVpc3Memory1, _pToVpc3Memory2, _wLength )\
Vpc3MemCmp( _pToVpc3Memory1, _pToVpc3Memory2, _wLength )
#else
#define CopyToVpc3_( _pToVpc3Memory, _pLocalMemory, _wLength )\
memcpy( _pToVpc3Memory, _pLocalMemory, _wLength )
#define CopyFromVpc3_( _pLocalMemory, _pToVpc3Memory, _wLength )\
memcpy( _pLocalMemory, _pToVpc3Memory, _wLength )
#define Vpc3MemSet_( _pToVpc3Memory, _bValue, _wLength )\
memset( _pToVpc3Memory, _bValue, _wLength )
#define Vpc3MemCmp_( _pToVpc3Memory1, _pToVpc3Memory2, _wLength )\
memcmp( _pToVpc3Memory1, _pToVpc3Memory2, _wLength )
#endif /* #if VPC3_SERIAL_MODE */
So the four functions have two definitions depending on whether you are in serial, or parallel mode. Yet, the memset() function is called in application source file, like the following:
/*-----------------------------------------------------------------------*/
/* init application data */
/*-----------------------------------------------------------------------*/
memset( &sDpAppl, 0, sizeof( sDpAppl ) );
/*-----------------------------------------------------------------------*/
/* initialize VPC3 */
/*-----------------------------------------------------------------------*/
#if VPC3_SERIAL_MODE
Vpc3AsicAddress = (VPC3_ADR)VPC3_ASIC_ADDRESS;
pVpc3 = &sVpc3OnlyForInit;
pDpSystem = &sDpSystemChannel1;
memset( pVpc3, 0, sizeof( VPC3_STRUC ) );
#else
pVpc3Channel1 = (VPC3_STRUC_PTR)VPC3_ASIC_ADDRESS;
Vpc3AsicAddress = (VPC3_ADR)VPC3_ASIC_ADDRESS;
pVpc3 = pVpc3Channel1;
pDpSystem = &sDpSystemChannel1;
#endif//#if VPC3_SERIAL_MODE
As if this were a different function. Or, am I still missing something? :/ By the way, I am in serial mode and I already defined CopyToVpc3(), CopyFromVpc3(), Vpc3MemSet(), Vpc3MemCmp().
Upvotes: 0
Reputation: 17711
Your macro does nearly nothing. It replaces Vpc3MemSet_
(with underscore) by Vpc3MemSet
(without underscore). Such macros usually make sense if there are different, platform-dependent variants (say for Linux, macOS, and Windows). For (fictional) example:
#ifdef __WINDOWS__
#define Vpc3MemSet_( _pToVpc3Memory, _bValue, _wLength )\
Vpc3MemSet( _pToVpc3Memory, _bValue, _wLength )
#else
#define Vpc3MemSet_( _pToVpc3Memory, _bValue, _wLength )\
memset(_pToVpc3Memory, _bValue, _wLength * sizeof(Vpc3))
#endif
You can call the platform-dependent function with the same macro call:
Vpc3MemSet_(memory, value, length);
This will expand to different function calls on Windows and Linux.
Upvotes: 1