diff mbox

[v3,2/9] Split odp_buffer.h into API and platform parts

Message ID 5358DCBE.2080904@linaro.org
State Superseded
Headers show

Commit Message

Taras Kondratiuk April 24, 2014, 9:43 a.m. UTC
On 04/24/2014 11:29 AM, Savolainen, Petri (NSN - FI/Espoo) wrote:
> Hi,
> 
> Basically all definitions (except some specific align macros I'm going to remove) in odp/include are already normative. Names of types/macros/constants and function prototypes are normative. Values are implementation specific. Implementation specific headers (xxx_internal.h) are already in linux-generic/include.
> 
> Examples from /include:
> 
> typedef uint32_t odp_buffer_t;
>          ^^^^^^^^  ^^^^^^^^^^
>          specific   normative
> 
> #define ODP_BUFFER_INVALID (0xffffffff) /**< Invalid buffer */
>            ^^^^^^^^^^        ^^^^^^^^
>             normative          specific
> 
> /**
>   * Buffer start address
>   *
>   * @param buf      Buffer handle
>   *
>   * @return Buffer start address
>   */
> void *odp_buffer_addr(odp_buffer_t buf);
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>           normative
> 
> 
> static inline int odp_atomic_fetch_add_int(odp_atomic_int_t *ptr, int value)
>                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>                            normative
> {
> 	return __sync_fetch_and_add(ptr, value);
> }
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>     specific
> 
> 
> We don't e.g. want to limit values implementations may use e.g. XXX_INVALID == 0 or XXX_PRIO0..7 == 0..7. Some other values may be more natural fit to the underlying HW. Application must not use values found from API, only names.

Instead of removing normative part from top level headers,
we can do something like this
diff mbox

Patch

diff --git a/include/odp_buffer.h b/include/odp_buffer.h
index 2d2c25a..029c7b0 100644
--- a/include/odp_buffer.h
+++ b/include/odp_buffer.h
@@ -21,7 +21,7 @@  extern "C" {
 
 
 #include <odp_std_types.h>
-
+#include <plat/odp_buffer.h>
 
 
 
@@ -29,9 +29,9 @@  extern "C" {
 /**
  * ODP buffer
  */
-typedef uint32_t odp_buffer_t;
+typedef plat_odp_buffer_t odp_buffer_t;
 
-#define ODP_BUFFER_INVALID (0xffffffff) /**< Invalid buffer */
+#define ODP_BUFFER_INVALID PLAT_ODP_BUFFER_INVALID /**< Invalid buffer */
 
 
 /**
diff --git a/platform/linux-generic/Makefile b/platform/linux-generic/Makefile
index ec5d4a7..77269a4 100644
--- a/platform/linux-generic/Makefile
+++ b/platform/linux-generic/Makefile
@@ -137,5 +137,7 @@  headers_install: libs
 	$(ECHO) Installing headers to $(DESTDIR)/include
 	$(COPY) $(ODP_ROOT)/include $(DESTDIR)
 	$(COPY) include/api/* $(DESTDIR)/include/
+	$(MKDIR) $(DESTDIR)/include/plat
+	$(COPY) include/plat/* $(DESTDIR)/include/plat
 
 install: lib_install headers_install
diff --git a/platform/linux-generic/include/plat/odp_buffer.h b/platform/linux-generic/include/plat/odp_buffer.h
new file mode 100644
index 0000000..fef0321
--- /dev/null
+++ b/platform/linux-generic/include/plat/odp_buffer.h
@@ -0,0 +1,11 @@ 
+/*
+ * No protector.
+ * This file should be included only in one corresponding top level header.
+ */
+
+/**
+ * ODP buffer
+ */
+typedef uint32_t plat_odp_buffer_t;
+
+#define PLAT_ODP_BUFFER_INVALID (0xffffffff) /**< Invalid buffer */