diff options
Diffstat (limited to 'src/VBox/Runtime/common/misc/handletable.cpp')
-rw-r--r-- | src/VBox/Runtime/common/misc/handletable.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/VBox/Runtime/common/misc/handletable.cpp b/src/VBox/Runtime/common/misc/handletable.cpp index 80eb2387..375e79db 100644 --- a/src/VBox/Runtime/common/misc/handletable.cpp +++ b/src/VBox/Runtime/common/misc/handletable.cpp @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2008 Oracle Corporation + * Copyright (C) 2008-2013 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -57,6 +57,8 @@ RTDECL(int) RTHandleTableCreateEx(PRTHANDLETABLE phHandleTable, uint32_t fFlags, *phHandleTable = NIL_RTHANDLETABLE; AssertPtrNullReturn(pfnRetain, VERR_INVALID_POINTER); AssertReturn(!(fFlags & ~RTHANDLETABLE_FLAGS_MASK), VERR_INVALID_PARAMETER); + AssertReturn(RT_BOOL(fFlags & RTHANDLETABLE_FLAGS_LOCKED) + RT_BOOL(fFlags & RTHANDLETABLE_FLAGS_LOCKED_IRQ_SAFE) < 2, + VERR_INVALID_PARAMETER); AssertReturn(cMax > 0, VERR_INVALID_PARAMETER); AssertReturn(UINT32_MAX - cMax >= uBase, VERR_INVALID_PARAMETER); @@ -100,9 +102,13 @@ RTDECL(int) RTHandleTableCreateEx(PRTHANDLETABLE phHandleTable, uint32_t fFlags, pThis->cLevel1 = cLevel1 < RTHT_LEVEL1_DYN_ALLOC_THRESHOLD ? cLevel1 : 0; pThis->iFreeHead = NIL_RTHT_INDEX; pThis->iFreeTail = NIL_RTHT_INDEX; - if (fFlags & RTHANDLETABLE_FLAGS_LOCKED) + if (fFlags & (RTHANDLETABLE_FLAGS_LOCKED | RTHANDLETABLE_FLAGS_LOCKED_IRQ_SAFE)) { - int rc = RTSpinlockCreate(&pThis->hSpinlock, RTSPINLOCK_FLAGS_INTERRUPT_UNSAFE, "RTHandleTableCreateEx"); + int rc; + if (fFlags & RTHANDLETABLE_FLAGS_LOCKED_IRQ_SAFE) + rc = RTSpinlockCreate(&pThis->hSpinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "RTHandleTableCreateEx"); + else + rc = RTSpinlockCreate(&pThis->hSpinlock, RTSPINLOCK_FLAGS_INTERRUPT_UNSAFE, "RTHandleTableCreateEx"); if (RT_FAILURE(rc)) { RTMemFree(pThis); |