diff mbox series

[API-NEXT,PATCHv3,2/5] linux-gen: ticketlock: inline also in application

Message ID 20170209115352.16271-3-bill.fischofer@linaro.org
State New
Headers show
Series Packet function inline | expand

Commit Message

Bill Fischofer Feb. 9, 2017, 11:53 a.m. UTC
From: Petri Savolainen <petri.savolainen@linaro.org>


Enable ticketlock function inlining in applications when
not building for ABI compatibility.

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

Signed-off-by: Bill Fischofer <bill.fischofer@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.11.0.295.gd7dffce
diff mbox series

Patch

diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am
index 66ff53d5..63d5cbc0 100644
--- a/platform/linux-generic/Makefile.am
+++ b/platform/linux-generic/Makefile.am
@@ -98,6 +98,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 87432a71..ecbea7c4 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 00000000..5efe696f
--- /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 85be4bc5..e0f5d81f 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 f18d78f5..f73dd9ab 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