1 /* 2 * SYS/MPLOCK2.H 3 * 4 * Implement the MP lock. Note that debug operations 5 */ 6 #ifndef _SYS_MPLOCK2_H_ 7 #define _SYS_MPLOCK2_H_ 8 9 #ifndef _MACHINE_ATOMIC_H_ 10 #include <machine/atomic.h> 11 #endif 12 #ifndef _SYS_THREAD_H_ 13 #include <sys/thread.h> 14 #endif 15 #ifndef _SYS_GLOBALDATA_H_ 16 #include <sys/globaldata.h> 17 #endif 18 19 #ifdef SMP 20 21 /* 22 * NOTE: try_mplock()/lwkt_trytoken() return non-zero on success. 23 */ 24 #define get_mplock() lwkt_gettoken(&mp_token) 25 #define try_mplock() lwkt_trytoken(&mp_token) 26 #define rel_mplock() lwkt_reltoken(&mp_token) 27 #define get_mplock_count(td) lwkt_cnttoken(&mp_token, td) 28 29 void cpu_get_initial_mplock(void); 30 31 #define MP_LOCK_HELD() LWKT_TOKEN_HELD(&mp_token) 32 #define ASSERT_MP_LOCK_HELD() ASSERT_LWKT_TOKEN_HELD(&mp_token) 33 34 #else 35 36 /* 37 * UNI-PROCESSOR BUILD - Degenerate case macros 38 */ 39 #define get_mplock() 40 #define rel_mplock() 41 #define try_mplock() 1 42 #define owner_mplock() 0 43 #define MP_LOCK_HELD(gd) 1 44 #define ASSERT_MP_LOCK_HELD(td) 45 46 #endif 47 48 #endif 49