5 #include "BasicTypes/WUComPtr.h"
8 #include "WavesPublicAPI/wstdint.h"
10 typedef int32_t wvComPtr[2];
12 // ConvertDPtr has the exact format of a vfp callback function, but it is a local function, native only.
13 // It converts a pointer in either 32 bits or 64 bits to a place-holder of 64 bits in coefs/states/external memory.
14 // pData is expected to point to a pre-allocate space enough for storing a pointer (posibly two single-precision coefs).
15 // Since pointers are not transferable between hardwares, at preset time no need for a shell callback.
16 // We keep this as a cALGORITHM for compatibility with the rest of the convert functions
17 //================================================================================
18 inline uint32_t vfpConvertDPtr(const void* InPointer, void* pData)
19 //================================================================================
21 uint64_t *pL = (uint64_t *)pData;
22 *pL = (uint64_t)InPointer;
23 return (uint32_t)sizeof(uint64_t);
29 // data in that struct must be the same type of the Coefs/States type!
30 int32_t LSW; // Least significant word
31 int32_t MSW; // Most significant word
34 inline wvComPtr PackToComPtr(const intptr_t in_PtrToPack)
35 // take ptr that hosted in intptr_t type
36 // and pack it to wvComPtr container type (MSW and LSW of 32bit each)
39 int64_t t_PtrToPack = static_cast<int64_t>(in_PtrToPack);
40 // This packing is xPlatform coding for x32 and x64
41 // #ifdef for x64 - intptr_t is 64 bit
42 retVal.LSW = static_cast<int32_t>(t_PtrToPack & intptr_t(0xFFFFFFFF));
43 retVal.MSW = (static_cast<int32_t>(t_PtrToPack>>32));
45 // #ifdef for x32 - intptr_t is 32 bit
46 // retVal.LSW = int32_t(in_PtrToPack);
52 inline intptr_t UnpackComPtr( const wvComPtr in_ComPtrToUnpack)
53 // take wvComPtr with MSW and LSW of 32bit each
54 // and unpack it to intptr_t type
58 // This unpacking is xPlatform coding for x32 and x64
59 // #ifdef for x64 - intptr_t is 64 bit so use intptr_t instead of int64_t
60 int64_t PtrAt64 = static_cast<int64_t>(in_ComPtrToUnpack.MSW);
62 PtrAt64 |= static_cast<int64_t>(in_ComPtrToUnpack.LSW);
63 retVal = static_cast<intptr_t>(PtrAt64);
66 // #ifdef for x32 - intptr_t is 32 bit
67 // retVal = static_cast<intptr_t>(retVal.LSW);
73 //////////////////////////////////////////////////////////////////////////
74 inline uint32_t ComPtr_to_DSP( const intptr_t PtrToConvert, char* pDataStruct )
77 *(reinterpret_cast<wvComPtr *>(pDataStruct)) = PackToComPtr(PtrToConvert);
79 return uint32_t(sizeof(wvComPtr));
81 //////////////////////////////////////////////////////////////////////////
83 //////////////////////////////////////////////////////////////////////////
84 inline uint32_t DSP_to_ComPtr( const char* pDataStruct, intptr_t *ThePtr)
85 // pDataStruct is pointing to wvComPtr in the Coefs/States
86 // the function reconstruct the pointer into ThePtr
89 *ThePtr = UnpackComPtr(*(reinterpret_cast<const wvComPtr *>(pDataStruct)));
91 return uint32_t(sizeof(wvComPtr));
93 //////////////////////////////////////////////////////////////////////////
96 #endif //#if !defined(__WUComPtr_h__)