Changeset 25722 in vbox for trunk/src/VBox/Runtime/r0drv/freebsd
- Timestamp:
- Jan 11, 2010 2:22:03 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 56464
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r0drv/freebsd/semfastmutex-r0drv-freebsd.c
r22579 r25722 58 58 59 59 60 RTDECL(int) RTSemFastMutexCreate(PRTSEMFASTMUTEX p MutexSem)60 RTDECL(int) RTSemFastMutexCreate(PRTSEMFASTMUTEX phFastMtx) 61 61 { 62 62 AssertCompile(sizeof(RTSEMFASTMUTEXINTERNAL) > sizeof(void *)); 63 AssertPtrReturn(p MutexSem, VERR_INVALID_POINTER);63 AssertPtrReturn(phFastMtx, VERR_INVALID_POINTER); 64 64 65 PRTSEMFASTMUTEXINTERNAL p FastInt = (PRTSEMFASTMUTEXINTERNAL)RTMemAllocZ(sizeof(*pFastInt));66 if (p FastInt)65 PRTSEMFASTMUTEXINTERNAL pThis = (PRTSEMFASTMUTEXINTERNAL)RTMemAllocZ(sizeof(*pThis)); 66 if (pThis) 67 67 { 68 pFastInt->u32Magic = RTSEMFASTMUTEX_MAGIC; 69 sx_init(&pFastInt->SxLock, "IPRT Fast Mutex Semaphore"); 70 *pMutexSem = pFastInt; 68 pThis->u32Magic = RTSEMFASTMUTEX_MAGIC; 69 sx_init(&pThis->SxLock, "IPRT Fast Mutex Semaphore"); 70 71 *phFastMtx = pThis; 71 72 return VINF_SUCCESS; 72 73 } … … 75 76 76 77 77 RTDECL(int) RTSemFastMutexDestroy(RTSEMFASTMUTEX MutexSem)78 RTDECL(int) RTSemFastMutexDestroy(RTSEMFASTMUTEX hFastMtx) 78 79 { 79 if (MutexSem == NIL_RTSEMFASTMUTEX) /* don't bitch */ 80 return VERR_INVALID_PARAMETER; 81 PRTSEMFASTMUTEXINTERNAL pFastInt = (PRTSEMFASTMUTEXINTERNAL)MutexSem; 82 AssertPtrReturn(pFastInt, VERR_INVALID_PARAMETER); 83 AssertMsgReturn(pFastInt->u32Magic == RTSEMFASTMUTEX_MAGIC, 84 ("pFastInt->u32Magic=%RX32 pFastInt=%p\n", pFastInt->u32Magic, pFastInt), 85 VERR_INVALID_PARAMETER); 80 PRTSEMFASTMUTEXINTERNAL pThis = hFastMtx; 81 if (pThis == NIL_RTSEMFASTMUTEX) 82 return VINF_SUCCESS; 83 AssertPtrReturn(pThis, VERR_INVALID_HANDLE); 84 AssertMsgReturn(pThis->u32Magic == RTSEMFASTMUTEX_MAGIC, ("%p: u32Magic=%RX32\n", pThis, pThis->u32Magic), VERR_INVALID_HANDLE); 86 85 87 ASMAtomic XchgU32(&pFastInt->u32Magic, RTSEMFASTMUTEX_MAGIC_DEAD);88 sx_destroy(&p FastInt->SxLock);89 RTMemFree(p FastInt);86 ASMAtomicWriteU32(&pThis->u32Magic, RTSEMFASTMUTEX_MAGIC_DEAD); 87 sx_destroy(&pThis->SxLock); 88 RTMemFree(pThis); 90 89 91 90 return VINF_SUCCESS; … … 93 92 94 93 95 RTDECL(int) RTSemFastMutexRequest(RTSEMFASTMUTEX MutexSem)94 RTDECL(int) RTSemFastMutexRequest(RTSEMFASTMUTEX hFastMtx) 96 95 { 97 PRTSEMFASTMUTEXINTERNAL pFastInt = (PRTSEMFASTMUTEXINTERNAL)MutexSem; 98 AssertPtrReturn(pFastInt, VERR_INVALID_PARAMETER); 99 AssertMsgReturn(pFastInt->u32Magic == RTSEMFASTMUTEX_MAGIC, 100 ("pFastInt->u32Magic=%RX32 pFastInt=%p\n", pFastInt->u32Magic, pFastInt), 101 VERR_INVALID_PARAMETER); 96 PRTSEMFASTMUTEXINTERNAL pThis = hFastMtx; 97 AssertPtrReturn(pThis, VERR_INVALID_HANDLE); 98 AssertMsgReturn(pThis->u32Magic == RTSEMFASTMUTEX_MAGIC, ("%p: u32Magic=%RX32\n", pThis, pThis->u32Magic), VERR_INVALID_HANDLE); 102 99 103 sx_xlock(&p FastInt->SxLock);100 sx_xlock(&pThis->SxLock); 104 101 return VINF_SUCCESS; 105 102 } 106 103 107 104 108 RTDECL(int) RTSemFastMutexRelease(RTSEMFASTMUTEX MutexSem)105 RTDECL(int) RTSemFastMutexRelease(RTSEMFASTMUTEX hFastMtx) 109 106 { 110 PRTSEMFASTMUTEXINTERNAL pFastInt = (PRTSEMFASTMUTEXINTERNAL)MutexSem; 111 AssertPtrReturn(pFastInt, VERR_INVALID_PARAMETER); 112 AssertMsgReturn(pFastInt->u32Magic == RTSEMFASTMUTEX_MAGIC, 113 ("pFastInt->u32Magic=%RX32 pFastInt=%p\n", pFastInt->u32Magic, pFastInt), 114 VERR_INVALID_PARAMETER); 107 PRTSEMFASTMUTEXINTERNAL pThis = hFastMtx; 108 AssertPtrReturn(pThis, VERR_INVALID_HANDLE); 109 AssertMsgReturn(pThis->u32Magic == RTSEMFASTMUTEX_MAGIC, ("%p: u32Magic=%RX32\n", pThis, pThis->u32Magic), VERR_INVALID_HANDLE); 115 110 116 sx_xunlock(&p FastInt->SxLock);111 sx_xunlock(&pThis->SxLock); 117 112 return VINF_SUCCESS; 118 113 }
Note:
See TracChangeset
for help on using the changeset viewer.