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


C++ C_ASSERT函数代码示例

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


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

示例1: hk_app

SAT_returnState hk_app(tc_tm_pkt *pkt) {

    if(!C_ASSERT(pkt != NULL && pkt->data != NULL) == true) { return SATR_ERROR; }
    if(!C_ASSERT(pkt->ser_subtype == TC_HK_REPORT_PARAMETERS ||
                 pkt->ser_subtype == TM_HK_PARAMETERS_REPORT) == true) {return SATR_ERROR; }

    if(pkt->ser_subtype == TC_HK_REPORT_PARAMETERS) {

        tc_tm_pkt *temp_pkt = 0;
        HK_struct_id sid = (HK_struct_id)pkt->data[0];

        hk_crt_empty_pkt_TM(&temp_pkt, (TC_TM_app_id)pkt->dest_id, sid);

        if(!C_ASSERT(temp_pkt != NULL) == true) {
            return SATR_ERROR;
        }

        route_pkt(temp_pkt);

    } else if(pkt->ser_subtype == TM_HK_PARAMETERS_REPORT) {

        const SAT_returnState res = hk_parameters_report(pkt->app_id, (HK_struct_id)pkt->data[0],  pkt->data, pkt->len);

        if(res == SATR_OK) {
            pkt->verification_state = SATR_OK;
        }
    }

    return SATR_OK;
}
开发者ID:nchronas,项目名称:ecss_services,代码行数:30,代码来源:housekeeping_service.c

示例2: GetImageInfoFromPEHeader

HRESULT GetImageInfoFromPEHeader( HANDLE hProcess, void* dllBase, uint16_t& machine, uint32_t& size, Address& prefBase )
{
    IMAGE_DOS_HEADER    dosHeader = { 0 };
    SIZE_T              cActual = 0;

    if ( !::ReadProcessMemory( hProcess, dllBase, &dosHeader, sizeof dosHeader, &cActual ) ) 
    {
        _ASSERT( !"Failed to read IMAGE_DOS_HEADER from loaded module" );
        return GetLastHr();
    }

    IMAGE_NT_HEADERS    ntHeaders = { 0 };
    void*               ntHeadersAddr = (void*) ((DWORD_PTR) dosHeader.e_lfanew + (DWORD_PTR) dllBase);
    
    if ( !::ReadProcessMemory( hProcess, ntHeadersAddr, &ntHeaders, sizeof ntHeaders, &cActual ) ) 
    {
        _ASSERT( !"Failed to read IMAGE_NT_HEADERS from loaded module" );
        return GetLastHr();
    }

    // These fields line up for 32 and 64-bit IMAGE_NT_HEADERS; make sure of it
    // otherwise, we would have had to check fileHeader.Characteristics & IMAGE_FILE_32BIT_MACHINE
    C_ASSERT( &((IMAGE_NT_HEADERS32*) 0)->OptionalHeader.SizeOfImage == 
              &((IMAGE_NT_HEADERS64*) 0)->OptionalHeader.SizeOfImage );
    C_ASSERT( &((IMAGE_NT_HEADERS32*) 0)->FileHeader.Machine == 
              &((IMAGE_NT_HEADERS64*) 0)->FileHeader.Machine );

    machine = ntHeaders.FileHeader.Machine;
    size = ntHeaders.OptionalHeader.SizeOfImage;
    prefBase = ntHeaders.OptionalHeader.ImageBase;

    return S_OK;
}
开发者ID:Kentorix,项目名称:MagoWrapper,代码行数:33,代码来源:Utility.cpp

示例3: seqiter_new

PmReturn_t
seqiter_new(pPmObj_t pobj, pPmObj_t *r_pobj)
{
    PmReturn_t retval;
    uint8_t *pchunk;
    pPmSeqIter_t psi;

    C_ASSERT(pobj != C_NULL);
    C_ASSERT(*r_pobj != C_NULL);

    /* Raise a TypeError if pobj is not a sequence */
    if ((OBJ_GET_TYPE(pobj) != OBJ_TYPE_STR)
            && (OBJ_GET_TYPE(pobj) != OBJ_TYPE_TUP)
            && (OBJ_GET_TYPE(pobj) != OBJ_TYPE_LST))
    {
        PM_RAISE(retval, PM_RET_EX_TYPE);
        return retval;
    }

    /* Alloc a chunk for the sequence iterator obj */
    retval = heap_getChunk(sizeof(PmSeqIter_t), &pchunk);
    PM_RETURN_IF_ERROR(retval);

    /* Set the sequence iterator's fields */
    psi = (pPmSeqIter_t)pchunk;
    OBJ_SET_TYPE(psi, OBJ_TYPE_SQI);
    psi->si_sequence = pobj;
    psi->si_index = 0;

    *r_pobj = (pPmObj_t)psi;
    return retval;
}
开发者ID:rumjack,项目名称:megapython,代码行数:32,代码来源:seq.c

示例4: seqiter_getNext

PmReturn_t
seqiter_getNext(pPmObj_t pobj, pPmObj_t *r_pitem)
{
    PmReturn_t retval;
    int16_t length;

    C_ASSERT(pobj != C_NULL);
    C_ASSERT(*r_pitem != C_NULL);
    C_ASSERT(OBJ_GET_TYPE(pobj) == OBJ_TYPE_SQI);

    /*
     * Raise TypeError if sequence iterator's object is not a sequence
     * otherwise, the get sequence's length
     */
    retval = seq_getLength(((pPmSeqIter_t)pobj)->si_sequence, &length);
    PM_RETURN_IF_ERROR(retval);

    /* Raise StopIteration if at the end of the sequence */
    if (((pPmSeqIter_t)pobj)->si_index == length)
    {
        /* Make null the pointer to the sequence */
        ((pPmSeqIter_t)pobj)->si_sequence = C_NULL;
        PM_RAISE(retval, PM_RET_EX_STOP);
        return retval;
    }

    /* Get the item at the current index */
    retval = seq_getSubscript(((pPmSeqIter_t)pobj)->si_sequence,
                              ((pPmSeqIter_t)pobj)->si_index, r_pitem);

    /* Increment the index */
    ((pPmSeqIter_t)pobj)->si_index++;

    return retval;
}
开发者ID:rumjack,项目名称:megapython,代码行数:35,代码来源:seq.c

示例5: DriverEntry

// driver entry
NTSTATUS DriverEntry(__in PDRIVER_OBJECT pDriverObject,__in PUNICODE_STRING pRegPath)
{
	PAGED_CODE();

	C_ASSERT(sizeof(CHidData) == 0x6c);
	C_ASSERT(sizeof(CDeviceExtension) == 0x200);

	NTSTATUS statusRet = STATUS_SUCCESS;

	AppleDebugPrint(DBGLEVEL_INFO,"Enter AppleKeyboard DriverEntry %p,%p\n",pDriverObject,pRegPath);

	pDriverObject->MajorFunction[IRP_MJ_CREATE] = AppleKeyboardCreate;
	pDriverObject->MajorFunction[IRP_MJ_CLOSE] = AppleKeyboardClose;
	pDriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = AppleKeyboardIoControl;
	pDriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = AppleKeyboardInternalIoControl;
	pDriverObject->MajorFunction[IRP_MJ_PNP] = AppleKeyboardPnp;
	pDriverObject->MajorFunction[IRP_MJ_FLUSH_BUFFERS] = AppleKeyboardFlush;
	pDriverObject->MajorFunction[IRP_MJ_POWER] = AppleKeyboardPower;
	pDriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = AppleKeyboardSystemControl;
	pDriverObject->DriverUnload = AppleKeyboardUnload;
	pDriverObject->DriverExtension->AddDevice = AppleKeyboardAddDevice;

	g_regPath.Length = pRegPath->Length;
	g_regPath.MaximumLength = g_regPath.Length + sizeof(WCHAR);
	g_regPath.Buffer = static_cast<PWCH>(ExAllocatePoolWithTag(PagedPool,g_regPath.MaximumLength,'Appl'));
	if(g_regPath.Buffer)
		RtlCopyMemory(g_regPath.Buffer,pRegPath->Buffer,pRegPath->Length);
	else
		statusRet = STATUS_INSUFFICIENT_RESOURCES;

	AppleDebugPrint(DBGLEVEL_INFO,"Leave DriverEntry 0x%08x\n",statusRet);

	return statusRet;
}
开发者ID:killbug2004,项目名称:applebluetoothwirelesskeyboardhiddriverforwindows,代码行数:35,代码来源:DriverMain.cpp

示例6: float_print

PmReturn_t
float_print(pPmObj_t pf)
{
    uint8_t tBuffer[32];
    uint8_t bytesWritten;
    uint8_t i;
    PmReturn_t retval = PM_RET_OK;

    C_ASSERT(pf != C_NULL);

    /* Raise TypeError if obj is not an float */
    if (OBJ_GET_TYPE(pf) != OBJ_TYPE_FLT)
    {
        PM_RAISE(retval, PM_RET_EX_TYPE);
        return retval;
    }

    /* #196: Changed to use snprintf */
    bytesWritten = snprintf((char *)&tBuffer, 32, "%f", ((pPmFloat_t) pf)->val);

    /* Sanity check */
    C_ASSERT(bytesWritten != 0);
    C_ASSERT(bytesWritten < sizeof(tBuffer));

    for (i = (uint8_t)0; i < bytesWritten; i++)
    {
        retval = plat_putByte(tBuffer[i]);
        PM_RETURN_IF_ERROR(retval);
    }
    return PM_RET_OK;
}
开发者ID:01iv3r,项目名称:OpenPilot,代码行数:31,代码来源:float.c

示例7: UpdateCacheEntryAtomically

// Helper method for updating an interface dispatch cache entry atomically. See comments by the usage of
// this method for the details of why we need this. If a racing update is detected false is returned and the
// update abandoned. This is necessary since it's not safe to update a valid cache entry (one with a non-NULL
// m_pInstanceType field) outside of a GC.
static bool UpdateCacheEntryAtomically(InterfaceDispatchCacheEntry *pEntry,
                                       EEType * pInstanceType,
                                       void * pTargetCode)
{
    C_ASSERT(sizeof(InterfaceDispatchCacheEntry) == (sizeof(void*) * 2));
    C_ASSERT(offsetof(InterfaceDispatchCacheEntry, m_pInstanceType) < offsetof(InterfaceDispatchCacheEntry, m_pTargetCode));

    return UpdatePointerPairAtomically(pEntry, pInstanceType, pTargetCode, true) == NULL;
}
开发者ID:danmosemsft,项目名称:corert,代码行数:13,代码来源:CachedInterfaceDispatch.cpp

示例8: C_ASSERT

static
int32_t
IDNA_FlagsToICU
(
	DWORD dwFlags
)
{
	C_ASSERT(IDN_ALLOW_UNASSIGNED == UIDNA_ALLOW_UNASSIGNED);
	C_ASSERT(IDN_USE_STD3_ASCII_RULES == UIDNA_USE_STD3_RULES);
	return dwFlags;
}
开发者ID:HBelusca,项目名称:NasuTek-Odyssey,代码行数:11,代码来源:idna.cpp

示例9: thread_new

PmReturn_t
thread_new(pPmObj_t pframe, pPmObj_t *r_pobj)
{
    PmReturn_t retval = PM_RET_OK;
    pPmThread_t pthread = C_NULL;

    C_ASSERT(pframe != C_NULL);

    /* If it's not a frame, raise TypeError */
    if (OBJ_GET_TYPE(pframe) != OBJ_TYPE_FRM)
    {
        PM_RAISE(retval, PM_RET_EX_TYPE);
        return retval;
    }

    /* Allocate a thread */
    retval = heap_getChunk(sizeof(PmThread_t), (uint8_t **)r_pobj);
    PM_RETURN_IF_ERROR(retval);

    /* Set type, frame and initialize status */
    pthread = (pPmThread_t)*r_pobj;
    OBJ_SET_TYPE(pthread, OBJ_TYPE_THR);
    pthread->pframe = (pPmFrame_t)pframe;
    pthread->interpctrl = INTERP_CTRL_CONT;

    return retval;
}
开发者ID:BackupGGCode,项目名称:megapython,代码行数:27,代码来源:thread.c

示例10: dict_clear

PmReturn_t
dict_clear(pPmObj_t pdict)
{
    PmReturn_t retval = PM_RET_OK;

    C_ASSERT(pdict != C_NULL);

    /* Raise TypeError if arg is not a dict */
    if (OBJ_GET_TYPE(pdict) != OBJ_TYPE_DIC)
    {
        PM_RAISE(retval, PM_RET_EX_TYPE);
        return retval;
    }

    /* clear length */
    ((pPmDict_t)pdict)->length = 0;

    /* Free the keys and values seglists if needed */
    if (((pPmDict_t)pdict)->d_keys != C_NULL)
    {
        PM_RETURN_IF_ERROR(seglist_clear(((pPmDict_t)pdict)->d_keys));
        PM_RETURN_IF_ERROR(heap_freeChunk((pPmObj_t)
                                          ((pPmDict_t)pdict)->d_keys));
        ((pPmDict_t)pdict)->d_keys = C_NULL;
    }
    if (((pPmDict_t)pdict)->d_vals != C_NULL)
    {
        PM_RETURN_IF_ERROR(seglist_clear(((pPmDict_t)pdict)->d_vals));
        retval = heap_freeChunk((pPmObj_t)((pPmDict_t)pdict)->d_vals);
        ((pPmDict_t)pdict)->d_vals = C_NULL;
    }
    return retval;
}
开发者ID:AGM1968,项目名称:python-on-a-chip,代码行数:33,代码来源:dict.c

示例11: rx_ecss

/**
 * This functions handles an incoming ECSS packet.
 * If the ECSS packet is part of a large data transfer consisting from
 * several sequential ECSS packets, it handles them automatically.
 *
 * In other words, there is no need to explicitly check for a fragmented data
 * transfer.
 *
 * @param payload the received payload
 * @param payload_size the size of the payload
 * @return SATR_OK if all went ok or appropriate error code
 */
SAT_returnState
rx_ecss (uint8_t *payload, const uint16_t payload_size)
{
  SAT_returnState ret;
  tc_tm_pkt *pkt;

  pkt = get_pkt (payload_size);

  if (!C_ASSERT(pkt != NULL)) {
    return SATR_ERROR;
  }
  if (unpack_pkt (payload, pkt, payload_size) == SATR_OK) {
    ret = route_pkt (pkt);
  }

  TC_TM_app_id dest = 0;

  if(pkt->type == TC) {
    dest = pkt->app_id;
  }
  else if(pkt->type == TM) {
    dest = pkt->dest_id;
  }

  if(dest == SYSTEM_APP_ID) {
      free_pkt(pkt);
  }

  return ret;
}
开发者ID:mashua,项目名称:ecss_services,代码行数:42,代码来源:comms.c

示例12: pm_vmPeriodic

/* Warning: Can be called in interrupt context! */
PmReturn_t
pm_vmPeriodic(uint16_t usecsSinceLastCall)
{
    /*
     * Add the full milliseconds to pm_timerMsTicks and store additional
     * microseconds for the next run. Thus, usecsSinceLastCall must be
     * less than 2^16-1000 so it will not overflow usecResidual.
     */
    static uint16_t usecResidual = 0;

    C_ASSERT(usecsSinceLastCall < 64536);

    usecResidual += usecsSinceLastCall;
    while (usecResidual >= 1000)
    {
        usecResidual -= 1000;
        pm_timerMsTicks++;
    }

    /* Check if enough time has passed for a scheduler run */
    if ((pm_timerMsTicks - pm_lastRescheduleTimestamp)
        >= PM_THREAD_TIMESLICE_MS)
    {
        interp_setRescheduleFlag((uint8_t)1);
        pm_lastRescheduleTimestamp = pm_timerMsTicks;
    }
    return PM_RET_OK;
}
开发者ID:01iv3r,项目名称:OpenPilot,代码行数:29,代码来源:pm.c

示例13: dict_delItem

PmReturn_t
dict_delItem(pPmObj_t pdict, pPmObj_t pkey)
{
    PmReturn_t retval = PM_RET_OK;
    int16_t indx = 0;

    C_ASSERT(pdict != C_NULL);

    /* Check for matching key */
    retval = seglist_findEqual(((pPmDict_t)pdict)->d_keys, pkey, &indx);

    /* Raise KeyError if key is not found */
    if (retval == PM_RET_NO)
    {
        PM_RAISE(retval, PM_RET_EX_KEY);
    }

    /* Return any other error */
    PM_RETURN_IF_ERROR(retval);

    /* Remove the key and value */
    retval = seglist_removeItem(((pPmDict_t)pdict)->d_keys, indx);
    PM_RETURN_IF_ERROR(retval);
    retval = seglist_removeItem(((pPmDict_t)pdict)->d_vals, indx);

    /* Reduce the item count */
    ((pPmDict_t)pdict)->length--;

    return retval;
}
开发者ID:AGM1968,项目名称:python-on-a-chip,代码行数:30,代码来源:dict.c

示例14: obj_repr

PmReturn_t
obj_repr(pPmObj_t pobj, pPmObj_t *r_pstr)
{
    uint8_t tBuffer[32];
    PmReturn_t retval = PM_RET_OK;
    uint8_t const *pcstr = (uint8_t *)tBuffer;;

    C_ASSERT(pobj != C_NULL);

    switch (OBJ_GET_TYPE(pobj))
    {
    case OBJ_TYPE_INT:
        retval = sli_ltoa10(((pPmInt_t)pobj)->val, tBuffer, sizeof(tBuffer));
        PM_RETURN_IF_ERROR(retval);
        retval = string_new(&pcstr, r_pstr);
        break;

#ifdef HAVE_FLOAT
    case OBJ_TYPE_FLT:
        /* #212: Use homebrew float formatter */
        retval = sli_ftoa(((pPmFloat_t)pobj)->val, tBuffer, sizeof(tBuffer));
        sli_strlen((char *)tBuffer);
        retval = string_new(&pcstr, r_pstr);
        break;
#endif /* HAVE_FLOAT */

    default:
        /* Otherwise raise a TypeError */
        PM_RAISE(retval, PM_RET_EX_TYPE);
        break;
    }

    return retval;
}
开发者ID:KnightSch,项目名称:python-on-a-chip,代码行数:34,代码来源:obj.c

示例15: heap_linkToFreelist

/* Inserts in order a chunk into the free list.  Caller adjusts heap state */
static PmReturn_t
heap_linkToFreelist(pPmHeapDesc_t pchunk)
{
    uint16_t size;
    pPmHeapDesc_t pscan;

    /* Ensure the object is already free */
    C_ASSERT(OBJ_GET_FREE(pchunk) != 0);

    /* If free list is empty, add to head of list */
    if (pmHeap.pfreelist == C_NULL)
    {
        pmHeap.pfreelist = pchunk;
        pchunk->next = C_NULL;
        pchunk->prev = C_NULL;

        return PM_RET_OK;
    }

    /* Scan free list for insertion point */
    pscan = pmHeap.pfreelist;
    size = OBJ_GET_SIZE(pchunk);
    while ((OBJ_GET_SIZE(pscan) < size) && (pscan->next != C_NULL))
    {
        pscan = pscan->next;
    }

    /*
     * Insert chunk after the scan chunk (next is NULL).
     * This is a slightly rare case where the last chunk in the free list
     * is smaller than the chunk being freed.
     */
    if (size > OBJ_GET_SIZE(pscan))
    {
        pchunk->next = pscan->next;
        pscan->next = pchunk;
        pchunk->prev = pscan;
    }

    /* Insert chunk before the scan chunk */
    else
    {
        pchunk->next = pscan;
        pchunk->prev = pscan->prev;

        /* If chunk will be first item in free list */
        if (pscan->prev == C_NULL)
        {
            pmHeap.pfreelist = pchunk;
        }
        else
        {
            pscan->prev->next = pchunk;
        }
        pscan->prev = pchunk;
    }

    return PM_RET_OK;
}
开发者ID:BackupGGCode,项目名称:megapython,代码行数:60,代码来源:heap.c


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