summaryrefslogtreecommitdiff
path: root/include/linux/mutex.h
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2024-01-16 17:00:02 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2024-01-16 17:17:23 -0500
commitb5fd066153c40a70a29caa1ea7987723ab687763 (patch)
tree6d43a8b0a90d549a54c65565ac96c92b3e84b594 /include/linux/mutex.h
parent06ff8b55b70fda44d91b31b5511fafd1680a8934 (diff)
Move c_src dirs back to toplevel
We just wanted c sourcefiles out of the top level, not c source directories. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'include/linux/mutex.h')
-rw-r--r--include/linux/mutex.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/include/linux/mutex.h b/include/linux/mutex.h
new file mode 100644
index 00000000..801f06e1
--- /dev/null
+++ b/include/linux/mutex.h
@@ -0,0 +1,18 @@
+#ifndef __TOOLS_LINUX_MUTEX_H
+#define __TOOLS_LINUX_MUTEX_H
+
+#include <pthread.h>
+
+struct mutex {
+ pthread_mutex_t lock;
+};
+
+#define DEFINE_MUTEX(mutexname) \
+ struct mutex mutexname = { .lock = PTHREAD_MUTEX_INITIALIZER }
+
+#define mutex_init(l) pthread_mutex_init(&(l)->lock, NULL)
+#define mutex_lock(l) pthread_mutex_lock(&(l)->lock)
+#define mutex_trylock(l) (!pthread_mutex_trylock(&(l)->lock))
+#define mutex_unlock(l) pthread_mutex_unlock(&(l)->lock)
+
+#endif /* __TOOLS_LINUX_MUTEX_H */