1*d4a07e70Sfengbojiang /*- 2*d4a07e70Sfengbojiang * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3*d4a07e70Sfengbojiang * 4*d4a07e70Sfengbojiang * Copyright (c) 2019, 2020 Jeffrey Roberson <[email protected]> 5*d4a07e70Sfengbojiang * 6*d4a07e70Sfengbojiang * Redistribution and use in source and binary forms, with or without 7*d4a07e70Sfengbojiang * modification, are permitted provided that the following conditions 8*d4a07e70Sfengbojiang * are met: 9*d4a07e70Sfengbojiang * 1. Redistributions of source code must retain the above copyright 10*d4a07e70Sfengbojiang * notice unmodified, this list of conditions, and the following 11*d4a07e70Sfengbojiang * disclaimer. 12*d4a07e70Sfengbojiang * 2. Redistributions in binary form must reproduce the above copyright 13*d4a07e70Sfengbojiang * notice, this list of conditions and the following disclaimer in the 14*d4a07e70Sfengbojiang * documentation and/or other materials provided with the distribution. 15*d4a07e70Sfengbojiang * 16*d4a07e70Sfengbojiang * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17*d4a07e70Sfengbojiang * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18*d4a07e70Sfengbojiang * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19*d4a07e70Sfengbojiang * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20*d4a07e70Sfengbojiang * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21*d4a07e70Sfengbojiang * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22*d4a07e70Sfengbojiang * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23*d4a07e70Sfengbojiang * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24*d4a07e70Sfengbojiang * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25*d4a07e70Sfengbojiang * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26*d4a07e70Sfengbojiang * 27*d4a07e70Sfengbojiang * $FreeBSD$ 28*d4a07e70Sfengbojiang * 29*d4a07e70Sfengbojiang */ 30*d4a07e70Sfengbojiang 31*d4a07e70Sfengbojiang #ifndef _SYS__SMR_H_ 32*d4a07e70Sfengbojiang #define _SYS__SMR_H_ 33*d4a07e70Sfengbojiang 34*d4a07e70Sfengbojiang typedef uint32_t smr_seq_t; 35*d4a07e70Sfengbojiang typedef int32_t smr_delta_t; 36*d4a07e70Sfengbojiang typedef struct smr *smr_t; 37*d4a07e70Sfengbojiang 38*d4a07e70Sfengbojiang #define SMR_ENTERED(smr) \ 39*d4a07e70Sfengbojiang (curthread->td_critnest != 0 && zpcpu_get((smr))->c_seq != SMR_SEQ_INVALID) 40*d4a07e70Sfengbojiang 41*d4a07e70Sfengbojiang #define SMR_ASSERT_ENTERED(smr) \ 42*d4a07e70Sfengbojiang KASSERT(SMR_ENTERED(smr), ("Not in smr section")) 43*d4a07e70Sfengbojiang 44*d4a07e70Sfengbojiang #define SMR_ASSERT_NOT_ENTERED(smr) \ 45*d4a07e70Sfengbojiang KASSERT(!SMR_ENTERED(smr), ("In smr section.")); 46*d4a07e70Sfengbojiang 47*d4a07e70Sfengbojiang #define SMR_ASSERT(ex, fn) \ 48*d4a07e70Sfengbojiang KASSERT((ex), (fn ": Assertion " #ex " failed at %s:%d", __FILE__, __LINE__)) 49*d4a07e70Sfengbojiang 50*d4a07e70Sfengbojiang #endif /* __SYS_SMR_H_ */ 51