diff mbox series

[v2,2/5] linux-gen: ticketlock: inline also in application

Message ID 1486556256-22167-3-git-send-email-petri.savolainen@linaro.org
State Accepted
Commit 4960e04aff0c21b3213eba480cf7ca38578e0839
Headers show
Series Packet function inline | expand

Commit Message

Petri Savolainen Feb. 8, 2017, 12:17 p.m. UTC
Enable ticketlock function inlining in applications when
not building for ABI compatibility.

Signed-off-by: Petri Savolainen <petri.savolainen@linaro.org>

---
 platform/linux-generic/Makefile.am                 |  1 +
 .../include/odp/api/plat/ticketlock_inlines.h      | 19 +++++++++++-
 .../include/odp/api/plat/ticketlock_inlines_api.h  | 36 ++++++++++++++++++++++
 .../linux-generic/include/odp/api/ticketlock.h     |  4 +++
 platform/linux-generic/odp_ticketlock.c            | 24 +++------------
 5 files changed, 64 insertions(+), 20 deletions(-)
 create mode 100644 platform/linux-generic/include/odp/api/plat/ticketlock_inlines_api.h

-- 
2.8.1
diff mbox series

Patch

diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am
index 576fedf..64b0287 100644
--- a/platform/linux-generic/Makefile.am
+++ b/platform/linux-generic/Makefile.am
@@ -94,6 +94,7 @@  odpapiplatinclude_HEADERS = \
 		  $(srcdir)/include/odp/api/plat/thread_types.h \
 		  $(srcdir)/include/odp/api/plat/thrmask_types.h \
 		  $(srcdir)/include/odp/api/plat/ticketlock_inlines.h \
+		  $(srcdir)/include/odp/api/plat/ticketlock_inlines_api.h \
 		  $(srcdir)/include/odp/api/plat/ticketlock_types.h \
 		  $(srcdir)/include/odp/api/plat/time_types.h \
 		  $(srcdir)/include/odp/api/plat/timer_types.h \
diff --git a/platform/linux-generic/include/odp/api/plat/ticketlock_inlines.h b/platform/linux-generic/include/odp/api/plat/ticketlock_inlines.h
index 87432a7..ecbea7c 100644
--- a/platform/linux-generic/include/odp/api/plat/ticketlock_inlines.h
+++ b/platform/linux-generic/include/odp/api/plat/ticketlock_inlines.h
@@ -13,11 +13,12 @@ 
 #ifndef _ODP_PLAT_TICKETLOCK_INLINES_H_
 #define _ODP_PLAT_TICKETLOCK_INLINES_H_
 
-#include <odp/api/ticketlock.h>
 #include <odp/api/atomic.h>
 #include <odp/api/sync.h>
 #include <odp/api/cpu.h>
 
+#include <odp/api/plat/ticketlock_types.h>
+
 /** @internal
  * Acquire ticket lock.
  *
@@ -110,4 +111,20 @@  static inline int _odp_ticketlock_is_locked(odp_ticketlock_t *ticketlock)
 		odp_atomic_load_u32(&ticketlock->next_ticket);
 }
 
+/* Include inlined versions of API functions */
+#include <odp/api/plat/static_inline.h>
+#if ODP_ABI_COMPAT == 0
+
+/** @ingroup odp_locks
+ *  @{
+ */
+
+#include <odp/api/plat/ticketlock_inlines_api.h>
+
+/**
+ * @}
+ */
+
+#endif
+
 #endif
diff --git a/platform/linux-generic/include/odp/api/plat/ticketlock_inlines_api.h b/platform/linux-generic/include/odp/api/plat/ticketlock_inlines_api.h
new file mode 100644
index 0000000..5efe696
--- /dev/null
+++ b/platform/linux-generic/include/odp/api/plat/ticketlock_inlines_api.h
@@ -0,0 +1,36 @@ 
+/* Copyright (c) 2017, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+/**
+ * @file
+ *
+ * Ticketlock inline functions
+ */
+
+#ifndef _ODP_PLAT_TICKETLOCK_INLINES_API_H_
+#define _ODP_PLAT_TICKETLOCK_INLINES_API_H_
+
+_ODP_INLINE void odp_ticketlock_lock(odp_ticketlock_t *lock)
+{
+	return _odp_ticketlock_lock(lock);
+}
+
+_ODP_INLINE int odp_ticketlock_trylock(odp_ticketlock_t *lock)
+{
+	return _odp_ticketlock_trylock(lock);
+}
+
+_ODP_INLINE void odp_ticketlock_unlock(odp_ticketlock_t *lock)
+{
+	_odp_ticketlock_unlock(lock);
+}
+
+_ODP_INLINE int odp_ticketlock_is_locked(odp_ticketlock_t *lock)
+{
+	return _odp_ticketlock_is_locked(lock);
+}
+
+#endif
diff --git a/platform/linux-generic/include/odp/api/ticketlock.h b/platform/linux-generic/include/odp/api/ticketlock.h
index 85be4bc..e0f5d81 100644
--- a/platform/linux-generic/include/odp/api/ticketlock.h
+++ b/platform/linux-generic/include/odp/api/ticketlock.h
@@ -19,6 +19,10 @@  extern "C" {
 
 #include <odp/api/plat/ticketlock_types.h>
 
+#if ODP_ABI_COMPAT == 0
+#include <odp/api/plat/ticketlock_inlines.h>
+#endif
+
 #include <odp/api/spec/ticketlock.h>
 
 #ifdef __cplusplus
diff --git a/platform/linux-generic/odp_ticketlock.c b/platform/linux-generic/odp_ticketlock.c
index f18d78f..f73dd9a 100644
--- a/platform/linux-generic/odp_ticketlock.c
+++ b/platform/linux-generic/odp_ticketlock.c
@@ -5,6 +5,7 @@ 
  */
 
 #include <odp/api/plat/ticketlock_inlines.h>
+#include <odp/api/spec/ticketlock.h>
 
 void odp_ticketlock_init(odp_ticketlock_t *ticketlock)
 {
@@ -12,22 +13,7 @@  void odp_ticketlock_init(odp_ticketlock_t *ticketlock)
 	odp_atomic_init_u32(&ticketlock->cur_ticket, 0);
 }
 
-void odp_ticketlock_lock(odp_ticketlock_t *lock)
-{
-	return _odp_ticketlock_lock(lock);
-}
-
-int odp_ticketlock_trylock(odp_ticketlock_t *lock)
-{
-	return _odp_ticketlock_trylock(lock);
-}
-
-void odp_ticketlock_unlock(odp_ticketlock_t *lock)
-{
-	_odp_ticketlock_unlock(lock);
-}
-
-int odp_ticketlock_is_locked(odp_ticketlock_t *lock)
-{
-	return _odp_ticketlock_is_locked(lock);
-}
+/* Include non-inlined versions of API functions */
+#if ODP_ABI_COMPAT == 1
+#include <odp/api/plat/ticketlock_inlines_api.h>
+#endif