Path: blob/main/sys/contrib/ck/include/ck_spinlock.h
48254 views
/*1* Copyright 2010-2015 Samy Al Bahra.2* All rights reserved.3*4* Redistribution and use in source and binary forms, with or without5* modification, are permitted provided that the following conditions6* are met:7* 1. Redistributions of source code must retain the above copyright8* notice, this list of conditions and the following disclaimer.9* 2. Redistributions in binary form must reproduce the above copyright10* notice, this list of conditions and the following disclaimer in the11* documentation and/or other materials provided with the distribution.12*13* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND14* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE15* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE16* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE17* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL18* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS19* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)20* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT21* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY22* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF23* SUCH DAMAGE.24*/2526#ifndef CK_SPINLOCK_H27#define CK_SPINLOCK_H2829#include "spinlock/anderson.h"30#include "spinlock/cas.h"31#include "spinlock/clh.h"32#include "spinlock/dec.h"33#include "spinlock/fas.h"34#include "spinlock/hclh.h"35#include "spinlock/mcs.h"36#include "spinlock/ticket.h"3738/*39* On tested x86, x86_64, PPC64 and SPARC64 targets,40* ck_spinlock_fas proved to have lowest latency41* in fast path testing or negligible degradation42* from faster but less robust implementations.43*/44#define CK_SPINLOCK_INITIALIZER CK_SPINLOCK_FAS_INITIALIZER45#define ck_spinlock_t ck_spinlock_fas_t46#define ck_spinlock_init(x) ck_spinlock_fas_init(x)47#define ck_spinlock_lock(x) ck_spinlock_fas_lock(x)48#define ck_spinlock_lock_eb(x) ck_spinlock_fas_lock_eb(x)49#define ck_spinlock_unlock(x) ck_spinlock_fas_unlock(x)50#define ck_spinlock_locked(x) ck_spinlock_fas_locked(x)51#define ck_spinlock_trylock(x) ck_spinlock_fas_trylock(x)5253CK_ELIDE_PROTOTYPE(ck_spinlock, ck_spinlock_t,54ck_spinlock_locked, ck_spinlock_lock,55ck_spinlock_locked, ck_spinlock_unlock)5657CK_ELIDE_TRYLOCK_PROTOTYPE(ck_spinlock, ck_spinlock_t,58ck_spinlock_locked, ck_spinlock_trylock)5960#endif /* CK_SPINLOCK_H */616263