本文整理汇总了C++中RTSpinlockRelease函数的典型用法代码示例。如果您正苦于以下问题:C++ RTSpinlockRelease函数的具体用法?C++ RTSpinlockRelease怎么用?C++ RTSpinlockRelease使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RTSpinlockRelease函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: DECLCALLBACK
/**
* @copydoc INTNETTRUNKIFPORT::pfnXmit
*/
static DECLCALLBACK(int) vboxNetAdpPortXmit(PINTNETTRUNKIFPORT pIfPort, PINTNETSG pSG, uint32_t fDst)
{
PVBOXNETADP pThis = IFPORT_2_VBOXNETADP(pIfPort);
int rc = VINF_SUCCESS;
/*
* Input validation.
*/
AssertPtr(pThis);
AssertPtr(pSG);
Assert(pThis->MyPort.u32Version == INTNETTRUNKIFPORT_VERSION);
Log(("vboxNetAdpPortXmit: outgoing packet (len=%d)\n", pSG->cbTotal));
/*
* Do a retain/busy, invoke the OS specific code.
*/
RTSpinlockAcquire(pThis->hSpinlock);
if (vboxNetAdpGetState(pThis) != kVBoxNetAdpState_Active)
{
RTSpinlockRelease(pThis->hSpinlock);
Log(("vboxNetAdpReceive: Dropping incoming packet for inactive interface %s.\n",
pThis->szName));
return VERR_INVALID_STATE;
}
vboxNetAdpRetain(pThis);
vboxNetAdpBusy(pThis);
RTSpinlockRelease(pThis->hSpinlock);
rc = vboxNetAdpPortOsXmit(pThis, pSG, fDst);
vboxNetAdpIdle(pThis);
vboxNetAdpRelease(pThis);
return rc;
}
开发者ID:mcenirm,项目名称:vbox,代码行数:38,代码来源:VBoxNetAdp.c
示例2: RTDECL
RTDECL(int) RTTimerStart(PRTTIMER pTimer, uint64_t u64First)
{
if (!rtTimerIsValid(pTimer))
return VERR_INVALID_HANDLE;
if (!pTimer->fSuspended)
return VERR_TIMER_ACTIVE;
/*
* Calc when it should start firing and give the thread a kick so it get going.
*/
u64First += RTTimeNanoTS();
RTSpinlockAcquire(g_Spinlock);
g_u32ChangeNo++;
if (!g_cActiveTimers)
{
int rc = rtTimerOs2Arm();
if (RT_FAILURE(rc))
{
RTSpinlockRelease(g_Spinlock);
return rc;
}
}
g_cActiveTimers++;
pTimer->fSuspended = false;
pTimer->fDone = true; /* next tick, not current! */
pTimer->iTick = 0;
pTimer->u64StartTS = u64First;
pTimer->u64NextTS = u64First;
RTSpinlockRelease(g_Spinlock);
return VINF_SUCCESS;
}
开发者ID:miguelinux,项目名称:vbox,代码行数:33,代码来源:timer-r0drv-os2.cpp
示例3: DECLINLINE
/**
* Sets the enmState member atomically after first acquiring the spinlock.
*
* Used for all updates.
*
* @param pThis The instance.
* @param enmNewState The new value.
*/
DECLINLINE(void) vboxNetAdpSetStateWithLock(PVBOXNETADP pThis, VBOXNETADPSTATE enmNewState)
{
Log(("vboxNetAdpSetStateWithLock: pThis=%p, state=%d.\n", pThis, enmNewState));
RTSpinlockAcquire(pThis->hSpinlock);
vboxNetAdpSetState(pThis, enmNewState);
RTSpinlockRelease(pThis->hSpinlock);
}
开发者ID:mcenirm,项目名称:vbox,代码行数:15,代码来源:VBoxNetAdp.c
示例4: DECLASM
DECLASM(int) VBoxDrvIOCtlFast(uint16_t sfn, uint8_t iFunction)
{
/*
* Find the session.
*/
const RTPROCESS Process = RTProcSelf();
const unsigned iHash = SESSION_HASH(sfn);
PSUPDRVSESSION pSession;
RTSpinlockAcquire(g_Spinlock);
pSession = g_apSessionHashTab[iHash];
if (pSession && pSession->Process != Process)
{
do pSession = pSession->pNextHash;
while ( pSession
&& ( pSession->sfn != sfn
|| pSession->Process != Process));
if (RT_LIKELY(pSession))
supdrvSessionRetain(pSession);
}
RTSpinlockRelease(g_Spinlock);
if (RT_UNLIKELY(!pSession))
{
OSDBGPRINT(("VBoxDrvIoctl: WHUT?!? pSession == NULL! This must be a mistake... pid=%d\n", (int)Process));
return VERR_INVALID_PARAMETER;
}
/*
* Dispatch the fast IOCtl.
*/
supdrvIOCtlFast(iFunction, 0, &g_DevExt, pSession);
supdrvSessionRelease(pSession);
return 0;
}
开发者ID:sobomax,项目名称:virtualbox_64bit_edd,代码行数:35,代码来源:SUPDrv-os2.cpp
示例5: DECLHIDDEN
/**
* OS specific free function.
*/
DECLHIDDEN(void) rtR0MemFree(PRTMEMHDR pHdr)
{
IPRT_LINUX_SAVE_EFL_AC();
pHdr->u32Magic += 1;
if (pHdr->fFlags & RTMEMHDR_FLAG_KMALLOC)
kfree(pHdr);
#ifdef RTMEMALLOC_EXEC_HEAP
else if (pHdr->fFlags & RTMEMHDR_FLAG_EXEC_HEAP)
{
RTSpinlockAcquire(g_HeapExecSpinlock);
RTHeapSimpleFree(g_HeapExec, pHdr);
RTSpinlockRelease(g_HeapExecSpinlock);
}
#endif
#ifdef RTMEMALLOC_EXEC_VM_AREA
else if (pHdr->fFlags & RTMEMHDR_FLAG_EXEC_VM_AREA)
{
PRTMEMLNXHDREX pHdrEx = RT_FROM_MEMBER(pHdr, RTMEMLNXHDREX, Hdr);
size_t iPage = pHdrEx->pVmArea->nr_pages;
struct page **papPages = pHdrEx->pVmArea->pages;
void *pvMapping = pHdrEx->pVmArea->addr;
vunmap(pvMapping);
while (iPage-- > 0)
__free_page(papPages[iPage]);
kfree(papPages);
}
#endif
else
vfree(pHdr);
IPRT_LINUX_RESTORE_EFL_AC();
}
开发者ID:ailispaw,项目名称:vboxguest,代码行数:38,代码来源:alloc-r0drv-linux.c
示例6: VBoxGuestNativeISRMousePollEvent
void VBoxGuestNativeISRMousePollEvent(PVBOXGUESTDEVEXT pDevExt)
{
LogFlow((MODULE_NAME "::NativeISRMousePollEvent:\n"));
status_t err = B_OK;
//dprintf(MODULE_NAME ": isr mouse\n");
/*
* Wake up poll waiters.
*/
//selwakeup(&g_SelInfo);
//XXX:notify_select_event();
RTSpinlockAcquire(g_Spinlock);
if (sState.selectSync)
{
//dprintf(MODULE_NAME ": isr mouse: notify\n");
notify_select_event(sState.selectSync, sState.selectEvent);
sState.selectEvent = (uint8_t)0;
sState.selectRef = (uint32_t)0;
sState.selectSync = NULL;
}
else
err = B_ERROR;
RTSpinlockRelease(g_Spinlock);
}
开发者ID:tigranbs,项目名称:virtualbox,代码行数:27,代码来源:VBoxGuest-haiku.c
示例7: VbgdDarwinIOCtl
/**
* Device I/O Control entry point.
*
* @returns Darwin for slow IOCtls and VBox status code for the fast ones.
* @param Dev The device number (major+minor).
* @param iCmd The IOCtl command.
* @param pData Pointer to the data (if any it's a VBOXGUESTIOCTLDATA (kernel copy)).
* @param fFlags Flag saying we're a character device (like we didn't know already).
* @param pProcess The process issuing this request.
*/
static int VbgdDarwinIOCtl(dev_t Dev, u_long iCmd, caddr_t pData, int fFlags, struct proc *pProcess)
{
//const bool fUnrestricted = minor(Dev) == 0;
const RTPROCESS Process = proc_pid(pProcess);
const unsigned iHash = SESSION_HASH(Process);
PVBOXGUESTSESSION pSession;
/*
* Find the session.
*/
RTSpinlockAcquire(g_Spinlock);
pSession = g_apSessionHashTab[iHash];
while (pSession && pSession->Process != Process && (/*later: pSession->fUnrestricted != fUnrestricted ||*/ !pSession->fOpened))
pSession = pSession->pNextHash;
RTSpinlockRelease(g_Spinlock);
if (!pSession)
{
Log(("VBoxDrvDarwinIOCtl: WHAT?!? pSession == NULL! This must be a mistake... pid=%d iCmd=%#lx\n",
(int)Process, iCmd));
return EINVAL;
}
/*
* No high speed IOCtls here yet.
*/
return VbgdDarwinIOCtlSlow(pSession, iCmd, pData, pProcess);
}
开发者ID:tigranbs,项目名称:virtualbox,代码行数:38,代码来源:VBoxGuest-darwin.cpp
示例8: vboxNetAdpCreate
int vboxNetAdpCreate(PINTNETTRUNKFACTORY pIfFactory, PVBOXNETADP *ppNew)
{
PVBOXNETADPGLOBALS pGlobals = (PVBOXNETADPGLOBALS)((uint8_t *)pIfFactory - RT_OFFSETOF(VBOXNETADPGLOBALS, TrunkFactory));
unsigned i;
int rc;
for (i = 0; i < RT_ELEMENTS(pGlobals->aAdapters); i++)
{
PVBOXNETADP pThis = &pGlobals->aAdapters[i];
if (vboxNetAdpCheckAndSetState(pThis, kVBoxNetAdpState_Invalid, kVBoxNetAdpState_Transitional))
{
/* Found an empty slot -- use it. */
uint32_t cRefs = ASMAtomicIncU32(&pThis->cRefs);
Assert(cRefs == 1);
RTMAC Mac;
vboxNetAdpComposeMACAddress(pThis, &Mac);
rc = vboxNetAdpOsCreate(pThis, &Mac);
*ppNew = pThis;
RTSpinlockAcquire(pThis->hSpinlock);
vboxNetAdpSetState(pThis, kVBoxNetAdpState_Available);
RTSpinlockRelease(pThis->hSpinlock);
return rc;
}
}
/* All slots in adapter array are busy. */
return VERR_OUT_OF_RESOURCES;
}
开发者ID:mcenirm,项目名称:vbox,代码行数:30,代码来源:VBoxNetAdp.c
示例9: DECLHIDDEN
DECLHIDDEN(void) rtR0MpNotificationTerm(void)
{
PRTMPNOTIFYREG pHead;
RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
RTSPINLOCK hSpinlock = g_hRTMpNotifySpinLock;
AssertReturnVoid(hSpinlock != NIL_RTSPINLOCK);
rtR0MpNotificationNativeTerm();
/* pick up the list and the spinlock. */
RTSpinlockAcquire(hSpinlock, &Tmp);
ASMAtomicWriteHandle(&g_hRTMpNotifySpinLock, NIL_RTSPINLOCK);
pHead = g_pRTMpCallbackHead;
g_pRTMpCallbackHead = NULL;
ASMAtomicIncU32(&g_iRTMpGeneration);
RTSpinlockRelease(hSpinlock, &Tmp);
/* free the list. */
while (pHead)
{
PRTMPNOTIFYREG pFree = pHead;
pHead = pHead->pNext;
pFree->pNext = NULL;
pFree->pfnCallback = NULL;
RTMemFree(pFree);
}
RTSpinlockDestroy(hSpinlock);
}
开发者ID:virendramishra,项目名称:VirtualBox4.1.18,代码行数:30,代码来源:mpnotification-r0drv.c
示例10: vgdrvHaikuSelect
/**
* Driver select hook.
*
* @param cookie The session.
* @param event The event.
* @param ref ???
* @param sync ???
*
* @return Haiku status code.
*/
static status_t vgdrvHaikuSelect(void *cookie, uint8 event, uint32 ref, selectsync *sync)
{
PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)cookie;
status_t err = B_OK;
switch (event)
{
case B_SELECT_READ:
break;
default:
return EINVAL;
}
RTSpinlockAcquire(g_DevExt.SessionSpinlock);
uint32_t u32CurSeq = ASMAtomicUoReadU32(&g_DevExt.u32MousePosChangedSeq);
if (pSession->u32MousePosChangedSeq != u32CurSeq)
{
pSession->u32MousePosChangedSeq = u32CurSeq;
notify_select_event(sync, event);
}
else if (sState.selectSync == NULL)
{
sState.selectEvent = (uint8_t)event;
sState.selectRef = (uint32_t)ref;
sState.selectSync = (void *)sync;
}
else
err = B_WOULD_BLOCK;
RTSpinlockRelease(g_DevExt.SessionSpinlock);
return err;
}
开发者ID:svn2github,项目名称:virtualbox,代码行数:44,代码来源:VBoxDev-haiku.c
示例11: DECLINLINE
DECLINLINE(void) vboxPciDevUnlock(PVBOXRAWPCIINS pThis)
{
#ifdef VBOX_WITH_SHARED_PCI_INTERRUPTS
RTSpinlockRelease(pThis->hSpinlock);
#else
RTSemFastMutexRelease(pThis->hFastMtx);
#endif
}
开发者ID:Klanly,项目名称:virtualbox-org-svn-vbox-trunk,代码行数:8,代码来源:VBoxPci.c
示例12: vboxNetFltOsInitInstance
int vboxNetFltOsInitInstance(PVBOXNETFLTINS pThis, void *pvContext)
{
char nam[NG_NODESIZ];
struct ifnet *ifp;
node_p node;
VBOXCURVNET_SET_FROM_UCRED();
NOREF(pvContext);
ifp = ifunit(pThis->szName);
if (ifp == NULL)
return VERR_INTNET_FLT_IF_NOT_FOUND;
/* Create a new netgraph node for this instance */
if (ng_make_node_common(&ng_vboxnetflt_typestruct, &node) != 0)
return VERR_INTERNAL_ERROR;
RTSpinlockAcquire(pThis->hSpinlock);
ASMAtomicUoWritePtr(&pThis->u.s.ifp, ifp);
pThis->u.s.node = node;
bcopy(IF_LLADDR(ifp), &pThis->u.s.MacAddr, ETHER_ADDR_LEN);
ASMAtomicUoWriteBool(&pThis->fDisconnectedFromHost, false);
/* Initialize deferred input queue */
bzero(&pThis->u.s.inq, sizeof(struct ifqueue));
mtx_init(&pThis->u.s.inq.ifq_mtx, "vboxnetflt inq", NULL, MTX_SPIN);
TASK_INIT(&pThis->u.s.tskin, 0, vboxNetFltFreeBSDinput, pThis);
/* Initialize deferred output queue */
bzero(&pThis->u.s.outq, sizeof(struct ifqueue));
mtx_init(&pThis->u.s.outq.ifq_mtx, "vboxnetflt outq", NULL, MTX_SPIN);
TASK_INIT(&pThis->u.s.tskout, 0, vboxNetFltFreeBSDoutput, pThis);
RTSpinlockRelease(pThis->hSpinlock);
NG_NODE_SET_PRIVATE(node, pThis);
/* Attempt to name it vboxnetflt_<ifname> */
snprintf(nam, NG_NODESIZ, "vboxnetflt_%s", pThis->szName);
ng_name_node(node, nam);
/* Report MAC address, promiscuous mode and GSO capabilities. */
/** @todo keep these reports up to date, either by polling for changes or
* intercept some control flow if possible. */
if (vboxNetFltTryRetainBusyNotDisconnected(pThis))
{
Assert(pThis->pSwitchPort);
pThis->pSwitchPort->pfnReportMacAddress(pThis->pSwitchPort, &pThis->u.s.MacAddr);
pThis->pSwitchPort->pfnReportPromiscuousMode(pThis->pSwitchPort, vboxNetFltFreeBsdIsPromiscuous(pThis));
pThis->pSwitchPort->pfnReportGsoCapabilities(pThis->pSwitchPort, 0, INTNETTRUNKDIR_WIRE | INTNETTRUNKDIR_HOST);
pThis->pSwitchPort->pfnReportNoPreemptDsts(pThis->pSwitchPort, 0 /* none */);
vboxNetFltRelease(pThis, true /*fBusy*/);
}
VBOXCURVNET_RESTORE();
return VINF_SUCCESS;
}
开发者ID:sobomax,项目名称:virtualbox_64bit_edd,代码行数:57,代码来源:VBoxNetFlt-freebsd.c
示例13: vboxNetAdpFind
/**
* Finds a instance by its name, the caller does the locking.
*
* @returns Pointer to the instance by the given name. NULL if not found.
* @param pGlobals The globals.
* @param pszName The name of the instance.
*/
static PVBOXNETADP vboxNetAdpFind(PVBOXNETADPGLOBALS pGlobals, const char *pszName)
{
unsigned i;
for (i = 0; i < RT_ELEMENTS(pGlobals->aAdapters); i++)
{
PVBOXNETADP pThis = &pGlobals->aAdapters[i];
RTSpinlockAcquire(pThis->hSpinlock);
if ( vboxNetAdpGetState(pThis)
&& !strcmp(pThis->szName, pszName))
{
RTSpinlockRelease(pThis->hSpinlock);
return pThis;
}
RTSpinlockRelease(pThis->hSpinlock);
}
return NULL;
}
开发者ID:mcenirm,项目名称:vbox,代码行数:25,代码来源:VBoxNetAdp.c
示例14: VBoxDrvSolarisIOCtl
/**
* Driver ioctl, an alternate entry point for this character driver.
*
* @param Dev Device number
* @param Cmd Operation identifier
* @param pArg Arguments from user to driver
* @param Mode Information bitfield (read/write, address space etc.)
* @param pCred User credentials
* @param pVal Return value for calling process.
*
* @return corresponding solaris error code.
*/
static int VBoxDrvSolarisIOCtl(dev_t Dev, int Cmd, intptr_t pArgs, int Mode, cred_t *pCred, int *pVal)
{
#ifndef USE_SESSION_HASH
/*
* Get the session from the soft state item.
*/
vbox_devstate_t *pState = ddi_get_soft_state(g_pVBoxDrvSolarisState, getminor(Dev));
if (!pState)
{
LogRel(("VBoxDrvSolarisIOCtl: no state data for %#x (%d)\n", Dev, getminor(Dev)));
return EINVAL;
}
PSUPDRVSESSION pSession = pState->pSession;
if (!pSession)
{
LogRel(("VBoxDrvSolarisIOCtl: no session in state data for %#x (%d)\n", Dev, getminor(Dev)));
return DDI_SUCCESS;
}
#else
const RTPROCESS Process = RTProcSelf();
const unsigned iHash = SESSION_HASH(Process);
PSUPDRVSESSION pSession;
const bool fUnrestricted = getminor(Dev) == 0;
/*
* Find the session.
*/
RTSpinlockAcquire(g_Spinlock);
pSession = g_apSessionHashTab[iHash];
while (pSession && pSession->Process != Process && pSession->fUnrestricted == fUnrestricted);
pSession = pSession->pNextHash;
RTSpinlockRelease(g_Spinlock);
if (!pSession)
{
LogRel(("VBoxSupDrvIOCtl: WHAT?!? pSession == NULL! This must be a mistake... pid=%d iCmd=%#x Dev=%#x\n",
(int)Process, Cmd, (int)Dev));
return EINVAL;
}
#endif
/*
* Deal with the two high-speed IOCtl that takes it's arguments from
* the session and iCmd, and only returns a VBox status code.
*/
if ( ( Cmd == SUP_IOCTL_FAST_DO_RAW_RUN
|| Cmd == SUP_IOCTL_FAST_DO_HM_RUN
|| Cmd == SUP_IOCTL_FAST_DO_NOP)
&& pSession->fUnrestricted)
{
*pVal = supdrvIOCtlFast(Cmd, pArgs, &g_DevExt, pSession);
return 0;
}
return VBoxDrvSolarisIOCtlSlow(pSession, Cmd, Mode, pArgs);
}
开发者ID:zBMNForks,项目名称:virtualbox-org-svn-vbox-trunk,代码行数:68,代码来源:SUPDrv-solaris.c
示例15: RTDECL
RTDECL(void) RTSpinlockReleaseNoInts(RTSPINLOCK Spinlock)
{
#if 1
if (RT_UNLIKELY(!(Spinlock->fFlags & RTSPINLOCK_FLAGS_INTERRUPT_SAFE)))
RTAssertMsg2("RTSpinlockReleaseNoInts: %p (magic=%#x)\n", Spinlock, Spinlock->u32Magic);
#else
AssertRelease(Spinlock->fFlags & RTSPINLOCK_FLAGS_INTERRUPT_SAFE);
#endif
RTSpinlockRelease(Spinlock);
}
开发者ID:greg100795,项目名称:virtualbox,代码行数:10,代码来源:spinlock-r0drv-linux.c
示例16: VbgdDarwinOpen
/**
* Device open. Called on open /dev/vboxguest and (later) /dev/vboxguestu.
*
* @param Dev The device number.
* @param fFlags ???.
* @param fDevType ???.
* @param pProcess The process issuing this request.
*/
static int VbgdDarwinOpen(dev_t Dev, int fFlags, int fDevType, struct proc *pProcess)
{
/*
* Only two minor devices numbers are allowed.
*/
if (minor(Dev) != 0 && minor(Dev) != 1)
return EACCES;
/*
* Find the session created by org_virtualbox_VBoxGuestClient, fail
* if no such session, and mark it as opened. We set the uid & gid
* here too, since that is more straight forward at this point.
*/
//const bool fUnrestricted = minor(Dev) == 0;
int rc = VINF_SUCCESS;
PVBOXGUESTSESSION pSession = NULL;
kauth_cred_t pCred = kauth_cred_proc_ref(pProcess);
if (pCred)
{
RTPROCESS Process = RTProcSelf();
unsigned iHash = SESSION_HASH(Process);
RTSpinlockAcquire(g_Spinlock);
pSession = g_apSessionHashTab[iHash];
while (pSession && pSession->Process != Process)
pSession = pSession->pNextHash;
if (pSession)
{
if (!pSession->fOpened)
{
pSession->fOpened = true;
/*pSession->fUnrestricted = fUnrestricted; - later */
}
else
rc = VERR_ALREADY_LOADED;
}
else
rc = VERR_GENERAL_FAILURE;
RTSpinlockRelease(g_Spinlock);
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
kauth_cred_unref(&pCred);
#else /* 10.4 */
/* The 10.4u SDK headers and 10.4.11 kernel source have inconsistent definitions
of kauth_cred_unref(), so use the other (now deprecated) API for releasing it. */
kauth_cred_rele(pCred);
#endif /* 10.4 */
}
else
rc = VERR_INVALID_PARAMETER;
Log(("VbgdDarwinOpen: g_DevExt=%p pSession=%p rc=%d pid=%d\n", &g_DevExt, pSession, rc, proc_pid(pProcess)));
return VbgdDarwinErr2DarwinErr(rc);
}
开发者ID:tigranbs,项目名称:virtualbox,代码行数:62,代码来源:VBoxGuest-darwin.cpp
示例17: vboxNetAdpDestroy
int vboxNetAdpDestroy(PVBOXNETADP pThis)
{
int rc = VINF_SUCCESS;
RTSpinlockAcquire(pThis->hSpinlock);
if (vboxNetAdpGetState(pThis) != kVBoxNetAdpState_Available || pThis->cBusy)
{
RTSpinlockRelease(pThis->hSpinlock);
return VERR_INTNET_FLT_IF_BUSY;
}
vboxNetAdpSetState(pThis, kVBoxNetAdpState_Transitional);
RTSpinlockRelease(pThis->hSpinlock);
vboxNetAdpRelease(pThis);
vboxNetAdpOsDestroy(pThis);
RTSpinlockAcquire(pThis->hSpinlock);
vboxNetAdpSetState(pThis, kVBoxNetAdpState_Invalid);
RTSpinlockRelease(pThis->hSpinlock);
return rc;
}
开发者ID:mcenirm,项目名称:vbox,代码行数:22,代码来源:VBoxNetAdp.c
示例18: RTDECL
RTDECL(int) RTPowerNotificationDeregister(PFNRTPOWERNOTIFICATION pfnCallback, void *pvUser)
{
PRTPOWERNOTIFYREG pPrev;
PRTPOWERNOTIFYREG pCur;
RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
/*
* Validation.
*/
AssertPtrReturn(pfnCallback, VERR_INVALID_POINTER);
AssertReturn(g_hRTPowerNotifySpinLock != NIL_RTSPINLOCK, VERR_WRONG_ORDER);
RT_ASSERT_INTS_ON();
/*
* Find and unlink the record from the list.
*/
RTSpinlockAcquire(g_hRTPowerNotifySpinLock, &Tmp);
pPrev = NULL;
for (pCur = g_pRTPowerCallbackHead; pCur; pCur = pCur->pNext)
{
if ( pCur->pvUser == pvUser
&& pCur->pfnCallback == pfnCallback)
break;
pPrev = pCur;
}
if (pCur)
{
if (pPrev)
pPrev->pNext = pCur->pNext;
else
g_pRTPowerCallbackHead = pCur->pNext;
ASMAtomicIncU32(&g_iRTPowerGeneration);
}
RTSpinlockRelease(g_hRTPowerNotifySpinLock, &Tmp);
if (!pCur)
return VERR_NOT_FOUND;
/*
* Invalidate and free the record.
*/
pCur->pNext = NULL;
pCur->pfnCallback = NULL;
RTMemFree(pCur);
return VINF_SUCCESS;
}
开发者ID:LastRitter,项目名称:vbox-haiku,代码行数:47,代码来源:powernotification-r0drv.c
示例19: DECLHIDDEN
/**
* Checks if receive is possible and increases busy and ref counters if so.
*
* @param pThis The instance.
*/
DECLHIDDEN(bool) vboxNetAdpPrepareToReceive(PVBOXNETADP pThis)
{
bool fCanReceive = false;
/*
* Input validation.
*/
AssertPtr(pThis);
Assert(pThis->MyPort.u32Version == INTNETTRUNKIFPORT_VERSION);
RTSpinlockAcquire(pThis->hSpinlock);
if (vboxNetAdpGetState(pThis) == kVBoxNetAdpState_Active)
{
fCanReceive = true;
vboxNetAdpRetain(pThis);
vboxNetAdpBusy(pThis);
}
RTSpinlockRelease(pThis->hSpinlock);
Log(("vboxNetAdpPrepareToReceive: fCanReceive=%d.\n", fCanReceive));
return fCanReceive;
}
开发者ID:mcenirm,项目名称:vbox,代码行数:25,代码来源:VBoxNetAdp.c
示例20: vgdrvHaikuDeselect
/**
* Driver deselect hook.
* @param cookie The session.
* @param event The event.
* @param sync ???
*
* @return Haiku status code.
*/
static status_t vgdrvHaikuDeselect(void *cookie, uint8 event, selectsync *sync)
{
PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)cookie;
status_t err = B_OK;
//dprintf(DRIVER_NAME "deselect(,%d,%p)\n", event, sync);
RTSpinlockAcquire(g_DevExt.SessionSpinlock);
if (sState.selectSync == sync)
{
//dprintf(DRIVER_NAME "deselect: dropping: %p %x\n", sState.selectSync, sState.selectEvent);
sState.selectEvent = (uint8_t)0;
sState.selectRef = (uint32_t)0;
sState.selectSync = NULL;
}
else
err = B_OK;
RTSpinlockRelease(g_DevExt.SessionSpinlock);
return err;
}
开发者ID:svn2github,项目名称:virtualbox,代码行数:29,代码来源:VBoxDev-haiku.c
注:本文中的RTSpinlockRelease函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论