Changeset 6746 in vbox
- Timestamp:
- Feb 2, 2008 12:55:04 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/linux/semmutex-linux.cpp
r6745 r6746 88 88 89 89 90 /**91 * Validate a Mutex semaphore handle passed to one of the interface.92 *93 * @returns true if valid.94 * @returns false if invalid.95 * @param pIntMutexSem Pointer to the mutex semaphore to validate.96 */97 inline bool rtsemMutexValid(struct RTSEMMUTEXINTERNAL *pIntMutexSem)98 {99 if ((uintptr_t)pIntMutexSem < 0x10000)100 return false;101 102 if (pIntMutexSem->iMagic != RTSEMMUTEX_MAGIC)103 return false;104 105 if (pIntMutexSem->cNesting == (uint32_t)~0)106 return false;107 108 return true;109 }110 111 112 90 RTDECL(int) RTSemMutexCreate(PRTSEMMUTEX pMutexSem) 113 91 { … … 133 111 RTDECL(int) RTSemMutexDestroy(RTSEMMUTEX MutexSem) 134 112 { 113 /* 114 * Validate input. 115 */ 116 if (MutexSem == NIL_RTSEMMUTEX) 117 return VERR_INVALID_HANDLE; 135 118 struct RTSEMMUTEXINTERNAL *pIntMutexSem = MutexSem; 136 /* 137 * Validate input. 138 */ 139 if (!rtsemMutexValid(pIntMutexSem)) 140 { 141 AssertMsgFailed(("Invalid handle %p!\n", MutexSem)); 142 return VERR_INVALID_HANDLE; 143 } 119 AssertPtrReturn(pIntMutexSem, VERR_INVALID_HANDLE); 120 AssertMsgReturn(pIntMutexSem->iMagic == RTSEMMUTEX_MAGIC, 121 ("MutexSem=%p iMagic=%#x\n", pIntMutexSem, pIntMutexSem->iMagic), 122 VERR_INVALID_HANDLE); 144 123 145 124 /* … … 153 132 } 154 133 pIntMutexSem->Owner = (pthread_t)~0; 155 pIntMutexSem->cNesting = ~0;134 pIntMutexSem->cNesting = 0; 156 135 157 136 /* … … 169 148 */ 170 149 struct RTSEMMUTEXINTERNAL *pIntMutexSem = MutexSem; 171 if (!rtsemMutexValid(pIntMutexSem)) 172 { 173 AssertMsgFailed(("Invalid handle %p!\n", MutexSem)); 174 return VERR_INVALID_HANDLE; 175 } 150 AssertPtrReturn(pIntMutexSem, VERR_INVALID_HANDLE); 151 AssertMsgReturn(pIntMutexSem->iMagic == RTSEMMUTEX_MAGIC, 152 ("MutexSem=%p iMagic=%#x\n", pIntMutexSem, pIntMutexSem->iMagic), 153 VERR_INVALID_HANDLE); 176 154 177 155 /* … … 284 262 */ 285 263 struct RTSEMMUTEXINTERNAL *pIntMutexSem = MutexSem; 286 if (!rtsemMutexValid(pIntMutexSem)) 287 { 288 AssertMsgFailed(("Invalid handle %p!\n", MutexSem)); 289 return VERR_INVALID_HANDLE; 290 } 264 AssertPtrReturn(pIntMutexSem, VERR_INVALID_HANDLE); 265 AssertMsgReturn(pIntMutexSem->iMagic == RTSEMMUTEX_MAGIC, 266 ("MutexSem=%p iMagic=%#x\n", pIntMutexSem, pIntMutexSem->iMagic), 267 VERR_INVALID_HANDLE); 291 268 292 269 /* … … 294 271 */ 295 272 pthread_t Self = pthread_self(); 296 if ( pIntMutexSem->Owner != Self297 || pIntMutexSem->cNesting == (uint32_t)~0)273 if (RT_UNLIKELY( pIntMutexSem->Owner != Self 274 || pIntMutexSem->cNesting == 0)) 298 275 { 299 276 AssertMsgFailed(("Not owner of mutex %p!! Self=%08x Owner=%08x cNesting=%d\n",
Note:
See TracChangeset
for help on using the changeset viewer.