1 /* 2 * Copyright 2018 The Hafnium Authors. 3 * 4 * Use of this source code is governed by a BSD-style 5 * license that can be found in the LICENSE file or at 6 * https://opensource.org/licenses/BSD-3-Clause. 7 */ 8 9 #pragma once 10 11 /* 12 * Includes the arch-specific definition of 'struct spinlock' and 13 * implementations of: 14 * - SPINLOCK_INIT 15 * - sl_lock() 16 * - sl_unlock() 17 */ 18 #include "hf/arch/spinlock.h" 19 20 /** 21 * Locks both locks, enforcing the lowest address first ordering for locks of 22 * the same kind. 23 */ sl_lock_both(struct spinlock * a,struct spinlock * b)24static inline void sl_lock_both(struct spinlock *a, struct spinlock *b) 25 { 26 if (a < b) { 27 sl_lock(a); 28 sl_lock(b); 29 } else { 30 sl_lock(b); 31 sl_lock(a); 32 } 33 } 34