aboutsummaryrefslogtreecommitdiff
path: root/include/odp/api/spec/spinlock.h
diff options
context:
space:
mode:
authorChristophe Milard <christophe.milard@linaro.org>2016-02-11 15:21:41 +0100
committerMaxim Uvarov <maxim.uvarov@linaro.org>2016-03-04 11:15:23 +0300
commit98e20f0a78da6bf680ffbf473abc99b88d8576d9 (patch)
tree6715608e902d887a5070040eac8f62c8edc6b8a7 /include/odp/api/spec/spinlock.h
parent307ad1208bc59e03425468eebe8cffdf09ccb669 (diff)
api and linux-generic: make room for new api
This is about making the current structure clearer so that other interfaces can be added to ODP: The ODP API specification (platform agnostic) is moved from include/odp/api to include/odp/api/spec. The ODP API platform definition (for linux generic) is moved from platform/linux-generic/include/odp to platform/linux-generic/include/odp/api Include statements are adjusted accordinaly. This patch has been done by a script which is given with the cover-letter of this patch series. Signed-off-by: Christophe Milard <christophe.milard@linaro.org> Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Diffstat (limited to 'include/odp/api/spec/spinlock.h')
-rw-r--r--include/odp/api/spec/spinlock.h91
1 files changed, 91 insertions, 0 deletions
diff --git a/include/odp/api/spec/spinlock.h b/include/odp/api/spec/spinlock.h
new file mode 100644
index 000000000..154d0258a
--- /dev/null
+++ b/include/odp/api/spec/spinlock.h
@@ -0,0 +1,91 @@
+/* Copyright (c) 2013, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+
+/**
+ * @file
+ *
+ * ODP spinlock
+ */
+
+#ifndef ODP_API_SPINLOCK_H_
+#define ODP_API_SPINLOCK_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @addtogroup odp_locks
+ * @details
+ * <b> Spin lock (odp_spinlock_t) </b>
+ *
+ * Spinlock simply re-tries to acquire the lock as long as takes to succeed.
+ * Spinlock is not fair since some threads may succeed more often than others.
+ * @{
+ */
+
+/**
+ * @typedef odp_spinlock_t
+ * ODP spinlock
+ */
+
+/**
+ * Initialize spin lock.
+ *
+ * @param splock Pointer to a spin lock
+ */
+void odp_spinlock_init(odp_spinlock_t *splock);
+
+
+/**
+ * Acquire spin lock.
+ *
+ * @param splock Pointer to a spin lock
+ */
+void odp_spinlock_lock(odp_spinlock_t *splock);
+
+
+/**
+ * Try to acquire spin lock.
+ *
+ * @param splock Pointer to a spin lock
+ *
+ * @retval 1 lock acquired
+ * @retval 0 lock not acquired
+ */
+int odp_spinlock_trylock(odp_spinlock_t *splock);
+
+
+/**
+ * Release spin lock.
+ *
+ * @param splock Pointer to a spin lock
+ */
+void odp_spinlock_unlock(odp_spinlock_t *splock);
+
+
+/**
+ * Check if spin lock is busy (locked).
+ *
+ * @param splock Pointer to a spin lock
+ *
+ * @retval 1 lock busy (locked)
+ * @retval 0 lock not busy.
+ */
+int odp_spinlock_is_locked(odp_spinlock_t *splock);
+
+
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif