From 9ce4a0e99198995bb7bf57076066b35fed23b8d3 Mon Sep 17 00:00:00 2001 From: Zhihao Cheng Date: Mon, 11 Nov 2024 16:36:47 +0800 Subject: ubifs-utils: Add spinlock implementations Add spinlock implementations, because there are some spinlocks (eg. c->cnt_lock, c->buds_lock) used in UBIFS linux kernel libs. The spinlock is implemented based on pthread mutex. This is a preparation for replacing implementation of UBIFS utils with linux kernel libs. Signed-off-by: Zhihao Cheng Signed-off-by: David Oberhollenzer --- ubifs-utils/common/spinlock.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 ubifs-utils/common/spinlock.h (limited to 'ubifs-utils/common') diff --git a/ubifs-utils/common/spinlock.h b/ubifs-utils/common/spinlock.h new file mode 100644 index 0000000..b9ed393 --- /dev/null +++ b/ubifs-utils/common/spinlock.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __LINUX_SPINLOCK_H_ +#define __LINUX_SPINLOCK_H_ + +#include + +#define spinlock_t pthread_mutex_t +#define DEFINE_SPINLOCK(x) pthread_mutex_t x = PTHREAD_MUTEX_INITIALIZER +#define spin_lock_init(x) pthread_mutex_init(x, NULL) + +#define spin_lock(x) pthread_mutex_lock(x) +#define spin_unlock(x) pthread_mutex_unlock(x) + +#endif -- cgit v1.2.3