]>
git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - ubuntu/vbox/include/iprt/spinlock.h
6 * Copyright (C) 2006-2016 Oracle Corporation
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
26 #ifndef ___iprt_spinlock_h
27 #define ___iprt_spinlock_h
29 #include <iprt/cdefs.h>
30 #include <iprt/types.h>
35 /** @defgroup grp_rt_spinlock RTSpinlock - Spinlocks
43 * @returns iprt status code.
44 * @param pSpinlock Where to store the spinlock handle.
45 * @param fFlags Creation flags, see RTSPINLOCK_FLAGS_XXX.
46 * @param pszName Spinlock name, for debugging purposes. String lifetime
47 * must be the same as the lock as it won't be copied.
49 RTDECL(int) RTSpinlockCreate(PRTSPINLOCK pSpinlock
, uint32_t fFlags
, const char *pszName
);
51 /** @name RTSPINLOCK_FLAGS_XXX
53 /** Disable interrupts when taking the spinlock, making it interrupt safe
54 * (sans NMI of course).
56 * This is generally the safest option, though it isn't really required unless
57 * the data being protect is also accessed from interrupt handler context. */
58 #define RTSPINLOCK_FLAGS_INTERRUPT_SAFE RT_BIT(1)
59 /** No need to disable interrupts, the protect code/data is not used by
60 * interrupt handlers. */
61 #define RTSPINLOCK_FLAGS_INTERRUPT_UNSAFE RT_BIT(2)
65 * Destroys a spinlock created by RTSpinlockCreate().
67 * @returns iprt status code.
68 * @param Spinlock Spinlock returned by RTSpinlockCreate().
70 RTDECL(int) RTSpinlockDestroy(RTSPINLOCK Spinlock
);
73 * Acquires the spinlock.
75 * @param Spinlock The spinlock to acquire.
77 RTDECL(void) RTSpinlockAcquire(RTSPINLOCK Spinlock
);
80 * Releases the spinlock.
82 * @param Spinlock The spinlock to acquire.
84 RTDECL(void) RTSpinlockRelease(RTSPINLOCK Spinlock
);