diff mbox

[API-NEXT,04/13] linux-generic: drv: strong typing

Message ID 1471621724-8485-5-git-send-email-christophe.milard@linaro.org
State Superseded
Headers show

Commit Message

Christophe Milard Aug. 19, 2016, 3:48 p.m. UTC
Mirrored from its couterpart on the api interface, the drv interface
gets its strong typing file.

Signed-off-by: Christophe Milard <christophe.milard@linaro.org>

---
 platform/linux-generic/Makefile.am                 |  3 +-
 .../include/odp/drv/plat/strong_types.h            | 35 ++++++++++++++++++++++
 2 files changed, 37 insertions(+), 1 deletion(-)
 create mode 100644 platform/linux-generic/include/odp/drv/plat/strong_types.h

-- 
2.7.4
diff mbox

Patch

diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am
index 42e9996..271f5b5 100644
--- a/platform/linux-generic/Makefile.am
+++ b/platform/linux-generic/Makefile.am
@@ -108,7 +108,8 @@  odpdrvplatinclude_HEADERS = \
 		  $(srcdir)/include/odp/drv/plat/atomic_types.h \
 		  $(srcdir)/include/odp/drv/plat/barrier_types.h \
 		  $(srcdir)/include/odp/drv/plat/byteorder_types.h \
-		  $(srcdir)/include/odp/drv/plat/spinlock_types.h
+		  $(srcdir)/include/odp/drv/plat/spinlock_types.h \
+		  $(srcdir)/include/odp/drv/plat/strong_types.h
 
 noinst_HEADERS = \
 		  ${srcdir}/include/odp_align_internal.h \
diff --git a/platform/linux-generic/include/odp/drv/plat/strong_types.h b/platform/linux-generic/include/odp/drv/plat/strong_types.h
new file mode 100644
index 0000000..a9c48ef
--- /dev/null
+++ b/platform/linux-generic/include/odp/drv/plat/strong_types.h
@@ -0,0 +1,35 @@ 
+/* Copyright (c) 2016, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:     BSD-3-Clause
+ */
+
+/**
+ * @file
+ *
+ * ODPDRV Strong Types. Common macros for implementing strong typing
+ * for ODPDRV abstract data types
+ */
+
+#ifndef ODPDRV_STRONG_TYPES_H_
+#define ODPDRV_STRONG_TYPES_H_
+
+/** Use strong typing for ODPDRV types */
+#ifdef __cplusplus
+#define ODPDRV_HANDLE_T(type) struct _##type { uint8_t unused_dummy_var; } *type
+#else
+#define odpdrv_handle_t struct { uint8_t unused_dummy_var; } *
+/** C/C++ helper macro for strong typing */
+#define ODPDRV_HANDLE_T(type) odpdrv_handle_t type
+#endif
+
+/** Internal macro to get value of an ODPDRV handle */
+#define _odpdrv_typeval(handle) ((uint32_t)(uintptr_t)(handle))
+
+/** Internal macro to get printable value of an ODPDRV handle */
+#define _odpdrv_pri(handle) ((uint64_t)_odpdrv_typeval(handle))
+
+/** Internal macro to convert a scalar to a typed handle */
+#define _odpdrv_cast_scalar(type, val) ((type)(uintptr_t)(val))
+
+#endif