spinlock-r0drv-freebsd.c revision f0ed7ab5e7f8d2f73b5aa08e46eb3a04cbb31cb2
af062818b47340eef15700d2f0211576ba3506eevboxsync * IPRT - Spinlocks, Ring-0 Driver, FreeBSD.
af062818b47340eef15700d2f0211576ba3506eevboxsync * Copyright (c) 2007 knut st. osmundsen <bird-src-spam@anduin.net>
af062818b47340eef15700d2f0211576ba3506eevboxsync * Permission is hereby granted, free of charge, to any person
af062818b47340eef15700d2f0211576ba3506eevboxsync * obtaining a copy of this software and associated documentation
af062818b47340eef15700d2f0211576ba3506eevboxsync * files (the "Software"), to deal in the Software without
af062818b47340eef15700d2f0211576ba3506eevboxsync * restriction, including without limitation the rights to use,
af062818b47340eef15700d2f0211576ba3506eevboxsync * copy, modify, merge, publish, distribute, sublicense, and/or sell
af062818b47340eef15700d2f0211576ba3506eevboxsync * copies of the Software, and to permit persons to whom the
af062818b47340eef15700d2f0211576ba3506eevboxsync * Software is furnished to do so, subject to the following
af062818b47340eef15700d2f0211576ba3506eevboxsync * conditions:
af062818b47340eef15700d2f0211576ba3506eevboxsync * The above copyright notice and this permission notice shall be
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync * included in all copies or substantial portions of the Software.
4b9d6701570cb98fd36e209314239d104ec584d3vboxsync * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
af062818b47340eef15700d2f0211576ba3506eevboxsync * OTHER DEALINGS IN THE SOFTWARE.
af062818b47340eef15700d2f0211576ba3506eevboxsync/*******************************************************************************
af062818b47340eef15700d2f0211576ba3506eevboxsync* Header Files *
af062818b47340eef15700d2f0211576ba3506eevboxsync*******************************************************************************/
af062818b47340eef15700d2f0211576ba3506eevboxsync/*******************************************************************************
af062818b47340eef15700d2f0211576ba3506eevboxsync* Structures and Typedefs *
af062818b47340eef15700d2f0211576ba3506eevboxsync*******************************************************************************/
af062818b47340eef15700d2f0211576ba3506eevboxsync * Wrapper for the struct mtx type.
af062818b47340eef15700d2f0211576ba3506eevboxsync /** Spinlock magic value (RTSPINLOCK_MAGIC). */
af062818b47340eef15700d2f0211576ba3506eevboxsync /** The spinlock. */
af062818b47340eef15700d2f0211576ba3506eevboxsync /** Saved interrupt flag. */
af062818b47340eef15700d2f0211576ba3506eevboxsync /** The spinlock creation flags. */
af062818b47340eef15700d2f0211576ba3506eevboxsync /** The idAssertCpu variable before acquring the lock for asserting after
af062818b47340eef15700d2f0211576ba3506eevboxsync * releasing the spinlock. */
af062818b47340eef15700d2f0211576ba3506eevboxsync /** The CPU that owns the lock. */
af062818b47340eef15700d2f0211576ba3506eevboxsyncRTDECL(int) RTSpinlockCreate(PRTSPINLOCK pSpinlock, uint32_t fFlags, const char *pszName)
af062818b47340eef15700d2f0211576ba3506eevboxsync AssertReturn(fFlags == RTSPINLOCK_FLAGS_INTERRUPT_SAFE || fFlags == RTSPINLOCK_FLAGS_INTERRUPT_UNSAFE, VERR_INVALID_PARAMETER);
af062818b47340eef15700d2f0211576ba3506eevboxsync * Allocate.
af062818b47340eef15700d2f0211576ba3506eevboxsync AssertCompile(sizeof(RTSPINLOCKINTERNAL) > sizeof(void *));
if (!pThis)
return VERR_NO_MEMORY;
return VINF_SUCCESS;
if (!pThis)
return VERR_INVALID_PARAMETER;
return VINF_SUCCESS;
cpu_spinwait();
cpu_spinwait();