您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ AssertMsgReturn函数代码示例

51自学网 2021-06-01 19:47:49
  C++
这篇教程C++ AssertMsgReturn函数代码示例写得很实用,希望能帮到您。

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

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

示例1: DECL_FORCE_INLINE

/** * Common worker for the debug and normal APIs. * * @returns VINF_SUCCESS if entered successfully. * @returns rcBusy when encountering a busy critical section in GC/R0. * @retval  VERR_SEM_DESTROYED if the critical section is delete before or *          during the operation. * * @param   pCritSect           The PDM critical section to enter. * @param   rcBusy              The status code to return when we're in GC or R0 *                              and the section is busy. */DECL_FORCE_INLINE(int) pdmCritSectEnter(PPDMCRITSECT pCritSect, int rcBusy, PCRTLOCKVALSRCPOS pSrcPos){    Assert(pCritSect->s.Core.cNestings < 8);  /* useful to catch incorrect locking */    Assert(pCritSect->s.Core.cNestings >= 0);    /*     * If the critical section has already been destroyed, then inform the caller.     */    AssertMsgReturn(pCritSect->s.Core.u32Magic == RTCRITSECT_MAGIC,                    ("%p %RX32/n", pCritSect, pCritSect->s.Core.u32Magic),                    VERR_SEM_DESTROYED);    /*     * See if we're lucky.     */    /* NOP ... */    if (pCritSect->s.Core.fFlags & RTCRITSECT_FLAGS_NOP)        return VINF_SUCCESS;    RTNATIVETHREAD hNativeSelf = pdmCritSectGetNativeSelf(pCritSect);    /* ... not owned ... */    if (ASMAtomicCmpXchgS32(&pCritSect->s.Core.cLockers, 0, -1))        return pdmCritSectEnterFirst(pCritSect, hNativeSelf, pSrcPos);    /* ... or nested. */    if (pCritSect->s.Core.NativeThreadOwner == hNativeSelf)    {        ASMAtomicIncS32(&pCritSect->s.Core.cLockers);        ASMAtomicIncS32(&pCritSect->s.Core.cNestings);        Assert(pCritSect->s.Core.cNestings > 1);        return VINF_SUCCESS;    }    /*     * Spin for a bit without incrementing the counter.     */    /** @todo Move this to cfgm variables since it doesn't make sense to spin on UNI     *        cpu systems. */    int32_t cSpinsLeft = CTX_SUFF(PDMCRITSECT_SPIN_COUNT_);    while (cSpinsLeft-- > 0)    {        if (ASMAtomicCmpXchgS32(&pCritSect->s.Core.cLockers, 0, -1))            return pdmCritSectEnterFirst(pCritSect, hNativeSelf, pSrcPos);        ASMNopPause();        /** @todo Should use monitor/mwait on e.g. &cLockers here, possibly with a           cli'ed pendingpreemption check up front using sti w/ instruction fusing           for avoiding races. Hmm ... This is assuming the other party is actually           executing code on another CPU ... which we could keep track of if we           wanted. */    }#ifdef IN_RING3    /*     * Take the slow path.     */    NOREF(rcBusy);    return pdmR3R0CritSectEnterContended(pCritSect, hNativeSelf, pSrcPos);#else# ifdef IN_RING0    /** @todo If preemption is disabled it means we're in VT-x/AMD-V context     *        and would be better off switching out of that while waiting for     *        the lock.  Several of the locks jumps back to ring-3 just to     *        get the lock, the ring-3 code will then call the kernel to do     *        the lock wait and when the call return it will call ring-0     *        again and resume via in setjmp style.  Not very efficient. */#  if 0    if (ASMIntAreEnabled()) /** @todo this can be handled as well by changing                             * callers not prepared for longjmp/blocking to                             * use PDMCritSectTryEnter. */    {        /*         * Leave HM context while waiting if necessary.         */        int rc;        if (RTThreadPreemptIsEnabled(NIL_RTTHREAD))        {            STAM_REL_COUNTER_ADD(&pCritSect->s.StatContentionRZLock,    1000000);            rc = pdmR3R0CritSectEnterContended(pCritSect, hNativeSelf, pSrcPos);        }        else        {            STAM_REL_COUNTER_ADD(&pCritSect->s.StatContentionRZLock, 1000000000);            PVM     pVM   = pCritSect->s.CTX_SUFF(pVM);            PVMCPU  pVCpu = VMMGetCpu(pVM);            HMR0Leave(pVM, pVCpu);            RTThreadPreemptRestore(NIL_RTTHREAD, XXX);//.........这里部分代码省略.........
开发者ID:stefano-garzarella,项目名称:virtualbox-org-svn-vbox-trunk,代码行数:101,


示例2: RTR3DECL

RTR3DECL(int) RTPathSetTimesEx(const char *pszPath, PCRTTIMESPEC pAccessTime, PCRTTIMESPEC pModificationTime,                               PCRTTIMESPEC pChangeTime, PCRTTIMESPEC pBirthTime, uint32_t fFlags){    /*     * Validate input.     */    AssertPtrReturn(pszPath, VERR_INVALID_POINTER);    AssertReturn(*pszPath, VERR_INVALID_PARAMETER);    AssertPtrNullReturn(pAccessTime, VERR_INVALID_POINTER);    AssertPtrNullReturn(pModificationTime, VERR_INVALID_POINTER);    AssertPtrNullReturn(pChangeTime, VERR_INVALID_POINTER);    AssertPtrNullReturn(pBirthTime, VERR_INVALID_POINTER);    AssertMsgReturn(RTPATH_F_IS_VALID(fFlags, 0), ("%#x/n", fFlags), VERR_INVALID_PARAMETER);    /*     * Convert the path.     */    PRTUTF16 pwszPath;    int rc = RTStrToUtf16(pszPath, &pwszPath);    if (RT_SUCCESS(rc))    {        HANDLE hFile;        if (fFlags & RTPATH_F_FOLLOW_LINK)            hFile = CreateFileW(pwszPath,                                FILE_WRITE_ATTRIBUTES,   /* dwDesiredAccess */                                FILE_SHARE_WRITE | FILE_SHARE_READ | FILE_SHARE_DELETE, /* dwShareMode */                                NULL,                    /* security attribs */                                OPEN_EXISTING,           /* dwCreationDisposition */                                FILE_FLAG_BACKUP_SEMANTICS | FILE_ATTRIBUTE_NORMAL,                                NULL);        else        {/** @todo Symlink: Test RTPathSetTimesEx on Windows. (The code is disabled *        because it's not tested yet.) */#if 0 //def FILE_FLAG_OPEN_REPARSE_POINT            hFile = CreateFileW(pwszPath,                                FILE_WRITE_ATTRIBUTES,   /* dwDesiredAccess */                                FILE_SHARE_WRITE | FILE_SHARE_READ | FILE_SHARE_DELETE, /* dwShareMode */                                NULL,                    /* security attribs */                                OPEN_EXISTING,           /* dwCreationDisposition */                                FILE_FLAG_BACKUP_SEMANTICS | FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OPEN_REPARSE_POINT,                                NULL);            if (hFile == INVALID_HANDLE_VALUE && GetLastError() == ERROR_INVALID_PARAMETER)#endif                hFile = CreateFileW(pwszPath,                                    FILE_WRITE_ATTRIBUTES,   /* dwDesiredAccess */                                    FILE_SHARE_WRITE | FILE_SHARE_READ | FILE_SHARE_DELETE, /* dwShareMode */                                    NULL,                    /* security attribs */                                    OPEN_EXISTING,           /* dwCreationDisposition */                                    FILE_FLAG_BACKUP_SEMANTICS | FILE_ATTRIBUTE_NORMAL,                                    NULL);        }        if (hFile != INVALID_HANDLE_VALUE)        {            /*             * Check if it's a no-op.             */            if (!pAccessTime && !pModificationTime && !pBirthTime)                rc = VINF_SUCCESS;    /* NOP */            else            {                /*                 * Convert the input and call the API.                 */                FILETIME    CreationTimeFT;                PFILETIME   pCreationTimeFT = NULL;                if (pBirthTime)                    pCreationTimeFT = RTTimeSpecGetNtFileTime(pBirthTime, &CreationTimeFT);                FILETIME    LastAccessTimeFT;                PFILETIME   pLastAccessTimeFT = NULL;                if (pAccessTime)                    pLastAccessTimeFT = RTTimeSpecGetNtFileTime(pAccessTime, &LastAccessTimeFT);                FILETIME    LastWriteTimeFT;                PFILETIME   pLastWriteTimeFT = NULL;                if (pModificationTime)                    pLastWriteTimeFT = RTTimeSpecGetNtFileTime(pModificationTime, &LastWriteTimeFT);                if (SetFileTime(hFile, pCreationTimeFT, pLastAccessTimeFT, pLastWriteTimeFT))                    rc = VINF_SUCCESS;                else                {                    DWORD Err = GetLastError();                    rc = RTErrConvertFromWin32(Err);                    Log(("RTPathSetTimes('%s', %p, %p, %p, %p): SetFileTime failed with lasterr %d (%Rrc)/n",                         pszPath, pAccessTime, pModificationTime, pChangeTime, pBirthTime, Err, rc));                }            }            BOOL fRc = CloseHandle(hFile); Assert(fRc); NOREF(fRc);        }        else        {            DWORD Err = GetLastError();            rc = RTErrConvertFromWin32(Err);            Log(("RTPathSetTimes('%s',,,,): failed with %Rrc and lasterr=%u/n", pszPath, rc, Err));        }        RTUtf16Free(pwszPath);//.........这里部分代码省略.........
开发者ID:greg100795,项目名称:virtualbox,代码行数:101,


示例3: RTDECL

RTDECL(int) RTDirReadEx(PRTDIR pDir, PRTDIRENTRYEX pDirEntry, size_t *pcbDirEntry, RTFSOBJATTRADD enmAdditionalAttribs, uint32_t fFlags){    /*     * Validate and digest input.     */    if (!rtDirValidHandle(pDir))        return VERR_INVALID_PARAMETER;    AssertMsgReturn(VALID_PTR(pDirEntry), ("%p/n", pDirEntry), VERR_INVALID_POINTER);    AssertMsgReturn(    enmAdditionalAttribs >= RTFSOBJATTRADD_NOTHING                    &&  enmAdditionalAttribs <= RTFSOBJATTRADD_LAST,                    ("Invalid enmAdditionalAttribs=%p/n", enmAdditionalAttribs),                    VERR_INVALID_PARAMETER);    AssertMsgReturn(RTPATH_F_IS_VALID(fFlags, 0), ("%#x/n", fFlags), VERR_INVALID_PARAMETER);    size_t cbDirEntry = sizeof(*pDirEntry);    if (pcbDirEntry)    {        AssertMsgReturn(VALID_PTR(pcbDirEntry), ("%p/n", pcbDirEntry), VERR_INVALID_POINTER);        cbDirEntry = *pcbDirEntry;        AssertMsgReturn(cbDirEntry >= (unsigned)RT_OFFSETOF(RTDIRENTRYEX, szName[2]),                        ("Invalid *pcbDirEntry=%d (min %d)/n", *pcbDirEntry, RT_OFFSETOF(RTDIRENTRYEX, szName[2])),                        VERR_INVALID_PARAMETER);    }    /*     * Fetch more data if necessary and/or convert the name.     */    int rc = rtDirReadMore(pDir);    if (RT_SUCCESS(rc))    {        /*         * Check if we've got enough space to return the data.         */        const char  *pszName    = pDir->pszName;        const size_t cchName    = pDir->cchName;        const size_t cbRequired = RT_OFFSETOF(RTDIRENTRYEX, szName[1]) + cchName;        if (pcbDirEntry)            *pcbDirEntry = cbRequired;        if (cbRequired <= cbDirEntry)        {            /*             * Setup the returned data.             */            pDirEntry->cwcShortName = 0;            pDirEntry->wszShortName[0] = 0;            pDirEntry->cbName  = (uint16_t)cchName;            Assert(pDirEntry->cbName == cchName);            memcpy(pDirEntry->szName, pszName, cchName + 1);            /* get the info data */            size_t cch = cchName + pDir->cchPath + 1;            char *pszNamePath = (char *)alloca(cch);            if (pszNamePath)            {                memcpy(pszNamePath, pDir->pszPath, pDir->cchPath);                memcpy(pszNamePath + pDir->cchPath, pszName, cchName + 1);                rc = RTPathQueryInfoEx(pszNamePath, &pDirEntry->Info, enmAdditionalAttribs, fFlags);            }            else                rc = VERR_NO_MEMORY;            if (RT_FAILURE(rc))            {#ifdef HAVE_DIRENT_D_TYPE                rtDirSetDummyInfo(&pDirEntry->Info, rtDirType(pDir->Data.d_type));#else                rtDirSetDummyInfo(&pDirEntry->Info, RTDIRENTRYTYPE_UNKNOWN);#endif                rc = VWRN_NO_DIRENT_INFO;            }            /* free cached data */            pDir->fDataUnread  = false;            rtPathFreeIprt(pDir->pszName, pDir->Data.d_name);            pDir->pszName = NULL;        }        else            rc = VERR_BUFFER_OVERFLOW;    }    return rc;}
开发者ID:bayasist,项目名称:vbox,代码行数:80,


示例4: LogFlowThisFunc

/** * Runs all the filters on the specified device. * * All filters mean global and active VM, with the exception of those * belonging to /a aMachine. If a global ignore filter matched or if * none of the filters matched, the device will be released back to * the host. * * The device calling us here will be in the HeldByProxy, Unused, or * Capturable state. The caller is aware that locks held might have * to be abandond because of IPC and that the device might be in * almost any state upon return. * * * @returns COM status code (only parameter & state checks will fail). * @param   aDevice         The USB device to apply filters to. * @param   aIgnoreMachine  The machine to ignore filters from (we've just *                          detached the device from this machine). * * @note    The caller is expected to own no locks. */HRESULT USBProxyService::runAllFiltersOnDevice(ComObjPtr<HostUSBDevice> &aDevice,                                               SessionMachinesList &llOpenedMachines,                                               SessionMachine *aIgnoreMachine){    LogFlowThisFunc(("{%s} ignoring=%p/n", aDevice->i_getName().c_str(), aIgnoreMachine));    /*     * Verify preconditions.     */    AssertReturn(!isWriteLockOnCurrentThread(), E_FAIL);    AssertReturn(!aDevice->isWriteLockOnCurrentThread(), E_FAIL);    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);    AutoWriteLock devLock(aDevice COMMA_LOCKVAL_SRC_POS);    AssertMsgReturn(aDevice->i_isCapturableOrHeld(), ("{%s} %s/n", aDevice->i_getName().c_str(),                                                      aDevice->i_getStateName()), E_FAIL);    /*     * Get the lists we'll iterate.     */    Host::USBDeviceFilterList globalFilters;    mHost->i_getUSBFilters(&globalFilters);    /*     * Run global filters filters first.     */    bool fHoldIt = false;    for (Host::USBDeviceFilterList::const_iterator it = globalFilters.begin();         it != globalFilters.end();         ++it)    {        AutoWriteLock filterLock(*it COMMA_LOCKVAL_SRC_POS);        const HostUSBDeviceFilter::Data &data = (*it)->i_getData();        if (aDevice->i_isMatch(data))        {            USBDeviceFilterAction_T action = USBDeviceFilterAction_Null;            (*it)->COMGETTER(Action)(&action);            if (action == USBDeviceFilterAction_Ignore)            {                /*                 * Release the device to the host and we're done.                 */                filterLock.release();                devLock.release();                alock.release();                aDevice->i_requestReleaseToHost();                return S_OK;            }            if (action == USBDeviceFilterAction_Hold)            {                /*                 * A device held by the proxy needs to be subjected                 * to the machine filters.                 */                fHoldIt = true;                break;            }            AssertMsgFailed(("action=%d/n", action));        }    }    globalFilters.clear();    /*     * Run the per-machine filters.     */    for (SessionMachinesList::const_iterator it = llOpenedMachines.begin();         it != llOpenedMachines.end();         ++it)    {        ComObjPtr<SessionMachine> pMachine = *it;        /* Skip the machine the device was just detached from. */        if (    aIgnoreMachine            &&  pMachine == aIgnoreMachine)            continue;        /* runMachineFilters takes care of checking the machine state. */        devLock.release();        alock.release();//.........这里部分代码省略.........
开发者ID:Klanly,项目名称:virtualbox-org-svn-vbox-trunk,代码行数:101,


示例5: RTDECL

RTDECL(int) RTFileMove(const char *pszSrc, const char *pszDst, unsigned fMove){    /*     * Validate input.     */    AssertMsgReturn(VALID_PTR(pszSrc), ("%p/n", pszSrc), VERR_INVALID_POINTER);    AssertMsgReturn(VALID_PTR(pszDst), ("%p/n", pszDst), VERR_INVALID_POINTER);    AssertMsgReturn(*pszSrc, ("%p/n", pszSrc), VERR_INVALID_PARAMETER);    AssertMsgReturn(*pszDst, ("%p/n", pszDst), VERR_INVALID_PARAMETER);    AssertMsgReturn(!(fMove & ~RTFILEMOVE_FLAGS_REPLACE), ("%#x/n", fMove), VERR_INVALID_PARAMETER);    /*     * Try RTFileRename first.     */    Assert(RTPATHRENAME_FLAGS_REPLACE == RTFILEMOVE_FLAGS_REPLACE);    unsigned fRename = fMove;    int rc = RTFileRename(pszSrc, pszDst, fRename);    if (rc == VERR_NOT_SAME_DEVICE)    {        const char *pszDelete = NULL;        /*         * The source and target are not on the same device, darn.         * We'll try open both ends and perform a copy.         */        RTFILE FileSrc;        rc = RTFileOpen(&FileSrc, pszSrc, RTFILE_O_READ | RTFILE_O_DENY_WRITE | RTFILE_O_OPEN);        if (RT_SUCCESS(rc))        {            RTFILE FileDst;            rc = RTFileOpen(&FileDst, pszDst, RTFILE_O_WRITE | RTFILE_O_DENY_ALL | RTFILE_O_CREATE_REPLACE);            if (RT_SUCCESS(rc))            {                rc = RTFileCopyByHandles(FileSrc, FileDst);                if (RT_SUCCESS(rc))                    pszDelete = pszSrc;                else                {                    pszDelete = pszDst;                    Log(("RTFileMove('%s', '%s', %#x): copy failed, rc=%Rrc/n",                         pszSrc, pszDst, fMove, rc));                }                /* try delete without closing, and could perhaps avoid some trouble */                int rc2 = RTFileDelete(pszDelete);                if (RT_SUCCESS(rc2))                    pszDelete = NULL;                RTFileClose(FileDst);            }            else                Log(("RTFileMove('%s', '%s', %#x): failed to create destination, rc=%Rrc/n",                     pszSrc, pszDst, fMove, rc));            RTFileClose(FileSrc);        }        else            Log(("RTFileMove('%s', '%s', %#x): failed to open source, rc=%Rrc/n",                 pszSrc, pszDst, fMove, rc));        /* if we failed to close it while open, close it now */        if (pszDelete)        {            int rc2 = RTFileDelete(pszDelete);            if (RT_FAILURE(rc2))                Log(("RTFileMove('%s', '%s', %#x): failed to delete '%s', rc2=%Rrc (rc=%Rrc)/n",                     pszSrc, pszDst, fMove, pszDelete, rc2, rc));        }    }    LogFlow(("RTDirRename(%p:{%s}, %p:{%s}, %#x): returns %Rrc/n",             pszSrc, pszSrc, pszDst, pszDst, fMove, rc));    return rc;}
开发者ID:LastRitter,项目名称:vbox-haiku,代码行数:72,


示例6: DECLCALLBACK

/** * Construct a block driver instance. * * @copydoc FNPDMDRVCONSTRUCT */static DECLCALLBACK(int) drvscsiConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags){    int rc = VINF_SUCCESS;    PDRVSCSI pThis = PDMINS_2_DATA(pDrvIns, PDRVSCSI);    LogFlowFunc(("pDrvIns=%#p pCfg=%#p/n", pDrvIns, pCfg));    PDMDRV_CHECK_VERSIONS_RETURN(pDrvIns);    /*     * Initialize the instance data.     */    pThis->pDrvIns                              = pDrvIns;    pThis->ISCSIConnector.pfnSCSIRequestSend    = drvscsiRequestSend;    pDrvIns->IBase.pfnQueryInterface            = drvscsiQueryInterface;    pThis->IPort.pfnQueryDeviceLocation         = drvscsiQueryDeviceLocation;    pThis->IPortAsync.pfnTransferCompleteNotify = drvscsiTransferCompleteNotify;    pThis->hQueueRequests                       = NIL_RTREQQUEUE;    /* Query the SCSI port interface above. */    pThis->pDevScsiPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMISCSIPORT);    AssertMsgReturn(pThis->pDevScsiPort, ("Missing SCSI port interface above/n"), VERR_PDM_MISSING_INTERFACE);    /* Query the optional LED interface above. */    pThis->pLedPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMILEDPORTS);    if (pThis->pLedPort != NULL)    {        /* Get The Led. */        rc = pThis->pLedPort->pfnQueryStatusLed(pThis->pLedPort, 0, &pThis->pLed);        if (RT_FAILURE(rc))            pThis->pLed = &pThis->Led;    }    else        pThis->pLed = &pThis->Led;    /*     * Validate and read configuration.     */    if (!CFGMR3AreValuesValid(pCfg, "NonRotationalMedium/0Readonly/0"))        return PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_DEVINS_UNKNOWN_CFG_VALUES,                                N_("SCSI configuration error: unknown option specified"));    rc = CFGMR3QueryBoolDef(pCfg, "NonRotationalMedium", &pThis->fNonRotational, false);    if (RT_FAILURE(rc))        return PDMDRV_SET_ERROR(pDrvIns, rc,                    N_("SCSI configuration error: failed to read /"NonRotationalMedium/" as boolean"));    rc = CFGMR3QueryBoolDef(pCfg, "Readonly", &pThis->fReadonly, false);    if (RT_FAILURE(rc))        return PDMDRV_SET_ERROR(pDrvIns, rc,                                N_("SCSI configuration error: failed to read /"Readonly/" as boolean"));    /*     * Try attach driver below and query it's block interface.     */    rc = PDMDrvHlpAttach(pDrvIns, fFlags, &pThis->pDrvBase);    AssertMsgReturn(RT_SUCCESS(rc), ("Attaching driver below failed rc=%Rrc/n", rc), rc);    /*     * Query the block and blockbios interfaces.     */    pThis->pDrvBlock = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIBLOCK);    if (!pThis->pDrvBlock)    {        AssertMsgFailed(("Configuration error: No block interface!/n"));        return VERR_PDM_MISSING_INTERFACE;    }    pThis->pDrvBlockBios = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIBLOCKBIOS);    if (!pThis->pDrvBlockBios)    {        AssertMsgFailed(("Configuration error: No block BIOS interface!/n"));        return VERR_PDM_MISSING_INTERFACE;    }    pThis->pDrvMount = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIMOUNT);    /* Try to get the optional async block interface. */    pThis->pDrvBlockAsync = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIBLOCKASYNC);    PDMBLOCKTYPE enmType = pThis->pDrvBlock->pfnGetType(pThis->pDrvBlock);    if (enmType != PDMBLOCKTYPE_HARD_DISK)        return PDMDrvHlpVMSetError(pDrvIns, VERR_PDM_UNSUPPORTED_BLOCK_TYPE, RT_SRC_POS,                                   N_("Only hard disks are currently supported as SCSI devices (enmType=%d)"),                                   enmType);    /* Create VSCSI device and LUN. */    pThis->VScsiIoCallbacks.pfnVScsiLunMediumGetSize      = drvscsiGetSize;    pThis->VScsiIoCallbacks.pfnVScsiLunReqTransferEnqueue = drvscsiReqTransferEnqueue;    pThis->VScsiIoCallbacks.pfnVScsiLunGetFeatureFlags    = drvscsiGetFeatureFlags;    rc = VSCSIDeviceCreate(&pThis->hVScsiDevice, drvscsiVScsiReqCompleted, pThis);    AssertMsgReturn(RT_SUCCESS(rc), ("Failed to create VSCSI device rc=%Rrc/n"), rc);    rc = VSCSILunCreate(&pThis->hVScsiLun, VSCSILUNTYPE_SBC, &pThis->VScsiIoCallbacks,                        pThis);    AssertMsgReturn(RT_SUCCESS(rc), ("Failed to create VSCSI LUN rc=%Rrc/n"), rc);//.........这里部分代码省略.........
开发者ID:greg100795,项目名称:virtualbox,代码行数:101,


示例7: DECLCALLBACK

/** * Construct a status driver instance. * * @copydoc FNPDMDRVCONSTRUCT */DECLCALLBACK(int) VMStatus::drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags){    PDRVMAINSTATUS pData = PDMINS_2_DATA(pDrvIns, PDRVMAINSTATUS);    LogFlow(("VMStatus::drvConstruct: iInstance=%d/n", pDrvIns->iInstance));    /*     * Validate configuration.     */    if (!CFGMR3AreValuesValid(pCfg, "papLeds/0First/0Last/0"))        return VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES;    AssertMsgReturn(PDMDrvHlpNoAttach(pDrvIns) == VERR_PDM_NO_ATTACHED_DRIVER,                    ("Configuration error: Not possible to attach anything to this driver!/n"),                    VERR_PDM_DRVINS_NO_ATTACH);    /*     * Data.     */    pDrvIns->IBase.pfnQueryInterface        = VMStatus::drvQueryInterface;    pData->ILedConnectors.pfnUnitChanged    = VMStatus::drvUnitChanged;    /*     * Read config.     */    int rc = CFGMR3QueryPtr(pCfg, "papLeds", (void **)&pData->papLeds);    if (RT_FAILURE(rc))    {        AssertMsgFailed(("Configuration error: Failed to query the /"papLeds/" value! rc=%Rrc/n", rc));        return rc;    }    rc = CFGMR3QueryU32(pCfg, "First", &pData->iFirstLUN);    if (rc == VERR_CFGM_VALUE_NOT_FOUND)        pData->iFirstLUN = 0;    else if (RT_FAILURE(rc))    {        AssertMsgFailed(("Configuration error: Failed to query the /"First/" value! rc=%Rrc/n", rc));        return rc;    }    rc = CFGMR3QueryU32(pCfg, "Last", &pData->iLastLUN);    if (rc == VERR_CFGM_VALUE_NOT_FOUND)        pData->iLastLUN = 0;    else if (RT_FAILURE(rc))    {        AssertMsgFailed(("Configuration error: Failed to query the /"Last/" value! rc=%Rrc/n", rc));        return rc;    }    if (pData->iFirstLUN > pData->iLastLUN)    {        AssertMsgFailed(("Configuration error: Invalid unit range %u-%u/n", pData->iFirstLUN, pData->iLastLUN));        return VERR_GENERAL_FAILURE;    }    /*     * Get the ILedPorts interface of the above driver/device and     * query the LEDs we want.     */    pData->pLedPorts = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMILEDPORTS);    AssertMsgReturn(pData->pLedPorts, ("Configuration error: No led ports interface above!/n"),                    VERR_PDM_MISSING_INTERFACE_ABOVE);    for (unsigned i = pData->iFirstLUN; i <= pData->iLastLUN; i++)        VMStatus::drvUnitChanged(&pData->ILedConnectors, i);    return VINF_SUCCESS;}
开发者ID:greg100795,项目名称:virtualbox,代码行数:71,


示例8: rtR0SemEventWait

/** * Worker for RTSemEventWaitEx and RTSemEventWaitExDebug. * * @returns VBox status code. * @param   pThis           The event semaphore. * @param   fFlags          See RTSemEventWaitEx. * @param   uTimeout        See RTSemEventWaitEx. * @param   pSrcPos         The source code position of the wait. */static int rtR0SemEventWait(PRTSEMEVENTINTERNAL pThis, uint32_t fFlags, uint64_t uTimeout,                            PCRTLOCKVALSRCPOS pSrcPos){    status_t  status;    int       rc;    int32     flags = 0;    bigtime_t timeout; /* in microseconds */    /*     * Validate the input.     */    AssertPtrReturn(pThis, VERR_INVALID_PARAMETER);    AssertMsgReturn(pThis->u32Magic == RTSEMEVENT_MAGIC, ("%p u32Magic=%RX32/n", pThis, pThis->u32Magic), VERR_INVALID_PARAMETER);    AssertReturn(RTSEMWAIT_FLAGS_ARE_VALID(fFlags), VERR_INVALID_PARAMETER);    if (fFlags & RTSEMWAIT_FLAGS_INDEFINITE)        timeout = B_INFINITE_TIMEOUT;    else    {        if (fFlags & RTSEMWAIT_FLAGS_NANOSECS)            timeout = uTimeout / 1000;        else if (fFlags & RTSEMWAIT_FLAGS_MILLISECS)            timeout = uTimeout * 1000;        else            return VERR_INVALID_PARAMETER;        if (fFlags & RTSEMWAIT_FLAGS_RELATIVE)            flags |= B_RELATIVE_TIMEOUT;        else if (fFlags & RTSEMWAIT_FLAGS_ABSOLUTE)            flags |= B_ABSOLUTE_TIMEOUT;        else            return VERR_INVALID_PARAMETER;    }    if (fFlags & RTSEMWAIT_FLAGS_INTERRUPTIBLE)        flags |= B_CAN_INTERRUPT;    // likely not:    //else    //    flags |= B_KILL_CAN_INTERRUPT;    rtR0SemEventHkuRetain(pThis);    status = acquire_sem_etc(pThis->SemId, 1, flags, timeout);    switch (status)    {    case B_OK:        rc = VINF_SUCCESS;        break;    case B_BAD_SEM_ID:        rc = VERR_SEM_DESTROYED;        break;    case B_INTERRUPTED:        rc = VERR_INTERRUPTED;        break;    case B_WOULD_BLOCK:    /* fallthrough ? */    case B_TIMED_OUT:        rc = VERR_TIMEOUT;        break;    default:        rc = RTErrConvertFromHaikuKernReturn(status);        break;    }    rtR0SemEventHkuRelease(pThis);    return rc;}
开发者ID:sobomax,项目名称:virtualbox_64bit_edd,代码行数:77,


示例9: rtFileRecalcAndValidateFlags

/** * Adjusts and validates the flags. * * The adjustments are made according to the wishes specified using the RTFileSetForceFlags API. * * @returns IPRT status code. * @param   pfOpen      Pointer to the user specified flags on input. *                      Updated on successful return. * @internal */int rtFileRecalcAndValidateFlags(uint64_t *pfOpen){    /*     * Recalc.     */    uint32_t fOpen = *pfOpen;    switch (fOpen & RTFILE_O_ACCESS_MASK)    {        case RTFILE_O_READ:            fOpen |= g_fOpenReadSet;            fOpen &= ~g_fOpenReadMask;            break;        case RTFILE_O_WRITE:            fOpen |= g_fOpenWriteSet;            fOpen &= ~g_fOpenWriteMask;            break;        case RTFILE_O_READWRITE:            fOpen |= g_fOpenReadWriteSet;            fOpen &= ~g_fOpenReadWriteMask;            break;        default:            AssertMsgFailed(("Invalid RW value, fOpen=%#llx/n", fOpen));            return VERR_INVALID_PARAMETER;    }    /*     * Validate                                                                                                                                       .     */    AssertMsgReturn(fOpen & RTFILE_O_ACCESS_MASK, ("Missing RTFILE_O_READ/WRITE: fOpen=%#llx/n", fOpen), VERR_INVALID_PARAMETER);#if defined(RT_OS_WINDOWS) || defined(RT_OS_OS2)    AssertMsgReturn(!(fOpen & (~(uint64_t)RTFILE_O_VALID_MASK | RTFILE_O_NON_BLOCK)), ("%#llx/n", fOpen), VERR_INVALID_PARAMETER);#else    AssertMsgReturn(!(fOpen & ~(uint64_t)RTFILE_O_VALID_MASK), ("%#llx/n", fOpen), VERR_INVALID_PARAMETER);#endif    AssertMsgReturn((fOpen & (RTFILE_O_TRUNCATE | RTFILE_O_WRITE)) != RTFILE_O_TRUNCATE, ("%#llx/n", fOpen), VERR_INVALID_PARAMETER);    switch (fOpen & RTFILE_O_ACTION_MASK)    {        case 0: /* temporarily */            AssertMsgFailed(("Missing RTFILE_O_OPEN/CREATE*! (continuable assertion)/n"));            fOpen |= RTFILE_O_OPEN;            break;        case RTFILE_O_OPEN:            AssertMsgReturn(!(RTFILE_O_NOT_CONTENT_INDEXED & fOpen), ("%#llx/n", fOpen), VERR_INVALID_PARAMETER);        case RTFILE_O_OPEN_CREATE:        case RTFILE_O_CREATE:        case RTFILE_O_CREATE_REPLACE:            break;        default:            AssertMsgFailed(("Invalid action value: fOpen=%#llx/n", fOpen));            return VERR_INVALID_PARAMETER;    }    switch (fOpen & RTFILE_O_DENY_MASK)    {        case 0: /* temporarily */            AssertMsgFailed(("Missing RTFILE_O_DENY_*! (continuable assertion)/n"));            fOpen |= RTFILE_O_DENY_NONE;            break;        case RTFILE_O_DENY_NONE:        case RTFILE_O_DENY_READ:        case RTFILE_O_DENY_WRITE:        case RTFILE_O_DENY_WRITE | RTFILE_O_DENY_READ:        case RTFILE_O_DENY_NOT_DELETE:        case RTFILE_O_DENY_NOT_DELETE | RTFILE_O_DENY_READ:        case RTFILE_O_DENY_NOT_DELETE | RTFILE_O_DENY_WRITE:        case RTFILE_O_DENY_NOT_DELETE | RTFILE_O_DENY_WRITE | RTFILE_O_DENY_READ:            break;        default:            AssertMsgFailed(("Invalid deny value: fOpen=%#llx/n", fOpen));            return VERR_INVALID_PARAMETER;    }    /* done */    *pfOpen = fOpen;    return VINF_SUCCESS;}
开发者ID:leopucci,项目名称:VirtualMonitor,代码行数:87,


示例10: RTDECL

RTDECL(RTLDRARCH) RTLdrGetArch(RTLDRMOD hLdrMod){    AssertMsgReturn(rtldrIsValid(hLdrMod), ("hLdrMod=%p/n", hLdrMod), RTLDRARCH_INVALID);    PRTLDRMODINTERNAL pMod = (PRTLDRMODINTERNAL)hLdrMod;    return pMod->enmArch;}
开发者ID:mutoso-mirrors,项目名称:vbox,代码行数:6,


示例11: rtSemEventMultiPosixWaitTimed

/** * Implements the timed wait. * * @returns See RTSemEventMultiWaitEx * @param   pThis               The semaphore. * @param   fFlags              See RTSemEventMultiWaitEx. * @param   uTimeout            See RTSemEventMultiWaitEx. * @param   pSrcPos             The source position, can be NULL. */static int rtSemEventMultiPosixWaitTimed(struct RTSEMEVENTMULTIINTERNAL *pThis, uint32_t fFlags, uint64_t uTimeout,                                         PCRTLOCKVALSRCPOS pSrcPos){    /*     * Convert uTimeout to a relative value in nano seconds.     */    if (fFlags & RTSEMWAIT_FLAGS_MILLISECS)        uTimeout = uTimeout < UINT64_MAX / UINT32_C(1000000) * UINT32_C(1000000)                 ? uTimeout * UINT32_C(1000000)                 : UINT64_MAX;    if (uTimeout == UINT64_MAX) /* unofficial way of indicating an indefinite wait */        return rtSemEventMultiPosixWaitIndefinite(pThis, fFlags, pSrcPos);    uint64_t uAbsTimeout = uTimeout;    if (fFlags & RTSEMWAIT_FLAGS_ABSOLUTE)    {        uint64_t u64Now = RTTimeSystemNanoTS();        uTimeout = uTimeout > u64Now ? uTimeout - u64Now : 0;    }    if (uTimeout == 0)        return rtSemEventMultiPosixWaitPoll(pThis);    /*     * Get current time and calc end of deadline relative to real time.     */    struct timespec     ts = {0,0};    if (!pThis->fMonotonicClock)    {#if defined(RT_OS_DARWIN) || defined(RT_OS_HAIKU)        struct timeval  tv = {0,0};        gettimeofday(&tv, NULL);        ts.tv_sec = tv.tv_sec;        ts.tv_nsec = tv.tv_usec * 1000;#else        clock_gettime(CLOCK_REALTIME, &ts);#endif        struct timespec tsAdd;        tsAdd.tv_nsec = uTimeout % UINT32_C(1000000000);        tsAdd.tv_sec  = uTimeout / UINT32_C(1000000000);        if (   sizeof(ts.tv_sec) < sizeof(uint64_t)            && (   uTimeout > UINT64_C(1000000000) * UINT32_MAX                || (uint64_t)ts.tv_sec + tsAdd.tv_sec >= UINT32_MAX) )            return rtSemEventMultiPosixWaitIndefinite(pThis, fFlags, pSrcPos);        ts.tv_sec  += tsAdd.tv_sec;        ts.tv_nsec += tsAdd.tv_nsec;        if (ts.tv_nsec >= 1000000000)        {            ts.tv_nsec -= 1000000000;            ts.tv_sec++;        }        /* Note! No need to complete uAbsTimeout for RTSEMWAIT_FLAGS_RELATIVE in this path. */    }    else    {        /* ASSUMES RTTimeSystemNanoTS() == RTTimeNanoTS() == clock_gettime(CLOCK_MONOTONIC). */        if (fFlags & RTSEMWAIT_FLAGS_RELATIVE)            uAbsTimeout += RTTimeSystemNanoTS();        if (   sizeof(ts.tv_sec) < sizeof(uint64_t)            && uAbsTimeout > UINT64_C(1000000000) * UINT32_MAX)            return rtSemEventMultiPosixWaitIndefinite(pThis, fFlags, pSrcPos);        ts.tv_nsec = uAbsTimeout % UINT32_C(1000000000);        ts.tv_sec  = uAbsTimeout / UINT32_C(1000000000);    }    /*     * To business!     */    /* take mutex */    int rc = pthread_mutex_lock(&pThis->Mutex);    AssertMsgReturn(rc == 0, ("rc=%d pThis=%p/n", rc, pThis), RTErrConvertFromErrno(rc)); NOREF(rc);    ASMAtomicIncU32(&pThis->cWaiters);    for (;;)    {        /* check state. */        uint32_t const u32State = pThis->u32State;        if (u32State != EVENTMULTI_STATE_NOT_SIGNALED)        {            ASMAtomicDecU32(&pThis->cWaiters);            rc = pthread_mutex_unlock(&pThis->Mutex);            AssertMsg(!rc, ("Failed to unlock event multi sem %p, rc=%d./n", pThis, rc));            return u32State == EVENTMULTI_STATE_SIGNALED                 ? VINF_SUCCESS                 : VERR_SEM_DESTROYED;        }        /* wait */#ifdef RTSEMEVENTMULTI_STRICT        RTTHREAD hThreadSelf = RTThreadSelfAutoAdopt();//.........这里部分代码省略.........
开发者ID:sobomax,项目名称:virtualbox_64bit_edd,代码行数:101,


示例12: RTDECL

/** * Copies a file given the handles to both files and * provide progress callbacks. * * @returns VBox Status code. * * @param   FileSrc     The source file. The file position is unaltered. * @param   FileDst     The destination file. *                      On successful returns the file position is at the end of the file. *                      On failures the file position and size is undefined. * @param   pfnProgress Pointer to callback function for reporting progress. * @param   pvUser      User argument to pass to pfnProgress along with the completion percentage. */RTDECL(int) RTFileCopyByHandlesEx(RTFILE FileSrc, RTFILE FileDst, PFNRTPROGRESS pfnProgress, void *pvUser){    /*     * Validate input.     */    AssertMsgReturn(RTFileIsValid(FileSrc), ("FileSrc=%RTfile/n", FileSrc), VERR_INVALID_PARAMETER);    AssertMsgReturn(RTFileIsValid(FileDst), ("FileDst=%RTfile/n", FileDst), VERR_INVALID_PARAMETER);    AssertMsgReturn(!pfnProgress || VALID_PTR(pfnProgress), ("pfnProgress=%p/n", pfnProgress), VERR_INVALID_PARAMETER);    /*     * Save file offset.     */    RTFOFF offSrcSaved;    int rc = RTFileSeek(FileSrc, 0, RTFILE_SEEK_CURRENT, (uint64_t *)&offSrcSaved);    if (RT_FAILURE(rc))        return rc;    /*     * Get the file size.     */    RTFOFF cbSrc;    rc = RTFileSeek(FileSrc, 0, RTFILE_SEEK_END, (uint64_t *)&cbSrc);    if (RT_FAILURE(rc))        return rc;    /*     * Allocate buffer.     */    size_t      cbBuf;    uint8_t    *pbBufFree = NULL;    uint8_t    *pbBuf;    if (cbSrc < _512K)    {        cbBuf = 8*_1K;        pbBuf = (uint8_t *)alloca(cbBuf);    }    else    {        cbBuf = _128K;        pbBuf = pbBufFree = (uint8_t *)RTMemTmpAlloc(cbBuf);    }    if (pbBuf)    {        /*         * Seek to the start of each file         * and set the size of the destination file.         */        rc = RTFileSeek(FileSrc, 0, RTFILE_SEEK_BEGIN, NULL);        if (RT_SUCCESS(rc))        {            rc = RTFileSeek(FileDst, 0, RTFILE_SEEK_BEGIN, NULL);            if (RT_SUCCESS(rc))                rc = RTFileSetSize(FileDst, cbSrc);            if (RT_SUCCESS(rc) && pfnProgress)                rc = pfnProgress(0, pvUser);            if (RT_SUCCESS(rc))            {                /*                 * Copy loop.                 */                unsigned    uPercentage = 0;                RTFOFF      off = 0;                RTFOFF      cbPercent = cbSrc / 100;                RTFOFF      offNextPercent = cbPercent;                while (off < cbSrc)                {                    /* copy block */                    RTFOFF cbLeft = cbSrc - off;                    size_t cbBlock = cbLeft >= (RTFOFF)cbBuf ? cbBuf : (size_t)cbLeft;                    rc = RTFileRead(FileSrc, pbBuf, cbBlock, NULL);                    if (RT_FAILURE(rc))                        break;                    rc = RTFileWrite(FileDst, pbBuf, cbBlock, NULL);                    if (RT_FAILURE(rc))                        break;                    /* advance */                    off += cbBlock;                    if (pfnProgress && offNextPercent < off)                    {                        while (offNextPercent < off)                        {                            uPercentage++;                            offNextPercent += cbPercent;                        }                        rc = pfnProgress(uPercentage, pvUser);                        if (RT_FAILURE(rc))//.........这里部分代码省略.........
开发者ID:leopucci,项目名称:VirtualMonitor,代码行数:101,


示例13: socketpair

int HostDnsServiceLinux::monitorWorker(){    AutoNotify a;    int rc = socketpair(AF_LOCAL, SOCK_DGRAM, 0, g_DnsMonitorStop);    AssertMsgReturn(rc == 0, ("socketpair: failed (%d: %s)/n", errno, strerror(errno)), E_FAIL);    FileDescriptor stopper0(g_DnsMonitorStop[0]);    FileDescriptor stopper1(g_DnsMonitorStop[1]);    pollfd polls[2];    RT_ZERO(polls);    polls[0].fd = a.fileDescriptor();    polls[0].events = POLLIN;    polls[1].fd = g_DnsMonitorStop[1];    polls[1].events = POLLIN;    monitorThreadInitializationDone();    int wd[2];    wd[0] = wd[1] = -1;    /* inotify inialization */    wd[0] = inotify_add_watch(a.fileDescriptor(),                              g_ResolvConfFullPath.c_str(), IN_CLOSE_WRITE|IN_DELETE_SELF);    /**     * If /etc/resolv.conf exists we want to listen for movements: because     * # mv /etc/resolv.conf ...     * won't arm IN_DELETE_SELF on wd[0] instead it will fire IN_MOVE_FROM on wd[1].     *     * Because on some distributions /etc/resolv.conf is link, wd[0] can't detect deletion,     * it's recognizible on directory level (wd[1]) only.     */    wd[1] = inotify_add_watch(a.fileDescriptor(), g_EtcFolder.c_str(),                              wd[0] == -1 ? IN_MOVED_TO|IN_CREATE : IN_MOVED_FROM|IN_DELETE);    struct InotifyEventWithName combo;    while(true)    {        rc = poll(polls, 2, -1);        if (rc == -1)            continue;        AssertMsgReturn(   ((polls[0].revents & (POLLERR|POLLNVAL)) == 0)                        && ((polls[1].revents & (POLLERR|POLLNVAL)) == 0),                           ("Debug Me"), VERR_INTERNAL_ERROR);        if (polls[1].revents & POLLIN)            return VINF_SUCCESS; /* time to shutdown */        if (polls[0].revents & POLLIN)        {            RT_ZERO(combo);            ssize_t r = read(polls[0].fd, static_cast<void *>(&combo), sizeof(combo));            NOREF(r);            if (combo.e.wd == wd[0])            {                if (combo.e.mask & IN_CLOSE_WRITE)                {                    readResolvConf();                }                else if (combo.e.mask & IN_DELETE_SELF)                {                    inotify_rm_watch(a.fileDescriptor(), wd[0]); /* removes file watcher */                    inotify_add_watch(a.fileDescriptor(), g_EtcFolder.c_str(),                                      IN_MOVED_TO|IN_CREATE); /* alter folder watcher */                }                else if (combo.e.mask & IN_IGNORED)                {                    wd[0] = -1; /* we want receive any events on this watch */                }                else                {                    /**                     * It shouldn't happen, in release we will just ignore in debug                     * we will have to chance to look at into inotify_event                     */                    AssertMsgFailed(("Debug Me!!!"));                }            }            else if (combo.e.wd == wd[1])            {                if (   combo.e.mask & IN_MOVED_FROM                    || combo.e.mask & IN_DELETE)                {                    if (g_ResolvConf == combo.e.name)                    {                        /**                         * Our file has been moved so we should change watching mode.                         */                        inotify_rm_watch(a.fileDescriptor(), wd[0]);                        wd[1] = inotify_add_watch(a.fileDescriptor(), g_EtcFolder.c_str(),                                                  IN_MOVED_TO|IN_CREATE);                        AssertMsg(wd[1] != -1,                                  ("It shouldn't happen, further investigation is needed/n"));                    }//.........这里部分代码省略.........
开发者ID:jeppeter,项目名称:vbox,代码行数:101,


示例14: DECLCALLBACK

/** * Construct a block driver instance. * * @copydoc FNPDMDRVCONSTRUCT */static DECLCALLBACK(int) drvscsiConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags){    int rc = VINF_SUCCESS;    PDRVSCSI pThis = PDMINS_2_DATA(pDrvIns, PDRVSCSI);    LogFlowFunc(("pDrvIns=%#p pCfg=%#p/n", pDrvIns, pCfg));    PDMDRV_CHECK_VERSIONS_RETURN(pDrvIns);    /*     * Initialize the instance data.     */    pThis->pDrvIns                              = pDrvIns;    pThis->ISCSIConnector.pfnSCSIRequestSend    = drvscsiRequestSend;    pThis->ISCSIConnector.pfnQueryLUNType       = drvscsiQueryLUNType;    pDrvIns->IBase.pfnQueryInterface            = drvscsiQueryInterface;    pThis->IMountNotify.pfnMountNotify          = drvscsiMountNotify;    pThis->IMountNotify.pfnUnmountNotify        = drvscsiUnmountNotify;    pThis->IPort.pfnQueryDeviceLocation         = drvscsiQueryDeviceLocation;    pThis->IPortAsync.pfnTransferCompleteNotify = drvscsiTransferCompleteNotify;    pThis->hQueueRequests                       = NIL_RTREQQUEUE;    /* Query the SCSI port interface above. */    pThis->pDevScsiPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMISCSIPORT);    AssertMsgReturn(pThis->pDevScsiPort, ("Missing SCSI port interface above/n"), VERR_PDM_MISSING_INTERFACE);    /* Query the optional LED interface above. */    pThis->pLedPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMILEDPORTS);    if (pThis->pLedPort != NULL)    {        /* Get The Led. */        rc = pThis->pLedPort->pfnQueryStatusLed(pThis->pLedPort, 0, &pThis->pLed);        if (RT_FAILURE(rc))            pThis->pLed = &pThis->Led;    }    else        pThis->pLed = &pThis->Led;    /*     * Validate and read configuration.     */    if (!CFGMR3AreValuesValid(pCfg, "NonRotationalMedium/0Readonly/0"))        return PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_DEVINS_UNKNOWN_CFG_VALUES,                                N_("SCSI configuration error: unknown option specified"));    rc = CFGMR3QueryBoolDef(pCfg, "NonRotationalMedium", &pThis->fNonRotational, false);    if (RT_FAILURE(rc))        return PDMDRV_SET_ERROR(pDrvIns, rc,                                N_("SCSI configuration error: failed to read /"NonRotationalMedium/" as boolean"));    rc = CFGMR3QueryBoolDef(pCfg, "Readonly", &pThis->fReadonly, false);    if (RT_FAILURE(rc))        return PDMDRV_SET_ERROR(pDrvIns, rc,                                N_("SCSI configuration error: failed to read /"Readonly/" as boolean"));    /*     * Try attach driver below and query it's block interface.     */    rc = PDMDrvHlpAttach(pDrvIns, fFlags, &pThis->pDrvBase);    AssertMsgReturn(RT_SUCCESS(rc), ("Attaching driver below failed rc=%Rrc/n", rc), rc);    /*     * Query the block and blockbios interfaces.     */    pThis->pDrvMedia = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIMEDIA);    if (!pThis->pDrvMedia)    {        AssertMsgFailed(("Configuration error: No block interface!/n"));        return VERR_PDM_MISSING_INTERFACE;    }    pThis->pDrvMount = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIMOUNT);    /* Try to get the optional async block interface. */    pThis->pDrvMediaAsync = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIMEDIAASYNC);    PDMMEDIATYPE enmType = pThis->pDrvMedia->pfnGetType(pThis->pDrvMedia);    VSCSILUNTYPE enmLunType;    switch (enmType)    {    case PDMMEDIATYPE_HARD_DISK:        enmLunType = VSCSILUNTYPE_SBC;        break;    case PDMMEDIATYPE_CDROM:    case PDMMEDIATYPE_DVD:        enmLunType = VSCSILUNTYPE_MMC;        break;    default:        return PDMDrvHlpVMSetError(pDrvIns, VERR_PDM_UNSUPPORTED_BLOCK_TYPE, RT_SRC_POS,                                   N_("Only hard disks and CD/DVD-ROMs are currently supported as SCSI devices (enmType=%d)"),                                   enmType);    }    if (    (   enmType == PDMMEDIATYPE_DVD                || enmType == PDMMEDIATYPE_CDROM)            &&  !pThis->pDrvMount)//.........这里部分代码省略.........
开发者ID:jeppeter,项目名称:vbox,代码行数:101,


示例15: rtTimeNormalizeInternal

/** * Internal worker for RTTimeNormalize and RTTimeLocalNormalize. * It doesn't adjust the UCT offset but leaves that for RTTimeLocalNormalize. */static PRTTIME rtTimeNormalizeInternal(PRTTIME pTime){    unsigned    uSecond;    unsigned    uMinute;    unsigned    uHour;    bool        fLeapYear;    /*     * Fix the YearDay and Month/MonthDay.     */    fLeapYear = rtTimeIsLeapYear(pTime->i32Year);    if (!pTime->u16YearDay)    {        /*         * The Month+MonthDay must present, overflow adjust them and calc the year day.         */        AssertMsgReturn(    pTime->u8Month                        &&  pTime->u8MonthDay,                        ("date=%d-%d-%d/n", pTime->i32Year, pTime->u8Month, pTime->u8MonthDay),                        NULL);        while (pTime->u8Month > 12)        {            pTime->u8Month -= 12;            pTime->i32Year++;            fLeapYear = rtTimeIsLeapYear(pTime->i32Year);            pTime->fFlags &= ~(RTTIME_FLAGS_COMMON_YEAR | RTTIME_FLAGS_LEAP_YEAR);        }        for (;;)        {            unsigned cDaysInMonth = fLeapYear                                  ? g_acDaysInMonthsLeap[pTime->u8Month - 1]                                  : g_acDaysInMonths[pTime->u8Month - 1];            if (pTime->u8MonthDay <= cDaysInMonth)                break;            pTime->u8MonthDay -= cDaysInMonth;            if (pTime->u8Month != 12)                pTime->u8Month++;            else            {                pTime->u8Month = 1;                pTime->i32Year++;                fLeapYear = rtTimeIsLeapYear(pTime->i32Year);                pTime->fFlags &= ~(RTTIME_FLAGS_COMMON_YEAR | RTTIME_FLAGS_LEAP_YEAR);            }        }        pTime->u16YearDay  = pTime->u8MonthDay - 1                           + (fLeapYear                              ? g_aiDayOfYearLeap[pTime->u8Month - 1]                              : g_aiDayOfYear[pTime->u8Month - 1]);    }    else    {        /*         * Are both YearDay and Month/MonthDay valid?         * Check that they don't overflow and match, if not use YearDay (simpler).         */        bool fRecalc = true;        if (    pTime->u8Month            &&  pTime->u8MonthDay)        {            do            {                uint16_t u16YearDay;                /* If you change one, zero the other to make clear what you mean. */                AssertBreak(pTime->u8Month <= 12);                AssertBreak(pTime->u8MonthDay <= (fLeapYear                                                  ? g_acDaysInMonthsLeap[pTime->u8Month - 1]                                                  : g_acDaysInMonths[pTime->u8Month - 1]));                u16YearDay = pTime->u8MonthDay - 1                           + (fLeapYear                              ? g_aiDayOfYearLeap[pTime->u8Month - 1]                              : g_aiDayOfYear[pTime->u8Month - 1]);                AssertBreak(u16YearDay == pTime->u16YearDay);                fRecalc = false;            } while (0);        }        if (fRecalc)        {            const uint16_t *paiDayOfYear;            /* overflow adjust YearDay */            while (pTime->u16YearDay > (fLeapYear ? 366 : 365))            {                pTime->u16YearDay -= fLeapYear ? 366 : 365;                pTime->i32Year++;                fLeapYear = rtTimeIsLeapYear(pTime->i32Year);                pTime->fFlags &= ~(RTTIME_FLAGS_COMMON_YEAR | RTTIME_FLAGS_LEAP_YEAR);            }            /* calc Month and MonthDay */            paiDayOfYear = fLeapYear                         ? &g_aiDayOfYearLeap[0]                         : &g_aiDayOfYear[0];//.........这里部分代码省略.........
开发者ID:jeppeter,项目名称:vbox,代码行数:101,


示例16: rtZipGzip_WriteOutputBuffer

/** * Internal helper for rtZipGzip_Write, rtZipGzip_Flush and rtZipGzip_Close. * * @returns IPRT status code. * @retval  VINF_SUCCESS * @retval  VINF_TRY_AGAIN - the only informational status. * @retval  VERR_INTERRUPTED - call again. * * @param   pThis           The gzip I/O stream instance data. * @param   fBlocking       Whether to block or not. */static int rtZipGzip_WriteOutputBuffer(PRTZIPGZIPSTREAM pThis, bool fBlocking){    /*     * Anything to write?  No, then just return immediately.     */    size_t cbToWrite = sizeof(pThis->abBuffer) - pThis->Zlib.avail_out;    if (cbToWrite == 0)    {        Assert(pThis->Zlib.next_out == &pThis->abBuffer[0]);        return VINF_SUCCESS;    }    Assert(cbToWrite <= sizeof(pThis->abBuffer));    /*     * Loop write on VERR_INTERRUPTED.     *     * Note! Asserting a bit extra here to make sure the     *       RTVfsIoStrmSgWrite works correctly.     */    int    rc;    size_t cbWrittenOut;    for (;;)    {        /* Set up the buffer. */        pThis->SgSeg.cbSeg = cbToWrite;        Assert(pThis->SgSeg.pvSeg == &pThis->abBuffer[0]);        RTSgBufReset(&pThis->SgBuf);        cbWrittenOut = ~(size_t)0;        rc = RTVfsIoStrmSgWrite(pThis->hVfsIos, -1 /*off*/, &pThis->SgBuf, fBlocking, &cbWrittenOut);        if (rc != VINF_SUCCESS)        {            AssertMsg(RT_FAILURE(rc) || rc == VINF_TRY_AGAIN, ("%Rrc/n", rc));            if (rc == VERR_INTERRUPTED)            {                Assert(cbWrittenOut == 0);                continue;            }            if (RT_FAILURE(rc) || rc == VINF_TRY_AGAIN || cbWrittenOut == 0)            {                AssertReturn(cbWrittenOut == 0, VERR_INTERNAL_ERROR_3);                AssertReturn(rc != VINF_SUCCESS, VERR_IPE_UNEXPECTED_INFO_STATUS);                return rc;            }        }        break;    }    AssertMsgReturn(cbWrittenOut > 0 && cbWrittenOut <= sizeof(pThis->abBuffer),                    ("%zu %Rrc/n", cbWrittenOut, rc),                    VERR_INTERNAL_ERROR_4);    /*     * Adjust the Zlib output buffer members.     */    if (cbWrittenOut == pThis->SgBuf.paSegs[0].cbSeg)    {        pThis->Zlib.avail_out = sizeof(pThis->abBuffer);        pThis->Zlib.next_out  = &pThis->abBuffer[0];    }    else    {        Assert(cbWrittenOut <= pThis->SgBuf.paSegs[0].cbSeg);        size_t cbLeft = pThis->SgBuf.paSegs[0].cbSeg - cbWrittenOut;        memmove(&pThis->abBuffer[0], &pThis->abBuffer[cbWrittenOut], cbLeft);        pThis->Zlib.avail_out += (uInt)cbWrittenOut;        pThis->Zlib.next_out  = &pThis->abBuffer[cbWrittenOut];    }    return VINF_SUCCESS;}
开发者ID:mdaniel,项目名称:virtualbox-org-svn-vbox-trunk,代码行数:81,


示例17: rtR0SemEventMultiLnxWait

/** * Worker for RTSemEventMultiWaitEx and RTSemEventMultiWaitExDebug. * * @returns VBox status code. * @param   pThis           The event semaphore. * @param   fFlags          See RTSemEventMultiWaitEx. * @param   uTimeout        See RTSemEventMultiWaitEx. * @param   pSrcPos         The source code position of the wait. */static int rtR0SemEventMultiLnxWait(PRTSEMEVENTMULTIINTERNAL pThis, uint32_t fFlags, uint64_t uTimeout,                                    PCRTLOCKVALSRCPOS pSrcPos){    uint32_t    fOrgStateAndGen;    int         rc;    /*     * Validate the input.     */    AssertPtrReturn(pThis, VERR_INVALID_PARAMETER);    AssertMsgReturn(pThis->u32Magic == RTSEMEVENTMULTI_MAGIC, ("%p u32Magic=%RX32/n", pThis, pThis->u32Magic), VERR_INVALID_PARAMETER);    AssertReturn(RTSEMWAIT_FLAGS_ARE_VALID(fFlags), VERR_INVALID_PARAMETER);    rtR0SemEventMultiLnxRetain(pThis);    /*     * Is the event already signalled or do we have to wait?     */    fOrgStateAndGen = ASMAtomicUoReadU32(&pThis->fStateAndGen);    if (fOrgStateAndGen & RTSEMEVENTMULTILNX_STATE_MASK)        rc = VINF_SUCCESS;    else    {        /*         * We have to wait.         */        RTR0SEMLNXWAIT Wait;        rc = rtR0SemLnxWaitInit(&Wait, fFlags, uTimeout, &pThis->Head);        if (RT_SUCCESS(rc))        {            IPRT_DEBUG_SEMS_STATE(pThis, 'E');            for (;;)            {                /* The destruction test. */                if (RT_UNLIKELY(pThis->u32Magic != RTSEMEVENTMULTI_MAGIC))                    rc = VERR_SEM_DESTROYED;                else                {                    rtR0SemLnxWaitPrepare(&Wait);                    /* Check the exit conditions. */                    if (RT_UNLIKELY(pThis->u32Magic != RTSEMEVENTMULTI_MAGIC))                        rc = VERR_SEM_DESTROYED;                    else if (ASMAtomicUoReadU32(&pThis->fStateAndGen) != fOrgStateAndGen)                        rc = VINF_SUCCESS;                    else if (rtR0SemLnxWaitHasTimedOut(&Wait))                        rc = VERR_TIMEOUT;                    else if (rtR0SemLnxWaitWasInterrupted(&Wait))                        rc = VERR_INTERRUPTED;                    else                    {                        /* Do the wait and then recheck the conditions. */                        rtR0SemLnxWaitDoIt(&Wait);                        continue;                    }                }                break;            }            rtR0SemLnxWaitDelete(&Wait);            IPRT_DEBUG_SEMS_STATE_RC(pThis, 'E', rc);        }    }    rtR0SemEventMultiLnxRelease(pThis);    return rc;}
开发者ID:gbriones1,项目名称:clear-vboxadd,代码行数:75,


示例18: RTDECL

RTDECL(int) RTMpNotificationRegister(PFNRTMPNOTIFICATION pfnCallback, void *pvUser){    PRTMPNOTIFYREG  pCur;    PRTMPNOTIFYREG  pNew;    /*     * Validation.     */    AssertPtrReturn(pfnCallback, VERR_INVALID_POINTER);    AssertReturn(g_hRTMpNotifySpinLock != NIL_RTSPINLOCK, VERR_WRONG_ORDER);    RT_ASSERT_PREEMPTIBLE();    RTSpinlockAcquire(g_hRTMpNotifySpinLock);    for (pCur = g_pRTMpCallbackHead; pCur; pCur = pCur->pNext)        if (    pCur->pvUser == pvUser            &&  pCur->pfnCallback == pfnCallback)            break;    RTSpinlockRelease(g_hRTMpNotifySpinLock);    AssertMsgReturn(!pCur, ("pCur=%p pfnCallback=%p pvUser=%p/n", pCur, pfnCallback, pvUser), VERR_ALREADY_EXISTS);    /*     * Allocate a new record and attempt to insert it.     */    pNew = (PRTMPNOTIFYREG)RTMemAlloc(sizeof(*pNew));    if (!pNew)        return VERR_NO_MEMORY;    pNew->pNext = NULL;    pNew->pfnCallback = pfnCallback;    pNew->pvUser = pvUser;    memset(&pNew->bmDone[0], 0xff, sizeof(pNew->bmDone));    RTSpinlockAcquire(g_hRTMpNotifySpinLock);    pCur = g_pRTMpCallbackHead;    if (!pCur)        g_pRTMpCallbackHead = pNew;    else    {        for (pCur = g_pRTMpCallbackHead; ; pCur = pCur->pNext)            if (    pCur->pvUser == pvUser                &&  pCur->pfnCallback == pfnCallback)                break;            else if (!pCur->pNext)            {                pCur->pNext = pNew;                pCur = NULL;                break;            }    }    ASMAtomicIncU32(&g_iRTMpGeneration);    RTSpinlockRelease(g_hRTMpNotifySpinLock);    /* duplicate? */    if (pCur)    {        RTMemFree(pCur);        AssertMsgFailedReturn(("pCur=%p pfnCallback=%p pvUser=%p/n", pCur, pfnCallback, pvUser), VERR_ALREADY_EXISTS);    }    return VINF_SUCCESS;}
开发者ID:jeppeter,项目名称:vbox,代码行数:64,


示例19: rtR0SemEventLnxWait

/** * Worker for RTSemEventWaitEx and RTSemEventWaitExDebug. * * @returns VBox status code. * @param   pThis           The event semaphore. * @param   fFlags          See RTSemEventWaitEx. * @param   uTimeout        See RTSemEventWaitEx. * @param   pSrcPos         The source code position of the wait. */static int rtR0SemEventLnxWait(PRTSEMEVENTINTERNAL pThis, uint32_t fFlags, uint64_t uTimeout,                               PCRTLOCKVALSRCPOS pSrcPos){    int rc;    /*     * Validate the input.     */    AssertPtrReturn(pThis, VERR_INVALID_PARAMETER);    AssertMsgReturn(pThis->u32Magic == RTSEMEVENT_MAGIC, ("%p u32Magic=%RX32/n", pThis, pThis->u32Magic), VERR_INVALID_PARAMETER);    AssertReturn(RTSEMWAIT_FLAGS_ARE_VALID(fFlags), VERR_INVALID_PARAMETER);    rtR0SemEventLnxRetain(pThis);    /*     * Try grab the event without setting up the wait.     */    if (   1 /** @todo check if there are someone waiting already - waitqueue_active, but then what do we do below? */        && ASMAtomicCmpXchgU32(&pThis->fState, 0, 1))        rc = VINF_SUCCESS;    else    {        /*         * We have to wait.         */        IPRT_LINUX_SAVE_EFL_AC();        RTR0SEMLNXWAIT Wait;        rc = rtR0SemLnxWaitInit(&Wait, fFlags, uTimeout, &pThis->Head);        if (RT_SUCCESS(rc))        {            IPRT_DEBUG_SEMS_STATE(pThis, 'E');            for (;;)            {                /* The destruction test. */                if (RT_UNLIKELY(pThis->u32Magic != RTSEMEVENT_MAGIC))                    rc = VERR_SEM_DESTROYED;                else                {                    rtR0SemLnxWaitPrepare(&Wait);                    /* Check the exit conditions. */                    if (RT_UNLIKELY(pThis->u32Magic != RTSEMEVENT_MAGIC))                        rc = VERR_SEM_DESTROYED;                    else if (ASMAtomicCmpXchgU32(&pThis->fState, 0, 1))                        rc = VINF_SUCCESS;                    else if (rtR0SemLnxWaitHasTimedOut(&Wait))                        rc = VERR_TIMEOUT;                    else if (rtR0SemLnxWaitWasInterrupted(&Wait))                        rc = VERR_INTERRUPTED;                    else                    {                        /* Do the wait and then recheck the conditions. */                        rtR0SemLnxWaitDoIt(&Wait);                        continue;                    }                }                break;            }            rtR0SemLnxWaitDelete(&Wait);            IPRT_DEBUG_SEMS_STATE_RC(pThis, 'E', rc);        }        IPRT_LINUX_RESTORE_EFL_AC();    }    rtR0SemEventLnxRelease(pThis);    return rc;}
开发者ID:ailispaw,项目名称:vboxguest,代码行数:76,


示例20: RTDECL

RTDECL(int) RTDirReadEx(PRTDIR pDir, PRTDIRENTRYEX pDirEntry, size_t *pcbDirEntry, RTFSOBJATTRADD enmAdditionalAttribs, uint32_t fFlags){    /** @todo Symlinks: Find[First|Next]FileW will return info about        the link, so RTPATH_F_FOLLOW_LINK is not handled correctly. */    /*     * Validate input.     */    if (!pDir || pDir->u32Magic != RTDIR_MAGIC)    {        AssertMsgFailed(("Invalid pDir=%p/n", pDir));        return VERR_INVALID_PARAMETER;    }    if (!pDirEntry)    {        AssertMsgFailed(("Invalid pDirEntry=%p/n", pDirEntry));        return VERR_INVALID_PARAMETER;    }    if (    enmAdditionalAttribs < RTFSOBJATTRADD_NOTHING        ||  enmAdditionalAttribs > RTFSOBJATTRADD_LAST)    {        AssertMsgFailed(("Invalid enmAdditionalAttribs=%p/n", enmAdditionalAttribs));        return VERR_INVALID_PARAMETER;    }    AssertMsgReturn(RTPATH_F_IS_VALID(fFlags, 0), ("%#x/n", fFlags), VERR_INVALID_PARAMETER);    size_t cbDirEntry = sizeof(*pDirEntry);    if (pcbDirEntry)    {        cbDirEntry = *pcbDirEntry;        if (cbDirEntry < RT_UOFFSETOF(RTDIRENTRYEX, szName[2]))        {            AssertMsgFailed(("Invalid *pcbDirEntry=%d (min %d)/n", *pcbDirEntry, RT_OFFSETOF(RTDIRENTRYEX, szName[2])));            return VERR_INVALID_PARAMETER;        }    }    /*     * Fetch data?     */    if (!pDir->fDataUnread)    {        RTStrFree(pDir->pszName);        pDir->pszName = NULL;        BOOL fRc = FindNextFileW(pDir->hDir, &pDir->Data);        if (!fRc)        {            int iErr = GetLastError();            if (pDir->hDir == INVALID_HANDLE_VALUE || iErr == ERROR_NO_MORE_FILES)                return VERR_NO_MORE_FILES;            return RTErrConvertFromWin32(iErr);        }    }    /*     * Convert the filename to UTF-8.     */    if (!pDir->pszName)    {        int rc = RTUtf16ToUtf8((PCRTUTF16)pDir->Data.cFileName, &pDir->pszName);        if (RT_FAILURE(rc))        {            pDir->pszName = NULL;            return rc;        }        pDir->cchName = strlen(pDir->pszName);    }    /*     * Check if we've got enough space to return the data.     */    const char  *pszName    = pDir->pszName;    const size_t cchName    = pDir->cchName;    const size_t cbRequired = RT_OFFSETOF(RTDIRENTRYEX, szName[1]) + cchName;    if (pcbDirEntry)        *pcbDirEntry = cbRequired;    if (cbRequired > cbDirEntry)        return VERR_BUFFER_OVERFLOW;    /*     * Setup the returned data.     */    pDir->fDataUnread  = false;    pDirEntry->cbName  = (uint16_t)cchName;    Assert(pDirEntry->cbName == cchName);    memcpy(pDirEntry->szName, pszName, cchName + 1);    if (pDir->Data.cAlternateFileName[0])    {        /* copy and calc length */        PCRTUTF16 pwszSrc = (PCRTUTF16)pDir->Data.cAlternateFileName;        PRTUTF16  pwszDst = pDirEntry->wszShortName;        uint32_t  off = 0;        while (pwszSrc[off] && off < RT_ELEMENTS(pDirEntry->wszShortName) - 1U)        {            pwszDst[off] = pwszSrc[off];            off++;        }        pDirEntry->cwcShortName = (uint16_t)off;        /* zero the rest */        do//.........这里部分代码省略.........
开发者ID:virendramishra,项目名称:VirtualBox4.1.18,代码行数:101,


示例21: DECLHIDDEN

DECLHIDDEN(int) rtR0MemObjNativeAllocLow(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, bool fExecutable){    AssertMsgReturn(cb <= _1G, ("%#x/n", cb), VERR_OUT_OF_RANGE); /* for safe size_t -> ULONG */    /*     * Try see if we get lucky first...     * (We could probably just assume we're lucky on NT4.)     */    int rc = rtR0MemObjNativeAllocPage(ppMem, cb, fExecutable);    if (RT_SUCCESS(rc))    {        size_t iPage = cb >> PAGE_SHIFT;        while (iPage-- > 0)            if (rtR0MemObjNativeGetPagePhysAddr(*ppMem, iPage) >= _4G)            {                rc = VERR_NO_LOW_MEMORY;                break;            }        if (RT_SUCCESS(rc))            return rc;        /* The following ASSUMES that rtR0MemObjNativeAllocPage returns a completed object. */        RTR0MemObjFree(*ppMem, false);        *ppMem = NULL;    }#ifndef IPRT_TARGET_NT4    /*     * Use MmAllocatePagesForMdl to specify the range of physical addresses we wish to use.     */    PHYSICAL_ADDRESS Zero;    Zero.QuadPart = 0;    PHYSICAL_ADDRESS HighAddr;    HighAddr.QuadPart = _4G - 1;    PMDL pMdl = MmAllocatePagesForMdl(Zero, HighAddr, Zero, cb);    if (pMdl)    {        if (MmGetMdlByteCount(pMdl) >= cb)        {            __try            {                void *pv = MmMapLockedPagesSpecifyCache(pMdl, KernelMode, MmCached, NULL /* no base address */,                                                        FALSE /* no bug check on failure */, NormalPagePriority);                if (pv)                {                    PRTR0MEMOBJNT pMemNt = (PRTR0MEMOBJNT)rtR0MemObjNew(sizeof(*pMemNt), RTR0MEMOBJTYPE_LOW, pv, cb);                    if (pMemNt)                    {                        pMemNt->fAllocatedPagesForMdl = true;                        pMemNt->cMdls = 1;                        pMemNt->apMdls[0] = pMdl;                        *ppMem = &pMemNt->Core;                        return VINF_SUCCESS;                    }                    MmUnmapLockedPages(pv, pMdl);                }            }            __except(EXCEPTION_EXECUTE_HANDLER)            {                NTSTATUS rcNt = GetExceptionCode();                Log(("rtR0MemObjNativeAllocLow: Exception Code %#x/n", rcNt));                /* nothing */            }        }        MmFreePagesFromMdl(pMdl);        ExFreePool(pMdl);    }
开发者ID:stefano-garzarella,项目名称:virtualbox-org-svn-vbox-trunk,代码行数:67,



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


C++ AssertNoneLocked函数代码示例
C++ AssertMsgFailed函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。