当前位置: 首页>>代码示例>>C++>>正文


C++ DEBUG_LVL_ERROR_TRACE函数代码示例

本文整理汇总了C++中DEBUG_LVL_ERROR_TRACE函数的典型用法代码示例。如果您正苦于以下问题:C++ DEBUG_LVL_ERROR_TRACE函数的具体用法?C++ DEBUG_LVL_ERROR_TRACE怎么用?C++ DEBUG_LVL_ERROR_TRACE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了DEBUG_LVL_ERROR_TRACE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getMacAdrs

//------------------------------------------------------------------------------
static void getMacAdrs(const char* pIfName_p, UINT8* pMacAddr_p)
{
    ULONG                 outBufLen;
    PIP_ADAPTER_ADDRESSES pAdapterAddresses;
    PIP_ADAPTER_ADDRESSES pAdapter = NULL;
    UINT32                retVal = 0;

    // search for the corresponding MAC address via IPHLPAPI
    outBufLen = sizeof(IP_ADAPTER_ADDRESSES);
    pAdapterAddresses = (IP_ADAPTER_ADDRESSES*)OPLK_MALLOC(sizeof(IP_ADAPTER_ADDRESSES));
    if (pAdapterAddresses == NULL)
    {
        DEBUG_LVL_ERROR_TRACE("Error allocating memory needed to call GetAdaptersAdresses\n");
        goto Exit;
    }

    // Make an initial call to GetAdaptersAdresses to get
    // the necessary size into the outBufLen variable
    retVal = GetAdaptersAddresses(AF_UNSPEC, 0, NULL, pAdapterAddresses, &outBufLen);
    if (retVal == ERROR_BUFFER_OVERFLOW)
    {
        OPLK_FREE(pAdapterAddresses);

        pAdapterAddresses = (IP_ADAPTER_ADDRESSES*)OPLK_MALLOC(outBufLen);
        if (pAdapterAddresses == NULL)
        {
            DEBUG_LVL_ERROR_TRACE("Error allocating memory needed to call GetAdaptersAdresses\n");
            goto Exit;
        }
    }

    // Get the real values
    retVal = GetAdaptersAddresses(AF_UNSPEC, 0, NULL, pAdapterAddresses, &outBufLen);
    if (retVal == NO_ERROR)
    {
        pAdapter = pAdapterAddresses;
        while (pAdapter)
        {
            if (pAdapter->IfType == IF_TYPE_ETHERNET_CSMACD)
            {
                if (strstr(pIfName_p, pAdapter->AdapterName) != NULL)
                {   // corresponding adapter found
                    OPLK_MEMCPY(pMacAddr_p, pAdapter->PhysicalAddress, min(pAdapter->PhysicalAddressLength, 6));
                    break;
                }
            }
            pAdapter = pAdapter->Next;
        }
    }
    else
    {
        DEBUG_LVL_ERROR_TRACE("GetAdaptersAddresses failed with error: %d\n", retVal);
    }

    if (pAdapterAddresses)
        OPLK_FREE(pAdapterAddresses);

Exit:
    return;
}
开发者ID:Kalycito-open-automation,项目名称:openPOWERLINK_V2,代码行数:61,代码来源:edrv-pcap_win.c

示例2: edrv_allocTxBuffer

//------------------------------------------------------------------------------
tOplkError edrv_allocTxBuffer(tEdrvTxBuffer* pBuffer_p)
{
    tNdisErrorStatus    ndisStatus;
    void*               pTxBuffer = NULL;

    if (pBuffer_p->maxBufferSize > EDRV_MAX_BUFFER_SIZE)
        return kErrorEdrvNoFreeBufEntry;

    ndisStatus = ndis_getTxBuff(&pTxBuffer, pBuffer_p->maxBufferSize,
                                &pBuffer_p->txBufferNumber.pArg);

    if (ndisStatus != kNdisStatusSuccess)
    {
        DEBUG_LVL_ERROR_TRACE("%s Tx buffers currently not allocated %x\n", __func__, ndisStatus);
        return kErrorEdrvNoFreeBufEntry;
    }

    if ((pTxBuffer != NULL) && (pBuffer_p->txBufferNumber.pArg != NULL))
    {
        pBuffer_p->pBuffer = (UINT8*)pTxBuffer;
    }
    else
    {
        DEBUG_LVL_ERROR_TRACE("%s Error Allocating buffer\n", __func__);
        return kErrorEdrvNoFreeBufEntry;
    }

    return kErrorOk;
}
开发者ID:Questio,项目名称:openPOWERLINK_V2,代码行数:30,代码来源:edrv-ndisintermediate.c

示例3: edrvWorkerThread

//------------------------------------------------------------------------------
static DWORD WINAPI edrvWorkerThread(LPVOID pArgument_p)
{
    tEdrvInstance*  pInstance = (tEdrvInstance*)pArgument_p;
    int             pcapRet;

    // Increase thread priority
    SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);

    // Start the pcap capturing loop
    // This function is blocking and returns only, if the loop is broken,
    // e.g. because of calling pcap_breakloop()
    pcapRet = pcap_loop(pInstance->pPcap, -1, packetHandler, (u_char*)pInstance);

    // Evaluate the reason of a loop break
    switch (pcapRet)
    {
        case 0:
            DEBUG_LVL_ERROR_TRACE("%s(): pcap_loop ended because 'cnt' is exhausted.\n", __func__);
            break;

        case -1:
            DEBUG_LVL_ERROR_TRACE("%s(): pcap_loop ended because of an error!\n", __func__);
            break;

        case -2:
            DEBUG_LVL_ERROR_TRACE("%s(): pcap_loop ended normally.\n", __func__);
            break;

        default:
            DEBUG_LVL_ERROR_TRACE("%s(): pcap_loop ended (unknown return value).\n", __func__);
            break;
    }

    return 0;
}
开发者ID:Kalycito-open-automation,项目名称:openPOWERLINK_V2,代码行数:36,代码来源:edrv-pcap_win.c

示例4: ctrlucal_init

//------------------------------------------------------------------------------
tOplkError ctrlucal_init(void)
{
    tHostifReturn   hifRet;
    tHostifConfig   hifConfig;

    OPLK_MEMSET(&instance_l, 0, sizeof(instance_l));
    OPLK_MEMSET(&hifConfig, 0, sizeof(hifConfig));

    hifConfig.instanceNum = 0;
    hifConfig.pBase = (UINT8*)HOSTIF_BASE; //FIXME: Get it from somewhere else?
    hifConfig.version.revision = HOSTIF_VERSION_REVISION;
    hifConfig.version.minor = HOSTIF_VERSION_MINOR;
    hifConfig.version.major = HOSTIF_VERSION_MAJOR;

    hifRet = hostif_create(&hifConfig, &instance_l.hifInstance);
    if (hifRet != kHostifSuccessful)
    {
        DEBUG_LVL_ERROR_TRACE("Could not initialize host interface (0x%X)\n", hifRet);
        return kErrorNoResource;
    }

    //disable master IRQ
    instance_l.fIrqMasterEnable = FALSE;
    hifRet = hostif_irqMasterEnable(instance_l.hifInstance, instance_l.fIrqMasterEnable);
    if (hifRet != kHostifSuccessful)
    {
        DEBUG_LVL_ERROR_TRACE("Could not disable master IRQ (0x%X)\n", hifRet);
        return kErrorNoResource;
    }

    return kErrorOk;
}
开发者ID:OpenAutomationTechnologies,项目名称:openPOWERLINK_V2,代码行数:33,代码来源:ctrlucal-hostif.c

示例5: getSharedMemory

//------------------------------------------------------------------------------
static void* getSharedMemory(tHostifInstance pHifInstance_p)
{
    tHostifReturn   hifRet;
    void*           pBase;
    size_t          span;

    hifRet = hostif_getBuf(pHifInstance_p, kHostifInstIdTimesync, &pBase, &span);
    if (hifRet != kHostifSuccessful)
    {
        DEBUG_LVL_ERROR_TRACE("%s() Could not get buffer from host interface (%d)\n",
                              __func__,
                              hifRet);
        return NULL;
    }

    if (span < sizeof(tTimesyncSharedMemory))
    {
        DEBUG_LVL_ERROR_TRACE("%s() Time Synchronization Buffer too small (shall be: %lu)\n",
                              __func__,
                              (ULONG)sizeof(tTimesyncSharedMemory));
        return NULL;
    }

    return pBase;
}
开发者ID:OpenAutomationTechnologies,项目名称:openPOWERLINK_V2,代码行数:26,代码来源:timesyncucal-hostif.c

示例6: circbuf_createInstance

//------------------------------------------------------------------------------
tCircBufInstance* circbuf_createInstance(UINT8 id_p, BOOL fNew_p)
{
    tCircBufInstance*           pInstance;
    tCircBufArchInstance*       pArch;
    TCHAR                       mutexName[MAX_PATH];

    UNUSED_PARAMETER(fNew_p);

    if ((pInstance = OPLK_MALLOC(sizeof(tCircBufInstance) +
                                 sizeof(tCircBufArchInstance))) == NULL)
    {
        DEBUG_LVL_ERROR_TRACE("%s() malloc failed!\n", __func__);
        return NULL;
    }
    OPLK_MEMSET(pInstance, 0, sizeof(tCircBufInstance) + sizeof(tCircBufArchInstance));
    pInstance->pCircBufArchInstance = (BYTE*)pInstance + sizeof(tCircBufInstance);
    pInstance->bufferId = id_p;

    pArch = (tCircBufArchInstance*)pInstance->pCircBufArchInstance;

    sprintf(mutexName, "Local\\circbufMutex%d", id_p);
    if ((pArch->lockMutex = CreateMutex(NULL, FALSE, mutexName)) == NULL)
    {
        DEBUG_LVL_ERROR_TRACE("%s() creating mutex failed!\n", __func__);
        OPLK_FREE(pInstance);
        return NULL;
    }

    return pInstance;
}
开发者ID:Openwide-Ingenierie,项目名称:openpowerlink-rtnet,代码行数:31,代码来源:circbuf-win32.c

示例7: timesyncucal_init

//------------------------------------------------------------------------------
tOplkError timesyncucal_init(tSyncCb pfnSyncCb_p)
{
    tHostifReturn   hifRet;

    OPLK_MEMSET(&instance_l, 0, sizeof(tTimesyncucalInstance));

    instance_l.pHifInstance = hostif_getInstance(0);

    if (instance_l.pHifInstance == NULL)
    {
        DEBUG_LVL_ERROR_TRACE("%s: Could not find hostif instance!\n", __func__);
        return kErrorNoResource;
    }

    hifRet = hostif_irqRegHdl(instance_l.pHifInstance, kHostifIrqSrcSync, hostifIrqSyncCb);
    if (hifRet != kHostifSuccessful)
    {
        DEBUG_LVL_ERROR_TRACE("%s: Enable irq not possible!\n", __func__);
        return kErrorNoResource;
    }

    instance_l.pfnSyncCb = pfnSyncCb_p;

#if defined(CONFIG_INCLUDE_SOC_TIME_FORWARD)
    instance_l.pSharedMemory = (tTimesyncSharedMemory*)getSharedMemory(instance_l.pHifInstance);
#endif

    return kErrorOk;
}
开发者ID:OpenAutomationTechnologies,项目名称:openPOWERLINK_V2,代码行数:30,代码来源:timesyncucal-hostif.c

示例8: eventucal_init

//------------------------------------------------------------------------------
tOplkError eventucal_init(void)
{
    tOplkError          ret = kErrorOk;
    struct sched_param  schedParam;

    OPLK_MEMSET(&instance_l, 0, sizeof(tEventuCalInstance));

    instance_l.fd = ctrlucal_getFd();
    instance_l.fStopKernelThread = FALSE;
    instance_l.fStopProcessThread = FALSE;

    sem_unlink("/semUserEvent");    // Deinitialize any existing instance of the semaphore

    if ((instance_l.semUserData = sem_open("/semUserEvent", O_CREAT | O_RDWR, S_IRWXG, 0)) == SEM_FAILED)
        goto Exit;

    if (eventucal_initQueueCircbuf(kEventQueueUInt) != kErrorOk)
        goto Exit;

    if (eventucal_setSignalingCircbuf(kEventQueueUInt, signalUIntEvent) != kErrorOk)
        goto Exit;

    // Create thread for fetching new user data from kernel
    if (pthread_create(&instance_l.kernelEventThreadId, NULL, k2uEventFetchThread, NULL) != 0)
        goto Exit;

    schedParam.sched_priority = KERNEL_EVENT_FETCH_THREAD_PRIORITY;
    if (pthread_setschedparam(instance_l.kernelEventThreadId, SCHED_FIFO, &schedParam) != 0)
    {
        DEBUG_LVL_ERROR_TRACE("%s(): couldn't set K2U thread scheduling parameters! %d\n",
                              __func__,
                              schedParam.sched_priority);
    }

#if (defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 12))
    pthread_setname_np(instance_l.kernelEventThreadId, "oplk-eventufetch");
#endif

    // Create thread for processing pending user data
    if (pthread_create(&instance_l.processEventThreadId, NULL, eventProcessThread, NULL) != 0)
        goto Exit;

    schedParam.sched_priority = EVENT_PROCESS_THREAD_PRIORITY;
    if (pthread_setschedparam(instance_l.processEventThreadId, SCHED_FIFO, &schedParam) != 0)
    {
        DEBUG_LVL_ERROR_TRACE("%s(): couldn't set event process thread scheduling parameters! %d\n",
                              __func__,
                              schedParam.sched_priority);
    }

#if (defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 12))
    pthread_setname_np(instance_l.processEventThreadId, "oplk-eventuprocess");
#endif
    instance_l.fInitialized = TRUE;
    return kErrorOk;

Exit:
    eventucal_exit();
    return ret;
}
开发者ID:chutao,项目名称:openPOWERLINK_V2,代码行数:61,代码来源:eventucal-linuxpcie.c

示例9: circbuf_createInstance

//------------------------------------------------------------------------------
tCircBufInstance* circbuf_createInstance(UINT8 id_p, BOOL fNew_p)
{
    tCircBufInstance*           pInstance;
    tCircBufArchInstance*       pArch;
    char                        semName[16];

    if ((pInstance = OPLK_MALLOC(sizeof(tCircBufInstance) +
                                 sizeof(tCircBufArchInstance))) == NULL)
    {
        DEBUG_LVL_ERROR_TRACE("%s() malloc failed!\n", __func__);
        return NULL;
    }
    OPLK_MEMSET(pInstance, 0, sizeof(tCircBufInstance) + sizeof(tCircBufArchInstance));
    pInstance->pCircBufArchInstance = (BYTE*)pInstance + sizeof(tCircBufInstance);
    pInstance->bufferId = id_p;

    pArch = (tCircBufArchInstance*)pInstance->pCircBufArchInstance;

    sprintf(semName, "/semCircbuf-%d", id_p);
     
    if (fNew_p)
    {
	sem_unlink(semName);
    }

    if ((pArch->lockSem = sem_open(semName, O_CREAT, S_IRWXG, 1)) == SEM_FAILED)
    {
        DEBUG_LVL_ERROR_TRACE("%s() open sem failed!\n", __func__);
        OPLK_FREE(pInstance);
        return NULL;
    }

    return pInstance;
}
开发者ID:Openwide-Ingenierie,项目名称:openpowerlink-rtnet,代码行数:35,代码来源:circbuf-posixshm-xeno.c

示例10: pdoucal_allocateMem

//------------------------------------------------------------------------------
tOplkError pdoucal_allocateMem(size_t memSize_p, BYTE** ppPdoMem_p)
{
    INT     ret = 0;

    *ppPdoMem_p = mmap(NULL, memSize_p + ATOMIC_MEM_OFFSET + getpagesize(), PROT_READ | PROT_WRITE, MAP_SHARED,
                       fd_l, 0);
    if (*ppPdoMem_p == MAP_FAILED)
    {
        DEBUG_LVL_ERROR_TRACE("%s() mmap failed!\n", __func__);
        *ppPdoMem_p = NULL;
        return kErrorNoResource;
    }

    if ((ret = ioctl(fd_l, PLK_CMD_PDO_MAP_OFFSET, &pdoMemOffset)) != 0)
    {
        DEBUG_LVL_ERROR_TRACE("%s() error %d\n", __func__, ret);
        return kErrorNoResource;
    }
    else
    {
        *ppPdoMem_p = (UINT8*)((size_t)(*ppPdoMem_p) + (size_t)pdoMemOffset);
    }

    return kErrorOk;
}
开发者ID:Questio,项目名称:openPOWERLINK_V2,代码行数:26,代码来源:pdoucalmem-linuxpcie.c

示例11: createTimestampShm

//------------------------------------------------------------------------------
static tOplkError createTimestampShm(void)
{
    instance_l.memSize = sizeof(tTimesyncSharedMemory);

    // Initialize shared memory for SOC timestamp
    instance_l.fd = shm_open(TIMESYNC_TIMESTAMP_SHM, O_RDWR, 0);

    if (instance_l.fd < 0)
    {
        DEBUG_LVL_ERROR_TRACE("%s() Initialization of shared memory failed!\n",
                              __func__);
        return kErrorNoResource;
    }

    instance_l.pSharedMemory = (void*)mmap(NULL,
                                           instance_l.memSize,     // Memory size
                                           PROT_READ | PROT_WRITE, // Map as read and write memory
                                           MAP_SHARED,             // Map as shared memory
                                           instance_l.fd,          // File descriptor for POWERLINK device
                                           0);

    // Check for valid memory mapping
    if (instance_l.pSharedMemory == MAP_FAILED)
    {
        DEBUG_LVL_ERROR_TRACE("%s() timesync shared memory mmap failed!\n",
                              __func__);
        instance_l.pSharedMemory = NULL;
        //Unlink timesync shared memory
        shm_unlink(TIMESYNC_TIMESTAMP_SHM);
        return kErrorNoResource;
    }

    return kErrorOk;
}
开发者ID:Kalycito-open-automation,项目名称:openPOWERLINK_V2,代码行数:35,代码来源:timesyncucal-bsdsem.c

示例12: drv_mapPdoMem

//------------------------------------------------------------------------------
tOplkError drv_mapPdoMem(UINT8** ppKernelMem_p, UINT8** ppUserMem_p,
                         size_t* pMemSize_p)
{
    tOplkError      ret;

    // Get PDO memory
    ret = pdokcal_getPdoMemRegion((UINT8**)&pdoMemInfo_l.pKernelVa,
                                  &pdoMemInfo_l.memSize);

    if (ret != kErrorOk || pdoMemInfo_l.pKernelVa == NULL)
        return kErrorNoResource;

    if (*pMemSize_p > pdoMemInfo_l.memSize)
    {
        DEBUG_LVL_ERROR_TRACE("%s() Higher Memory requested (Kernel-%d User-%d) !\n",
                              __func__, pdoMemInfo_l.memSize, *pMemSize_p);
        *pMemSize_p = 0;
        return kErrorNoResource;
    }

    // Allocate new MDL pointing to PDO memory
    pdoMemInfo_l.pMdl = IoAllocateMdl(pdoMemInfo_l.pKernelVa, pdoMemInfo_l.memSize, FALSE, FALSE,
                                      NULL);

    if (pdoMemInfo_l.pMdl == NULL)
    {
        DEBUG_LVL_ERROR_TRACE("%s() Error allocating MDL !\n", __func__);
        return kErrorNoResource;
    }

    // Update the MDL with physical addresses
    MmBuildMdlForNonPagedPool(pdoMemInfo_l.pMdl);

    // Map the memory in user space and get the address
    pdoMemInfo_l.pUserVa = MmMapLockedPagesSpecifyCache(pdoMemInfo_l.pMdl,    // MDL
                                                        UserMode,             // Mode
                                                        MmCached,             // Caching
                                                        NULL,                 // Address
                                                        FALSE,                // Bug-check?
                                                        NormalPagePriority);  // Priority

    if (pdoMemInfo_l.pUserVa == NULL)
    {
        MmUnmapLockedPages(pdoMemInfo_l.pUserVa, pdoMemInfo_l.pMdl);
        IoFreeMdl(pdoMemInfo_l.pMdl);
        DEBUG_LVL_ERROR_TRACE("%s() Error mapping MDL !\n", __func__);
        return kErrorNoResource;
    }

    *ppKernelMem_p = pdoMemInfo_l.pKernelVa;
    *ppUserMem_p = pdoMemInfo_l.pUserVa;
    *pMemSize_p = pdoMemInfo_l.memSize;

    TRACE("Mapped memory info U:%p K:%p size %x", pdoMemInfo_l.pUserVa,
                                                 (UINT8*)pdoMemInfo_l.pKernelVa,
                                                 pdoMemInfo_l.memSize);
    return kErrorOk;
}
开发者ID:Questio,项目名称:openPOWERLINK_V2,代码行数:59,代码来源:drvintf.c

示例13: timeru_setTimer

//------------------------------------------------------------------------------
tOplkError timeru_setTimer(tTimerHdl* pTimerHdl_p, ULONG timeInMs_p, tTimerArg argument_p)
{
    tTimeruData*        pData;
    struct itimerspec   relTime;
    tHrtimerSig         sig;

    if (pTimerHdl_p == NULL)
        return kErrorTimerInvalidHandle;

    pData = (tTimeruData*)OPLK_MALLOC(sizeof(tTimeruData));
    if (pData == NULL)
    {
        DEBUG_LVL_ERROR_TRACE("error allocating user timer memory!\n");
        return kErrorNoResource;
    }

    OPLK_MEMCPY(&pData->timerArg, &argument_p, sizeof(tTimerArg));

    addTimer(pData);

    sig.sigType = kHrtimerSigMsgQueue;
    sig.sigParam.m_signalMq.msgQueue = timeruInstance_l.msgQueue;
    sig.sigParam.m_signalMq.m_sigData = (ULONG)pData;

    if (hrtimer_create(CLOCK_MONOTONIC, &sig, &pData->timer) != 0)
    {
        DEBUG_LVL_ERROR_TRACE("%s() Error hrtimer_create!\n", __func__);
        return kErrorNoResource;
    }

    if (timeInMs_p >= 1000)
    {
        relTime.it_value.tv_sec = (timeInMs_p / 1000);
        relTime.it_value.tv_nsec = (timeInMs_p % 1000) * 1000000;
    }
    else
    {
        relTime.it_value.tv_sec = 0;
        relTime.it_value.tv_nsec = timeInMs_p * 1000000;
    }

    relTime.it_interval.tv_sec = 0;
    relTime.it_interval.tv_nsec = 0;

    DEBUG_LVL_TIMERU_TRACE("%s() Set timer:%08x timeInMs_p=%ld\n",
                           __func__, *pData, timeInMs_p);

    if (hrtimer_settime(pData->timer, 0, &relTime, NULL) < 0)
    {
        DEBUG_LVL_ERROR_TRACE("%s() Error hrtimer_settime!\n", __func__);
        return kErrorTimerNoTimerCreated;
    }

    *pTimerHdl_p = (tTimerHdl)pData;

    return kErrorOk;
}
开发者ID:Openwide-Ingenierie,项目名称:openpowerlink-rtnet,代码行数:58,代码来源:timer-vxworks.c

示例14: addInstance

//------------------------------------------------------------------------------
static tOplkError addInstance(tDllCalQueueInstance* ppDllCalQueue_p,
                              tDllCalQueue dllCalQueue_p)
{
    tOplkError                  ret = kErrorOk;
    tCircBufError               error = kCircBufOk;
    tDllCalCircBufInstance*     pDllCalCircBufInstance;

    pDllCalCircBufInstance = (tDllCalCircBufInstance*)OPLK_MALLOC(sizeof(tDllCalCircBufInstance));
    if (pDllCalCircBufInstance == NULL)
    {
        DEBUG_LVL_ERROR_TRACE("%s() malloc error!\n", __func__);
        ret = kErrorNoResource;
        goto Exit;
    }

    //store parameters in instance
    pDllCalCircBufInstance->dllCalQueue = dllCalQueue_p;
    //initialize shared buffer
    switch (pDllCalCircBufInstance->dllCalQueue)
    {
        case kDllCalQueueTxGen:
            error = circbuf_alloc(CIRCBUF_DLLCAL_TXGEN, CONFIG_DLLCAL_BUFFER_SIZE_TX_GEN,
                                  &pDllCalCircBufInstance->pCircBufInstance);
            break;

        case kDllCalQueueTxNmt:
            error = circbuf_alloc(CIRCBUF_DLLCAL_TXNMT, CONFIG_DLLCAL_BUFFER_SIZE_TX_NMT,
                                  &pDllCalCircBufInstance->pCircBufInstance);
            break;

        case kDllCalQueueTxSync:
            error = circbuf_alloc(CIRCBUF_DLLCAL_TXSYNC, CONFIG_DLLCAL_BUFFER_SIZE_TX_SYNC,
                                  &pDllCalCircBufInstance->pCircBufInstance);
            break;

        case kDllCalQueueTxVeth:
            error = circbuf_alloc(CIRCBUF_DLLCAL_TXVETH, CONFIG_DLLCAL_BUFFER_SIZE_TX_VETH,
                                  &pDllCalCircBufInstance->pCircBufInstance);
            break;

        default:
            DEBUG_LVL_ERROR_TRACE("%s() Invalid Queue!\n", __func__);
            ret = kErrorInvalidInstanceParam;
            break;
    }
    if (error != kCircBufOk)
    {
        DEBUG_LVL_ERROR_TRACE("%s() circbuf_alloc error!\n", __func__);
        ret = kErrorNoResource;
        goto Exit;
    }
    *ppDllCalQueue_p = (tDllCalQueueInstance*)pDllCalCircBufInstance;

Exit:
    return ret;
}
开发者ID:Openwide-Ingenierie,项目名称:openpowerlink-rtnet,代码行数:57,代码来源:dllkcal-circbuf.c

示例15: circbuf_allocBuffer

//------------------------------------------------------------------------------
tCircBufError circbuf_allocBuffer(tCircBufInstance* pInstance_p, size_t* pSize_p)
{
    char                        shmName[16];
    size_t                      size;
    tCircBufArchInstance*       pArch;
    size_t                      pageSize;
    unsigned int i;

    pArch = (tCircBufArchInstance*)pInstance_p->pCircBufArchInstance;

    sprintf(shmName, "/shmCircbuf-%d", pInstance_p->bufferId);
    pageSize = (sizeof(tCircBufHeader) + sysconf(_SC_PAGE_SIZE) - 1) & (~(sysconf(_SC_PAGE_SIZE) - 1));
    size = *pSize_p + pageSize;

    if ((pArch->fd = shm_open(shmName, O_RDWR | O_CREAT, 0)) < 0)
    {
        DEBUG_LVL_ERROR_TRACE("%s() shm_open failed!\n", __func__);
        return kCircBufNoResource;
    }

    if (ftruncate(pArch->fd, size) == -1)
    {
        DEBUG_LVL_ERROR_TRACE("%s() ftruncate failed!\n", __func__);
        close(pArch->fd);
        shm_unlink(shmName);
        return kCircBufNoResource;
    }

    pInstance_p->pCircBufHeader = mmap(NULL, sizeof(tCircBufHeader),
                                       PROT_READ | PROT_WRITE, MAP_SHARED, pArch->fd, 0);
    if (pInstance_p->pCircBufHeader == MAP_FAILED)
    {
        DEBUG_LVL_ERROR_TRACE("%s() mmap header failed!\n", __func__);
        close(pArch->fd);
        shm_unlink(shmName);
        return kCircBufNoResource;
    }

    pInstance_p->pCircBuf = mmap(NULL, *pSize_p, PROT_READ | PROT_WRITE, MAP_SHARED,
                                 pArch->fd, pageSize);
    if (pInstance_p->pCircBuf == MAP_FAILED)
    {
        DEBUG_LVL_ERROR_TRACE("%s() mmap buffer failed!\n", __func__);
        munmap(pInstance_p->pCircBufHeader, sizeof(tCircBufHeader));
        close(pArch->fd);
        shm_unlink(shmName);
        return kCircBufNoResource;
    }

    //pre-fault pages
    for(i = 0; i < *pSize_p; i+= pageSize)
	*(UINT32*)(pInstance_p->pCircBuf + i) = 0;

    return kCircBufOk;
}
开发者ID:Openwide-Ingenierie,项目名称:openpowerlink-rtnet,代码行数:56,代码来源:circbuf-posixshm-xeno.c


注:本文中的DEBUG_LVL_ERROR_TRACE函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。