VirtualBox

source: vbox/trunk/include/iprt/spinlock.h@ 92059

Last change on this file since 92059 was 82968, checked in by vboxsync, 5 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.8 KB
Line 
1/** @file
2 * IPRT - Spinlocks.
3 */
4
5/*
6 * Copyright (C) 2006-2020 Oracle Corporation
7 *
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.
15 *
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.
21 *
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.
24 */
25
26#ifndef IPRT_INCLUDED_spinlock_h
27#define IPRT_INCLUDED_spinlock_h
28#ifndef RT_WITHOUT_PRAGMA_ONCE
29# pragma once
30#endif
31
32#include <iprt/cdefs.h>
33#include <iprt/types.h>
34
35RT_C_DECLS_BEGIN
36
37
38/** @defgroup grp_rt_spinlock RTSpinlock - Spinlocks
39 * @ingroup grp_rt
40 * @{
41 */
42
43/**
44 * Creates a spinlock.
45 *
46 * @returns iprt status code.
47 * @param pSpinlock Where to store the spinlock handle.
48 * @param fFlags Creation flags, see RTSPINLOCK_FLAGS_XXX.
49 * @param pszName Spinlock name, for debugging purposes. String lifetime
50 * must be the same as the lock as it won't be copied.
51 */
52RTDECL(int) RTSpinlockCreate(PRTSPINLOCK pSpinlock, uint32_t fFlags, const char *pszName);
53
54/** @name RTSPINLOCK_FLAGS_XXX
55 * @{ */
56/** Disable interrupts when taking the spinlock, making it interrupt safe
57 * (sans NMI of course).
58 *
59 * This is generally the safest option, though it isn't really required unless
60 * the data being protect is also accessed from interrupt handler context. */
61#define RTSPINLOCK_FLAGS_INTERRUPT_SAFE RT_BIT(1)
62/** No need to disable interrupts, the protect code/data is not used by
63 * interrupt handlers. */
64#define RTSPINLOCK_FLAGS_INTERRUPT_UNSAFE RT_BIT(2)
65/** @} */
66
67/**
68 * Destroys a spinlock created by RTSpinlockCreate().
69 *
70 * @returns iprt status code.
71 * @param Spinlock Spinlock returned by RTSpinlockCreate().
72 */
73RTDECL(int) RTSpinlockDestroy(RTSPINLOCK Spinlock);
74
75/**
76 * Acquires the spinlock.
77 *
78 * @param Spinlock The spinlock to acquire.
79 */
80RTDECL(void) RTSpinlockAcquire(RTSPINLOCK Spinlock);
81
82/**
83 * Releases the spinlock.
84 *
85 * @param Spinlock The spinlock to acquire.
86 */
87RTDECL(void) RTSpinlockRelease(RTSPINLOCK Spinlock);
88
89
90/** @} */
91
92RT_C_DECLS_END
93
94#endif /* !IPRT_INCLUDED_spinlock_h */
95
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette