本文整理汇总了C++中AssertMsgFailed函数的典型用法代码示例。如果您正苦于以下问题:C++ AssertMsgFailed函数的具体用法?C++ AssertMsgFailed怎么用?C++ AssertMsgFailed使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了AssertMsgFailed函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: vboxfuseOp_write
//.........这里部分代码省略.........
else if (offFile >= pFlatImage->Node.cbPrimary)
rc = 0;
else if (!cbBuf)
rc = 0;
else
{
/* Adjust for EOF. */
if ((off_t)(offFile + cbBuf) >= pFlatImage->Node.cbPrimary)
cbBuf = pFlatImage->Node.cbPrimary - offFile;
/*
* Aligned write?
*/
int rc2;
if ( !(offFile & VBOXFUSE_MIN_SIZE_MASK_OFF)
&& !(cbBuf & VBOXFUSE_MIN_SIZE_MASK_OFF))
rc2 = VDWrite(pFlatImage->pDisk, offFile, pbBuf, cbBuf);
else
{
/*
* Unaligned write - lots of extra work.
*/
uint8_t abBlock[VBOXFUSE_MIN_SIZE];
if (((offFile + cbBuf) & VBOXFUSE_MIN_SIZE_MASK_BLK) == (offFile & VBOXFUSE_MIN_SIZE_MASK_BLK))
{
/* a single partial block. */
rc2 = VDRead(pFlatImage->pDisk, offFile & VBOXFUSE_MIN_SIZE_MASK_BLK, abBlock, VBOXFUSE_MIN_SIZE);
if (RT_SUCCESS(rc2))
{
memcpy(&abBlock[offFile & VBOXFUSE_MIN_SIZE_MASK_OFF], pbBuf, cbBuf);
/* Update the block */
rc2 = VDWrite(pFlatImage->pDisk, offFile & VBOXFUSE_MIN_SIZE_MASK_BLK, abBlock, VBOXFUSE_MIN_SIZE);
}
}
else
{
/* read unaligned head. */
rc2 = VINF_SUCCESS;
if (offFile & VBOXFUSE_MIN_SIZE_MASK_OFF)
{
rc2 = VDRead(pFlatImage->pDisk, offFile & VBOXFUSE_MIN_SIZE_MASK_BLK, abBlock, VBOXFUSE_MIN_SIZE);
if (RT_SUCCESS(rc2))
{
size_t cbCopy = VBOXFUSE_MIN_SIZE - (offFile & VBOXFUSE_MIN_SIZE_MASK_OFF);
memcpy(&abBlock[offFile & VBOXFUSE_MIN_SIZE_MASK_OFF], pbBuf, cbCopy);
pbBuf += cbCopy;
offFile += cbCopy;
cbBuf -= cbCopy;
rc2 = VDWrite(pFlatImage->pDisk, offFile & VBOXFUSE_MIN_SIZE_MASK_BLK, abBlock, VBOXFUSE_MIN_SIZE);
}
}
/* write the middle. */
Assert(!(offFile & VBOXFUSE_MIN_SIZE_MASK_OFF));
if (cbBuf >= VBOXFUSE_MIN_SIZE && RT_SUCCESS(rc2))
{
size_t cbWrite = cbBuf & VBOXFUSE_MIN_SIZE_MASK_BLK;
rc2 = VDWrite(pFlatImage->pDisk, offFile, pbBuf, cbWrite);
if (RT_SUCCESS(rc2))
{
pbBuf += cbWrite;
offFile += cbWrite;
cbBuf -= cbWrite;
}
}
/* unaligned tail write. */
Assert(cbBuf < VBOXFUSE_MIN_SIZE);
Assert(!(offFile & VBOXFUSE_MIN_SIZE_MASK_OFF));
if (cbBuf && RT_SUCCESS(rc2))
{
rc2 = VDRead(pFlatImage->pDisk, offFile, abBlock, VBOXFUSE_MIN_SIZE);
if (RT_SUCCESS(rc2))
{
memcpy(&abBlock[0], pbBuf, cbBuf);
rc2 = VDWrite(pFlatImage->pDisk, offFile, abBlock, VBOXFUSE_MIN_SIZE);
}
}
}
}
/* convert the return code */
if (RT_SUCCESS(rc2))
rc = cbBuf;
else
rc = -RTErrConvertToErrno(rc2);
}
vboxfuseNodeUnlock(&pFlatImage->Node);
return rc;
}
case VBOXFUSETYPE_CONTROL_PIPE:
return -ENOTSUP;
default:
AssertMsgFailed(("%s\n", pszPath));
return -EDOOFUS;
}
}
开发者ID:leopucci,项目名称:VirtualMonitor,代码行数:101,代码来源:VBoxFUSE.cpp
示例2: rtZipGzipConvertErrFromZlib
/**
* Convert from zlib to IPRT status codes.
*
* This will also set the fFatalError flag when appropriate.
*
* @returns IPRT status code.
* @param pThis The gzip I/O stream instance data.
* @param rc Zlib error code.
*/
static int rtZipGzipConvertErrFromZlib(PRTZIPGZIPSTREAM pThis, int rc)
{
switch (rc)
{
case Z_OK:
return VINF_SUCCESS;
case Z_BUF_ERROR:
/* This isn't fatal. */
return VINF_SUCCESS; /** @todo The code in zip.cpp treats Z_BUF_ERROR as fatal... */
case Z_STREAM_ERROR:
pThis->fFatalError = true;
return VERR_ZIP_CORRUPTED;
case Z_DATA_ERROR:
pThis->fFatalError = true;
return pThis->fDecompress ? VERR_ZIP_CORRUPTED : VERR_ZIP_ERROR;
case Z_MEM_ERROR:
pThis->fFatalError = true;
return VERR_ZIP_NO_MEMORY;
case Z_VERSION_ERROR:
pThis->fFatalError = true;
return VERR_ZIP_UNSUPPORTED_VERSION;
case Z_ERRNO: /* We shouldn't see this status! */
default:
AssertMsgFailed(("%d\n", rc));
if (rc >= 0)
return VINF_SUCCESS;
pThis->fFatalError = true;
return VERR_ZIP_ERROR;
}
}
开发者ID:jeppeter,项目名称:vbox,代码行数:45,代码来源:gzipvfs.cpp
示例3: QRegExp
/* StorageSlot <= QString: */
template<> StorageSlot fromString<StorageSlot>(const QString &strStorageSlot)
{
QHash<int, QString> list;
list[0] = QApplication::translate("VBoxGlobal", "IDE Primary Master", "StorageSlot");
list[1] = QApplication::translate("VBoxGlobal", "IDE Primary Slave", "StorageSlot");
list[2] = QApplication::translate("VBoxGlobal", "IDE Secondary Master", "StorageSlot");
list[3] = QApplication::translate("VBoxGlobal", "IDE Secondary Slave", "StorageSlot");
list[4] = QApplication::translate("VBoxGlobal", "SATA Port %1", "StorageSlot");
list[5] = QApplication::translate("VBoxGlobal", "SCSI Port %1", "StorageSlot");
list[6] = QApplication::translate("VBoxGlobal", "SAS Port %1", "StorageSlot");
list[7] = QApplication::translate("VBoxGlobal", "Floppy Device %1", "StorageSlot");
int index = -1;
QRegExp regExp;
for (int i = 0; i < list.size(); ++i)
{
regExp = QRegExp(i >= 0 && i <= 3 ? list[i] : list[i].arg("(\\d+)"));
if (regExp.indexIn(strStorageSlot) != -1)
{
index = i;
break;
}
}
StorageSlot result;
switch (index)
{
case 0:
case 1:
case 2:
case 3:
{
KStorageBus bus = KStorageBus_IDE;
int iMaxPort = vboxGlobal().virtualBox().GetSystemProperties().GetMaxPortCountForStorageBus(bus);
int iMaxDevice = vboxGlobal().virtualBox().GetSystemProperties().GetMaxDevicesPerPortForStorageBus(bus);
LONG iPort = index / iMaxPort;
LONG iDevice = index % iMaxPort;
if (iPort < 0 || iPort > iMaxPort)
{
AssertMsgFailed(("No storage slot for text='%s'", strStorageSlot.toAscii().constData()));
break;
}
if (iDevice < 0 || iDevice > iMaxDevice)
{
AssertMsgFailed(("No storage slot for text='%s'", strStorageSlot.toAscii().constData()));
break;
}
result.bus = bus;
result.port = iPort;
result.device = iDevice;
break;
}
case 4:
{
KStorageBus bus = KStorageBus_SATA;
int iMaxPort = vboxGlobal().virtualBox().GetSystemProperties().GetMaxPortCountForStorageBus(bus);
LONG iPort = regExp.cap(1).toInt();
LONG iDevice = 0;
if (iPort < 0 || iPort > iMaxPort)
{
AssertMsgFailed(("No storage slot for text='%s'", strStorageSlot.toAscii().constData()));
break;
}
result.bus = bus;
result.port = iPort;
result.device = iDevice;
break;
}
case 5:
{
KStorageBus bus = KStorageBus_SCSI;
int iMaxPort = vboxGlobal().virtualBox().GetSystemProperties().GetMaxPortCountForStorageBus(bus);
LONG iPort = regExp.cap(1).toInt();
LONG iDevice = 0;
if (iPort < 0 || iPort > iMaxPort)
{
AssertMsgFailed(("No storage slot for text='%s'", strStorageSlot.toAscii().constData()));
break;
}
result.bus = bus;
result.port = iPort;
result.device = iDevice;
break;
}
case 6:
{
KStorageBus bus = KStorageBus_SAS;
int iMaxPort = vboxGlobal().virtualBox().GetSystemProperties().GetMaxPortCountForStorageBus(bus);
LONG iPort = regExp.cap(1).toInt();
LONG iDevice = 0;
if (iPort < 0 || iPort > iMaxPort)
{
AssertMsgFailed(("No storage slot for text='%s'", strStorageSlot.toAscii().constData()));
break;
}
result.bus = bus;
result.port = iPort;
result.device = iDevice;
break;
}
//.........这里部分代码省略.........
开发者ID:MadHacker217,项目名称:VirtualBox-OSE,代码行数:101,代码来源:UIConverterBackendGlobal.cpp
示例4: switch
/* static */
QIcon UIIconPool::defaultIcon(UIDefaultIconType defaultIconType, const QWidget *pWidget /* = 0 */)
{
QIcon icon;
QStyle *pStyle = pWidget ? pWidget->style() : QApplication::style();
switch (defaultIconType)
{
case UIDefaultIconType_MessageBoxInformation:
{
icon = pStyle->standardIcon(QStyle::SP_MessageBoxInformation, 0, pWidget);
break;
}
case UIDefaultIconType_MessageBoxQuestion:
{
icon = pStyle->standardIcon(QStyle::SP_MessageBoxQuestion, 0, pWidget);
break;
}
case UIDefaultIconType_MessageBoxWarning:
{
#ifdef Q_WS_MAC
/* At least in Qt 4.3.4/4.4 RC1 SP_MessageBoxWarning is the application
* icon. So change this to the critical icon. (Maybe this would be
* fixed in a later Qt version) */
icon = pStyle->standardIcon(QStyle::SP_MessageBoxCritical, 0, pWidget);
#else /* Q_WS_MAC */
icon = pStyle->standardIcon(QStyle::SP_MessageBoxWarning, 0, pWidget);
#endif /* !Q_WS_MAC */
break;
}
case UIDefaultIconType_MessageBoxCritical:
{
icon = pStyle->standardIcon(QStyle::SP_MessageBoxCritical, 0, pWidget);
break;
}
case UIDefaultIconType_DialogCancel:
{
icon = pStyle->standardIcon(QStyle::SP_DialogCancelButton, 0, pWidget);
if (icon.isNull())
icon = iconSet(":/cancel_16px.png");
break;
}
case UIDefaultIconType_DialogHelp:
{
icon = pStyle->standardIcon(QStyle::SP_DialogHelpButton, 0, pWidget);
if (icon.isNull())
icon = iconSet(":/help_16px.png");
break;
}
case UIDefaultIconType_ArrowBack:
{
icon = pStyle->standardIcon(QStyle::SP_ArrowBack, 0, pWidget);
if (icon.isNull())
icon = iconSet(":/list_moveup_16px.png",
":/list_moveup_disabled_16px.png");
break;
}
case UIDefaultIconType_ArrowForward:
{
icon = pStyle->standardIcon(QStyle::SP_ArrowForward, 0, pWidget);
if (icon.isNull())
icon = iconSet(":/list_movedown_16px.png",
":/list_movedown_disabled_16px.png");
break;
}
default:
{
AssertMsgFailed(("Unknown default icon type!"));
break;
}
}
return icon;
}
开发者ID:mcenirm,项目名称:vbox,代码行数:72,代码来源:UIIconPool.cpp
示例5: VMMDECL
/**
* Maps a range of physical pages at a given virtual address
* in the guest context.
*
* The GC virtual address range must be within an existing mapping.
*
* @returns VBox status code.
* @param pVM The virtual machine.
* @param GCPtr Where to map the page(s). Must be page aligned.
* @param HCPhys Start of the range of physical pages. Must be page aligned.
* @param cbPages Number of bytes to map. Must be page aligned.
* @param fFlags Page flags (X86_PTE_*).
*/
VMMDECL(int) PGMMap(PVM pVM, RTGCUINTPTR GCPtr, RTHCPHYS HCPhys, uint32_t cbPages, unsigned fFlags)
{
AssertMsg(pVM->pgm.s.offVM, ("Bad init order\n"));
/*
* Validate input.
*/
AssertMsg(RT_ALIGN_T(GCPtr, PAGE_SIZE, RTGCUINTPTR) == GCPtr, ("Invalid alignment GCPtr=%#x\n", GCPtr));
AssertMsg(cbPages > 0 && RT_ALIGN_32(cbPages, PAGE_SIZE) == cbPages, ("Invalid cbPages=%#x\n", cbPages));
AssertMsg(!(fFlags & X86_PDE_PG_MASK), ("Invalid flags %#x\n", fFlags));
/* hypervisor defaults */
if (!fFlags)
fFlags = X86_PTE_P | X86_PTE_A | X86_PTE_D;
/*
* Find the mapping.
*/
PPGMMAPPING pCur = pVM->pgm.s.CTX_SUFF(pMappings);
while (pCur)
{
if (GCPtr - pCur->GCPtr < pCur->cb)
{
if (GCPtr + cbPages - 1 > pCur->GCPtrLast)
{
AssertMsgFailed(("Invalid range!!\n"));
return VERR_INVALID_PARAMETER;
}
/*
* Setup PTE.
*/
X86PTEPAE Pte;
Pte.u = fFlags | (HCPhys & X86_PTE_PAE_PG_MASK);
/*
* Update the page tables.
*/
for (;;)
{
RTGCUINTPTR off = GCPtr - pCur->GCPtr;
const unsigned iPT = off >> X86_PD_SHIFT;
const unsigned iPageNo = (off >> PAGE_SHIFT) & X86_PT_MASK;
/* 32-bit */
pCur->aPTs[iPT].CTX_SUFF(pPT)->a[iPageNo].u = (uint32_t)Pte.u; /* ASSUMES HCPhys < 4GB and/or that we're never gonna do 32-bit on a PAE host! */
/* pae */
PGMSHWPTEPAE_SET(pCur->aPTs[iPT].CTX_SUFF(paPaePTs)[iPageNo / 512].a[iPageNo % 512], Pte.u);
/* next */
cbPages -= PAGE_SIZE;
if (!cbPages)
break;
GCPtr += PAGE_SIZE;
Pte.u += PAGE_SIZE;
}
return VINF_SUCCESS;
}
/* next */
pCur = pCur->CTX_SUFF(pNext);
}
AssertMsgFailed(("GCPtr=%#x was not found in any mapping ranges!\n", GCPtr));
return VERR_INVALID_PARAMETER;
}
开发者ID:leopucci,项目名称:VirtualMonitor,代码行数:81,代码来源:PGMAllMap.cpp
示例6: DECLCALLBACK
/**
* Reap URBs in-flight on a device.
*
* @returns Pointer to a completed URB.
* @returns NULL if no URB was completed.
* @param pProxyDev The device.
* @param cMillies Number of milliseconds to wait. Use 0 to not
* wait at all.
*/
static DECLCALLBACK(PVUSBURB) usbProxyWinUrbReap(PUSBPROXYDEV pProxyDev, RTMSINTERVAL cMillies)
{
PPRIV_USBW32 pPriv = USBPROXYDEV_2_DATA(pProxyDev, PPRIV_USBW32);
AssertReturn(pPriv, NULL);
/*
* There are some unnecessary calls, just return immediately or
* WaitForMultipleObjects will fail.
*/
if ( pPriv->cQueuedUrbs <= 0
&& pPriv->cPendingUrbs == 0)
{
if ( cMillies != 0
&& pPriv->cPendingUrbs == 0)
{
/* Wait for the wakeup call. */
DWORD cMilliesWait = cMillies == RT_INDEFINITE_WAIT ? INFINITE : cMillies;
DWORD rc = WaitForMultipleObjects(1, &pPriv->hEventWakeup, FALSE, cMilliesWait);
}
return NULL;
}
again:
/* Check for pending URBs. */
if (pPriv->cPendingUrbs)
{
RTCritSectEnter(&pPriv->CritSect);
/* Ensure we've got sufficient space in the arrays. */
if (pPriv->cQueuedUrbs + pPriv->cPendingUrbs + 1 > pPriv->cAllocatedUrbs)
{
unsigned cNewMax = pPriv->cAllocatedUrbs + pPriv->cPendingUrbs + 1;
void *pv = RTMemRealloc(pPriv->paHandles, sizeof(pPriv->paHandles[0]) * (cNewMax + 1)); /* One extra for the wakeup event. */
if (!pv)
{
AssertMsgFailed(("RTMemRealloc failed for paHandles[%d]", cNewMax));
//break;
}
pPriv->paHandles = (PHANDLE)pv;
pv = RTMemRealloc(pPriv->paQueuedUrbs, sizeof(pPriv->paQueuedUrbs[0]) * cNewMax);
if (!pv)
{
AssertMsgFailed(("RTMemRealloc failed for paQueuedUrbs[%d]", cNewMax));
//break;
}
pPriv->paQueuedUrbs = (PQUEUED_URB *)pv;
pPriv->cAllocatedUrbs = cNewMax;
}
/* Copy the pending URBs over. */
for (unsigned i = 0; i < pPriv->cPendingUrbs; i++)
{
pPriv->paHandles[pPriv->cQueuedUrbs + i] = pPriv->aPendingUrbs[i]->overlapped.hEvent;
pPriv->paQueuedUrbs[pPriv->cQueuedUrbs + i] = pPriv->aPendingUrbs[i];
}
pPriv->cQueuedUrbs += pPriv->cPendingUrbs;
pPriv->cPendingUrbs = 0;
pPriv->paHandles[pPriv->cQueuedUrbs] = pPriv->hEventWakeup;
pPriv->paHandles[pPriv->cQueuedUrbs + 1] = INVALID_HANDLE_VALUE;
RTCritSectLeave(&pPriv->CritSect);
}
/*
* Wait/poll.
*
* ASSUMPTIONS:
* 1. The usbProxyWinUrbReap can not be run concurrently with each other
* so racing the cQueuedUrbs access/modification can not occur.
* 2. The usbProxyWinUrbReap can not be run concurrently with
* usbProxyWinUrbQueue so they can not race the pPriv->paHandles
* access/realloc.
*/
unsigned cQueuedUrbs = ASMAtomicReadU32((volatile uint32_t *)&pPriv->cQueuedUrbs);
DWORD cMilliesWait = cMillies == RT_INDEFINITE_WAIT ? INFINITE : cMillies;
PVUSBURB pUrb = NULL;
DWORD rc = WaitForMultipleObjects(cQueuedUrbs + 1, pPriv->paHandles, FALSE, cMilliesWait);
/* If the wakeup event fired return immediately. */
if (rc == WAIT_OBJECT_0 + cQueuedUrbs)
{
if (pPriv->cPendingUrbs)
goto again;
return NULL;
}
if (rc >= WAIT_OBJECT_0 && rc < WAIT_OBJECT_0 + cQueuedUrbs)
{
RTCritSectEnter(&pPriv->CritSect);
//.........这里部分代码省略.........
开发者ID:mcenirm,项目名称:vbox,代码行数:101,代码来源:USBProxyDevice-win.cpp
示例7: rtR0SemMutexDarwinRequestSleep
/**
* Internal worker for the sleep scenario.
*
* Called owning the spinlock, returns without it.
*
* @returns IPRT status code.
* @param pThis The mutex instance.
* @param cMillies The timeout.
* @param fInterruptible Whether it's interruptible
* (RTSemMutexRequestNoResume) or not
* (RTSemMutexRequest).
* @param hNativeSelf The thread handle of the caller.
*/
static int rtR0SemMutexDarwinRequestSleep(PRTSEMMUTEXINTERNAL pThis, RTMSINTERVAL cMillies,
wait_interrupt_t fInterruptible, RTNATIVETHREAD hNativeSelf)
{
/*
* Grab a reference and indicate that we're waiting.
*/
pThis->cWaiters++;
ASMAtomicIncU32(&pThis->cRefs);
/*
* Go to sleep, use the address of the mutex instance as sleep/blocking/event id.
*/
wait_result_t rcWait;
if (cMillies == RT_INDEFINITE_WAIT)
rcWait = lck_spin_sleep(pThis->pSpinlock, LCK_SLEEP_DEFAULT, (event_t)pThis, fInterruptible);
else
{
uint64_t u64AbsTime;
nanoseconds_to_absolutetime(cMillies * UINT64_C(1000000), &u64AbsTime);
u64AbsTime += mach_absolute_time();
rcWait = lck_spin_sleep_deadline(pThis->pSpinlock, LCK_SLEEP_DEFAULT,
(event_t)pThis, fInterruptible, u64AbsTime);
}
/*
* Translate the rc.
*/
int rc;
switch (rcWait)
{
case THREAD_AWAKENED:
if (RT_LIKELY(pThis->u32Magic == RTSEMMUTEX_MAGIC))
{
if (RT_LIKELY( pThis->cRecursions == 0
&& pThis->hNativeOwner == NIL_RTNATIVETHREAD))
{
pThis->cRecursions = 1;
pThis->hNativeOwner = hNativeSelf;
rc = VINF_SUCCESS;
}
else
{
Assert(pThis->cRecursions == 0);
Assert(pThis->hNativeOwner == NIL_RTNATIVETHREAD);
rc = VERR_INTERNAL_ERROR_3;
}
}
else
rc = VERR_SEM_DESTROYED;
break;
case THREAD_TIMED_OUT:
Assert(cMillies != RT_INDEFINITE_WAIT);
rc = VERR_TIMEOUT;
break;
case THREAD_INTERRUPTED:
Assert(fInterruptible);
rc = VERR_INTERRUPTED;
break;
case THREAD_RESTART:
Assert(pThis->u32Magic == ~RTSEMMUTEX_MAGIC);
rc = VERR_SEM_DESTROYED;
break;
default:
AssertMsgFailed(("rcWait=%d\n", rcWait));
rc = VERR_GENERAL_FAILURE;
break;
}
/*
* Dereference it and quit the lock.
*/
Assert(pThis->cWaiters > 0);
pThis->cWaiters--;
Assert(pThis->cRefs > 0);
if (RT_UNLIKELY(ASMAtomicDecU32(&pThis->cRefs) == 0))
rtSemMutexDarwinFree(pThis);
else
lck_spin_unlock(pThis->pSpinlock);
return rc;
}
开发者ID:miguelinux,项目名称:vbox,代码行数:99,代码来源:semmutex-r0drv-darwin.cpp
示例8: RTR3DECL
RTR3DECL(char *) RTUriFileNPath(const char *pszUri, uint32_t uFormat, size_t cchMax)
{
AssertPtrReturn(pszUri, NULL);
size_t iPos1;
size_t cbLen = RT_MIN(strlen(pszUri), cchMax);
/* Find the end of the scheme. */
if (!rtUriFindSchemeEnd(pszUri, 0, cbLen, &iPos1))
return NULL; /* no URI */
else
++iPos1; /* Skip ':' */
/* Check that this is a file Uri */
if (RTStrNICmp(pszUri, "file:", iPos1) != 0)
return NULL;
size_t iPos2;
size_t iPos3 = iPos1; /* Skip if no authority is found */
/* Find the start of the authority. */
if (rtUriCheckAuthorityStart(pszUri, iPos1, cbLen - iPos1, &iPos2))
{
/* Find the end of the authority. If not found, then there is no path
* component, cause the authority is the rest of the string. */
if (!rtUriFindAuthorityEnd(pszUri, iPos2, cbLen - iPos2, &iPos3))
return NULL; /* no path! */
}
size_t iPos4;
/* Find the start of the path */
if (rtUriCheckPathStart(pszUri, iPos3, cbLen - iPos3, &iPos4))
{
uint32_t uFIntern = uFormat;
/* Auto is based on the current OS. */
if (uFormat == URI_FILE_FORMAT_AUTO)
#ifdef RT_OS_WINDOWS
uFIntern = URI_FILE_FORMAT_WIN;
#else /* RT_OS_WINDOWS */
uFIntern = URI_FILE_FORMAT_UNIX;
#endif /* !RT_OS_WINDOWS */
if ( uFIntern != URI_FILE_FORMAT_UNIX
&& pszUri[iPos4] == '/')
++iPos4;
/* Search for the end of the scheme. */
size_t iPos5 = cbLen;
rtUriFindPathEnd(pszUri, iPos4, cbLen - iPos4, &iPos5);
if (iPos5 > iPos4) /* Length check */
{
char *pszPath = rtUriPercentDecodeN(&pszUri[iPos4], iPos5 - iPos4);
if (uFIntern == URI_FILE_FORMAT_UNIX)
return RTPathChangeToUnixSlashes(pszPath, true);
else if (uFIntern == URI_FILE_FORMAT_WIN)
return RTPathChangeToDosSlashes(pszPath, true);
else
{
RTStrFree(pszPath);
AssertMsgFailed(("Unknown uri file format %u", uFIntern));
return NULL;
}
}
}
return NULL;
}
开发者ID:sobomax,项目名称:virtualbox_64bit_edd,代码行数:64,代码来源:uri.cpp
示例9: RTR3DECL
RTR3DECL(int) RTPathQueryInfoEx(const char *pszPath, PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAdditionalAttribs, uint32_t fFlags)
{
/*
* Validate input.
*/
AssertPtrReturn(pszPath, VERR_INVALID_POINTER);
AssertReturn(*pszPath, VERR_INVALID_PARAMETER);
AssertPtrReturn(pObjInfo, 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);
/*
* Convert the filename.
*/
char const *pszNativePath;
int rc = rtPathToNative(&pszNativePath, pszPath, NULL);
if (RT_SUCCESS(rc))
{
struct stat Stat;
if (fFlags & RTPATH_F_FOLLOW_LINK)
rc = stat(pszNativePath, &Stat);
else
rc = lstat(pszNativePath, &Stat); /** @todo how doesn't have lstat again? */
if (!rc)
{
rtFsConvertStatToObjInfo(pObjInfo, &Stat, pszPath, 0);
switch (enmAdditionalAttribs)
{
case RTFSOBJATTRADD_NOTHING:
case RTFSOBJATTRADD_UNIX:
Assert(pObjInfo->Attr.enmAdditional == RTFSOBJATTRADD_UNIX);
break;
case RTFSOBJATTRADD_UNIX_OWNER:
rtFsObjInfoAttrSetUnixOwner(pObjInfo, Stat.st_uid);
break;
case RTFSOBJATTRADD_UNIX_GROUP:
rtFsObjInfoAttrSetUnixGroup(pObjInfo, Stat.st_gid);
break;
case RTFSOBJATTRADD_EASIZE:
/** @todo Use SGI extended attribute interface to query EA info. */
pObjInfo->Attr.enmAdditional = RTFSOBJATTRADD_EASIZE;
pObjInfo->Attr.u.EASize.cb = 0;
break;
default:
AssertMsgFailed(("Impossible!\n"));
return VERR_INTERNAL_ERROR;
}
}
else
rc = RTErrConvertFromErrno(errno);
rtPathFreeNative(pszNativePath, pszPath);
}
LogFlow(("RTPathQueryInfoEx(%p:{%s}, pObjInfo=%p, %d): returns %Rrc\n",
pszPath, pszPath, pObjInfo, enmAdditionalAttribs, rc));
return rc;
}
开发者ID:MadHacker217,项目名称:VirtualBox-OSE,代码行数:64,代码来源:path2-posix.cpp
示例10: switch
QString UINativeHotKey::toString(int iKeyCode)
{
QString strKeyName;
#ifdef Q_WS_WIN
/* MapVirtualKey doesn't distinguish between right and left vkeys,
* even under XP, despite that it stated in MSDN. Do it by hands.
* Besides that it can't recognize such virtual keys as
* VK_DIVIDE & VK_PAUSE, this is also known bug. */
int iScan;
switch (iKeyCode)
{
/* Processing special keys... */
case VK_PAUSE: iScan = 0x45 << 16; break;
case VK_RSHIFT: iScan = 0x36 << 16; break;
case VK_RCONTROL: iScan = (0x1D << 16) | (1 << 24); break;
case VK_RMENU: iScan = (0x38 << 16) | (1 << 24); break;
/* Processing extended keys... */
case VK_APPS:
case VK_LWIN:
case VK_RWIN:
case VK_NUMLOCK: iScan = (::MapVirtualKey(iKeyCode, 0) | 256) << 16; break;
default: iScan = ::MapVirtualKey(iKeyCode, 0) << 16;
}
TCHAR *pKeyName = new TCHAR[256];
if (::GetKeyNameText(iScan, pKeyName, 256))
{
strKeyName = QString::fromUtf16(pKeyName);
}
else
{
AssertMsgFailed(("That key have no name!\n"));
strKeyName = UIHostComboEditor::tr("<key_%1>").arg(iKeyCode);
}
delete[] pKeyName;
#endif /* Q_WS_WIN */
#ifdef Q_WS_X11
if (char *pNativeKeyName = ::XKeysymToString((KeySym)iKeyCode))
{
strKeyName = m_keyNames[pNativeKeyName].isEmpty() ?
QString(pNativeKeyName) : m_keyNames[pNativeKeyName];
}
else
{
AssertMsgFailed(("That key have no name!\n"));
strKeyName = UIHostComboEditor::tr("<key_%1>").arg(iKeyCode);
}
#endif /* Q_WS_X11 */
#ifdef Q_WS_MAC
UInt32 modMask = DarwinKeyCodeToDarwinModifierMask(iKeyCode);
switch (modMask)
{
case shiftKey:
case optionKey:
case controlKey:
case cmdKey:
strKeyName = UIHostComboEditor::tr("Left ");
break;
case rightShiftKey:
case rightOptionKey:
case rightControlKey:
case kEventKeyModifierRightCmdKeyMask:
strKeyName = UIHostComboEditor::tr("Right ");
break;
default:
AssertMsgFailedReturn(("modMask=%#x\n", modMask), QString());
}
switch (modMask)
{
case shiftKey:
case rightShiftKey:
strKeyName += QChar(kShiftUnicode);
break;
case optionKey:
case rightOptionKey:
strKeyName += QChar(kOptionUnicode);
break;
case controlKey:
case rightControlKey:
strKeyName += QChar(kControlUnicode);
break;
case cmdKey:
case kEventKeyModifierRightCmdKeyMask:
strKeyName += QChar(kCommandUnicode);
break;
}
#endif /* Q_WS_MAC */
return strKeyName;
}
开发者ID:gvsurenderreddy,项目名称:virtualbox,代码行数:92,代码来源:UIHostComboEditor.cpp
示例11: SUPDECL
//.........这里部分代码省略.........
iCpuSet &= RTCPUSET_MAX_CPUS - 1;
iGipCpu = pGip->aiCpuFromCpuSetIdx[iCpuSet];
}
else if (pGip->fGetGipCpu & SUPGIPGETCPU_IDTR_LIMIT_MASK_MAX_SET_CPUS)
{
/* Storing the IDTR is normally very quick, but we need to loop. */
uint32_t cTries = 0;
for (;;)
{
uint16_t cbLim = ASMGetIdtrLimit();
uTsc = ASMReadTSC();
if (RT_LIKELY(ASMGetIdtrLimit() == cbLim))
{
uint16_t iCpuSet = cbLim - 256 * (ARCH_BITS == 64 ? 16 : 8);
iCpuSet &= RTCPUSET_MAX_CPUS - 1;
iGipCpu = pGip->aiCpuFromCpuSetIdx[iCpuSet];
break;
}
if (cTries >= 16)
{
iGipCpu = UINT16_MAX;
break;
}
cTries++;
}
}
else
{
/* Get APIC ID via the slow CPUID instruction, requires looping. */
uint32_t cTries = 0;
for (;;)
{
uint8_t idApic = ASMGetApicId();
uTsc = ASMReadTSC();
if (RT_LIKELY(ASMGetApicId() == idApic))
{
iGipCpu = pGip->aiCpuFromApicId[idApic];
break;
}
if (cTries >= 16)
{
iGipCpu = UINT16_MAX;
break;
}
cTries++;
}
}
#elif defined(IN_RING0)
/* Ring-0: Use use RTMpCpuId(), no loops. */
RTCCUINTREG uFlags = ASMIntDisableFlags();
int iCpuSet = RTMpCpuIdToSetIndex(RTMpCpuId());
if (RT_LIKELY((unsigned)iCpuSet < RT_ELEMENTS(pGip->aiCpuFromCpuSetIdx)))
iGipCpu = pGip->aiCpuFromCpuSetIdx[iCpuSet];
else
iGipCpu = UINT16_MAX;
uTsc = ASMReadTSC();
ASMSetFlags(uFlags);
# elif defined(IN_RC)
/* Raw-mode context: We can get the host CPU set index via VMCPU, no loops. */
RTCCUINTREG uFlags = ASMIntDisableFlags(); /* Are already disable, but play safe. */
uint32_t iCpuSet = VMMGetCpu(&g_VM)->iHostCpuSet;
if (RT_LIKELY(iCpuSet < RT_ELEMENTS(pGip->aiCpuFromCpuSetIdx)))
iGipCpu = pGip->aiCpuFromCpuSetIdx[iCpuSet];
else
iGipCpu = UINT16_MAX;
uTsc = ASMReadTSC();
ASMSetFlags(uFlags);
#else
# error "IN_RING3, IN_RC or IN_RING0 must be defined!"
#endif
/*
* If the delta is valid, apply it.
*/
if (RT_LIKELY(iGipCpu < pGip->cCpus))
{
int64_t iTscDelta = pGip->aCPUs[iGipCpu].i64TSCDelta;
if (RT_LIKELY(iTscDelta != INT64_MAX))
return uTsc - iTscDelta;
# ifdef IN_RING3
/*
* The delta needs calculating, call supdrv to get the TSC.
*/
int rc = SUPR3ReadTsc(&uTsc, NULL);
if (RT_SUCCESS(rc))
return uTsc;
AssertMsgFailed(("SUPR3ReadTsc -> %Rrc\n", rc));
uTsc = ASMReadTSC();
# endif /* IN_RING3 */
}
/*
* This shouldn't happen, especially not in ring-3 and raw-mode context.
* But if it does, return something that's half useful.
*/
AssertMsgFailed(("iGipCpu=%d (%#x) cCpus=%d fGetGipCpu=%#x\n", iGipCpu, iGipCpu, pGip->cCpus, pGip->fGetGipCpu));
return uTsc;
}
开发者ID:rickysarraf,项目名称:virtualbox,代码行数:101,代码来源:SUPLibAll.cpp
示例12: RTDECL
RTDECL(int) RTErrConvertFromDarwin(int iNativeCode)
{
/*
* 'optimized' success case.
*/
if (iNativeCode == KERN_SUCCESS)
return VINF_SUCCESS;
switch (iNativeCode)
{
/*
* Mach.
*/
case KERN_INVALID_ADDRESS: return VERR_INVALID_POINTER;
//case KERN_PROTECTION_FAILURE:
//case KERN_NO_SPACE:
case KERN_INVALID_ARGUMENT: return VERR_INVALID_PARAMETER;
//case KERN_FAILURE:
//case KERN_RESOURCE_SHORTAGE:
//case KERN_NOT_RECEIVER:
case KERN_NO_ACCESS: return VERR_ACCESS_DENIED;
//case KERN_MEMORY_FAILURE:
//case KERN_MEMORY_ERROR:
//case KERN_ALREADY_IN_SET:
//case KERN_NOT_IN_SET:
//case KERN_NAME_EXISTS:
//case KERN_ABORTED:
//case KERN_INVALID_NAME:
//case KERN_INVALID_TASK:
//case KERN_INVALID_RIGHT:
//case KERN_INVALID_VALUE:
//case KERN_UREFS_OVERFLOW:
//case KERN_INVALID_CAPABILITY:
//case KERN_RIGHT_EXISTS:
//case KERN_INVALID_HOST:
//case KERN_MEMORY_PRESENT:
//case KERN_MEMORY_DATA_MOVED:
//case KERN_MEMORY_RESTART_COPY:
//case KERN_INVALID_PROCESSOR_SET:
//case KERN_POLICY_LIMIT:
//case KERN_INVALID_POLICY:
//case KERN_INVALID_OBJECT:
//case KERN_ALREADY_WAITING:
//case KERN_DEFAULT_SET:
//case KERN_EXCEPTION_PROTECTED:
//case KERN_INVALID_LEDGER:
//case KERN_INVALID_MEMORY_CONTROL:
//case KERN_INVALID_SECURITY:
//case KERN_NOT_DEPRESSED:
//case KERN_TERMINATED:
//case KERN_LOCK_SET_DESTROYED:
//case KERN_LOCK_UNSTABLE:
case KERN_LOCK_OWNED: return VERR_SEM_BUSY;
//case KERN_LOCK_OWNED_SELF:
case KERN_SEMAPHORE_DESTROYED: return VERR_SEM_DESTROYED;
//case KERN_RPC_SERVER_TERMINATED:
//case KERN_RPC_TERMINATE_ORPHAN:
//case KERN_RPC_CONTINUE_ORPHAN:
case KERN_NOT_SUPPORTED: return VERR_NOT_SUPPORTED;
//case KERN_NODE_DOWN:
//case KERN_NOT_WAITING:
case KERN_OPERATION_TIMED_OUT: return VERR_TIMEOUT;
/*
* I/O Kit.
*/
case kIOReturnNoDevice: return VERR_IO_BAD_UNIT;
case kIOReturnUnsupported: return VERR_NOT_SUPPORTED;
case kIOReturnInternalError: return VERR_INTERNAL_ERROR;
case kIOReturnNoResources: return VERR_OUT_OF_RESOURCES;
case kIOReturnBadArgument: return VERR_INVALID_PARAMETER;
case kIOReturnCannotWire: return VERR_LOCK_FAILED;
#ifdef IN_RING3
/*
* CoreFoundation COM (may overlap with I/O Kit and Mach).
*/
default:
if ( (unsigned)iNativeCode >= 0x80000000U
&& (unsigned)iNativeCode >= 0x8000FFFFU)
return RTErrConvertFromDarwinCOM(iNativeCode);
break;
#endif /* IN_RING3 */
}
/* unknown error. */
AssertMsgFailed(("Unhandled error %#x\n", iNativeCode));
return VERR_UNRESOLVED_ERROR;
}
开发者ID:virendramishra,项目名称:VirtualBox4.1.18,代码行数:90,代码来源:RTErrConvertFromDarwin.cpp
示例13: DECLINLINE
/**
* Allocates a page from the page pool.
*
* @returns Pointer to allocated page(s).
* @returns NULL on failure.
* @param pPool Pointer to the page pool.
* @thread The Emulation Thread.
*/
DECLINLINE(void *) mmR3PagePoolAlloc(PMMPAGEPOOL pPool)
{
VM_ASSERT_EMT(pPool->pVM);
STAM_COUNTER_INC(&pPool->cAllocCalls);
/*
* Walk free list.
*/
if (pPool->pHeadFree)
{
PMMPAGESUBPOOL pSub = pPool->pHeadFree;
/* decrement free count and unlink if no more free entries. */
if (!--pSub->cPagesFree)
pPool->pHeadFree = pSub->pNextFree;
#ifdef VBOX_WITH_STATISTICS
pPool->cFreePages--;
#endif
/* find free spot in bitmap. */
#ifdef USE_INLINE_ASM_BIT_OPS
const int iPage = ASMBitFirstClear(pSub->auBitmap, pSub->cPages);
if (iPage >= 0)
{
Assert(!ASMBitTest(pSub->auBitmap, iPage));
ASMBitSet(pSub->auBitmap, iPage);
return (uint8_t *)pSub->pvPages + PAGE_SIZE * iPage;
}
#else
unsigned *pu = &pSub->auBitmap[0];
unsigned *puEnd = &pSub->auBitmap[pSub->cPages / (sizeof(pSub->auBitmap) * 8)];
while (pu < puEnd)
{
unsigned u;
if ((u = *pu) != ~0U)
{
unsigned iBit = 0;
unsigned uMask = 1;
while (iBit < sizeof(pSub->auBitmap[0]) * 8)
{
if (!(u & uMask))
{
*pu |= uMask;
return (uint8_t *)pSub->pvPages
+ PAGE_SIZE * (iBit + ((uint8_t *)pu - (uint8_t *)&pSub->auBitmap[0]) * 8);
}
iBit++;
uMask <<= 1;
}
STAM_COUNTER_INC(&pPool->cErrors);
AssertMsgFailed(("how odd, expected to find a free bit in %#x, but didn't\n", u));
}
/* next */
pu++;
}
#endif
STAM_COUNTER_INC(&pPool->cErrors);
#ifdef VBOX_WITH_STATISTICS
pPool->cFreePages++;
#endif
AssertMsgFailed(("how strange, expected to find a free bit in %p, but didn't (%d pages supposed to be free!)\n", pSub, pSub->cPagesFree + 1));
}
/*
* Allocate new subpool.
*/
unsigned cPages = !pPool->fLow ? 128 : 32;
PMMPAGESUBPOOL pSub;
int rc = MMHyperAlloc(pPool->pVM,
RT_OFFSETOF(MMPAGESUBPOOL, auBitmap[cPages / (sizeof(pSub->auBitmap[0]) * 8)])
+ (sizeof(SUPPAGE) + sizeof(MMPPLOOKUPHCPHYS)) * cPages
+ sizeof(MMPPLOOKUPHCPTR),
0,
MM_TAG_MM_PAGE,
(void **)&pSub);
if (RT_FAILURE(rc))
return NULL;
PSUPPAGE paPhysPages = (PSUPPAGE)&pSub->auBitmap[cPages / (sizeof(pSub->auBitmap[0]) * 8)];
Assert((uintptr_t)paPhysPages >= (uintptr_t)&pSub->auBitmap[1]);
if (!pPool->fLow)
{
rc = SUPR3PageAllocEx(cPages,
0 /* fFlags */,
&pSub->pvPages,
NULL,
paPhysPages);
if (RT_FAILURE(rc))
rc = VMSetError(pPool->pVM, rc, RT_SRC_POS,
N_("Failed to lock host %zd bytes of memory (out of memory)"), (size_t)cPages << PAGE_SHIFT);
}
else
rc = SUPR3LowAlloc(cPages, &pSub->pvPages, NULL, paPhysPages);
//.........这里部分代码省略.........
开发者ID:jeppeter,项目名称:vbox,代码行数:101,代码来源:MMPagePool.cpp
示例14: drvHostALSAAudioALSAToFmt
static int drvHostALSAAudioALSAToFmt(snd_pcm_format_t fmt,
PDMAUDIOFMT *pFmt, PDMAUDIOENDIANNESS *pEndianness)
{
AssertPtrReturn(pFmt, VERR_INVALID_POINTER);
/* pEndianness is optional. */
switch (fmt)
{
case SND_PCM_FORMAT_S8:
*pFmt = AUD_FMT_S8;
if (pEndianness)
*pEndianness = PDMAUDIOENDIANNESS_LITTLE;
break;
case SND_PCM_FORMAT_U8:
*pFmt = AUD_FMT_U8;
if (pEndianness)
*pEndianness = PDMAUDIOENDIANNESS_LITTLE;
break;
case SND_PCM_FORMAT_S16_LE:
*pFmt = AUD_FMT_S16;
if (pEndianness)
*pEndianness = PDMAUDIOENDIANNESS_LITTLE;
break;
case SND_PCM_FORMAT_U16_LE:
*pFmt = AUD_FMT_U16;
if (pEndianness)
*pEndianness = PDMAUDIOENDIANNESS_LITTLE;
break;
case SND_PCM_FORMAT_S16_BE:
*pFmt = AUD_FMT_S16;
if (pEndianness)
*pEndianness = PDMAUDIOENDIANNESS_BIG;
break;
case SND_PCM_FORMAT_U16_BE:
*pFmt = AUD_FMT_U16;
if (pEndianness)
*pEndianness = PDMAUDIOENDIANNESS_BIG;
break;
case SND_PCM_FORMAT_S32_LE:
*pFmt = AUD_FMT_S32;
if (pEndianness)
*pEndianness = PDMAUDIOENDIANNESS_LITTLE;
break;
case SND_PCM_FORMAT_U32_LE:
*pFmt = AUD_FMT_U32;
if (pEndianness)
*pEndianness = PDMAUDIOENDIANNESS_LITTLE;
break;
case SND_PCM_FORMAT_S32_BE:
*pFmt = AUD_FMT_S32;
if (pEndianness)
*pEndianness = PDMAUDIOENDIANNESS_BIG;
break;
case SND_PCM_FORMAT_U32_BE:
*pFmt = AUD_FMT_U32;
if (pEndianness)
*pEndianness = PDMAUDIOENDIANNESS_BIG;
break;
default:
AssertMsgFailed(("Format %ld not supported\n", fmt));
return VERR_NOT_SUPPORTED;
}
return VINF_SUCCESS;
}
开发者ID:stefano-garzarella,项目名称:virtualbox-org-svn-vbox-trunk,代码行数:75,代码来源:DrvHostALSAAudio.cpp
示例15: DECLCALLBACK
/**
* @interface_method_impl{PDMDRVREG,pfnConstruct}
*/
DECLCALLBACK(int) VMMDev::drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle, uint32_t fFlags)
{
PDMDRV_CHECK_VERSIONS_RETURN(pDrvIns);
PDRVMAINVMMDEV pThis = PDMINS_2_DATA(pDrvIns, PDRVMAINVMMDEV);
LogFlow(("Keyboard::drvConstruct: iInstance=%d\n&
|
请发表评论