diff mbox series

[API-NEXT,1/3] api: hints: rework ODP_DEPRECATED API

Message ID 20170307115225.29225-2-dmitry.ereminsolenikov@linaro.org
State New
Headers show
Series deprecated hints proposal | expand

Commit Message

Dmitry Eremin-Solenikov March 7, 2017, 11:52 a.m. UTC
The ODP_DEPRECATED macro uses the deprecated attribute which works only
for types and functions, but not e.g. for fields of structure. So let's
add ODP_DEPRECATED_FIELD macro suitable for fields, variables and enum
values.

Also make ODP_DEPRECATED{,_FIELD} macros to be a no-op if
ODP_ALLOW_DEPRECATED is defined. ODP code MUST be compiled with this
macro, so that it supports deprecated API. Examples SHOULD be compiled
without this macro defined, so that they show best current practice of
using API but still MAY use the macro untill particular application is
ported to new API. User applications SHOULD try to compile without
ODP_ALLOW_DEPRECATED macro defined.

Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>

---
 doc/helper-guide/Doxyfile          |  1 +
 doc/platform-api-guide/Doxyfile    |  1 +
 helper/Makefile.am                 |  1 +
 include/odp/api/spec/hints.h       | 13 +++++++++++++
 platform/linux-generic/Makefile.am |  1 +
 5 files changed, 17 insertions(+)

-- 
2.11.0

Comments

Dmitry Eremin-Solenikov March 8, 2017, 12:24 a.m. UTC | #1
On 07.03.2017 14:52, Dmitry Eremin-Solenikov wrote:
> diff --git a/include/odp/api/spec/hints.h b/include/odp/api/spec/hints.h

> index 82400f07..3b70db6f 100644

> --- a/include/odp/api/spec/hints.h

> +++ b/include/odp/api/spec/hints.h

> @@ -54,7 +54,20 @@ extern "C" {

>  /**

>   * Indicate deprecated variables, functions or types

>   */

> +#ifdef ODP_ALLOW_DEPRECATED


It should be #ifndef obviously, forgot to change.

>  #define ODP_DEPRECATED __attribute__((__deprecated__))

> +#else

> +#define ODP_DEPRECATED

> +#endif

> +

> +/**

> + * Indicate deprecated field, bitfield or enum value

> + */

> +#ifndef ODP_ALLOW_DEPRECATED

> +#define ODP_DEPRECATED_FIELD(x) __odp_deprecated_ ## x

> +#else

> +#define ODP_DEPRECATED_FIELD(x) x

> +#endif



-- 
With best wishes
Dmitry
diff mbox series

Patch

diff --git a/doc/helper-guide/Doxyfile b/doc/helper-guide/Doxyfile
index bcc24539..62c1f862 100644
--- a/doc/helper-guide/Doxyfile
+++ b/doc/helper-guide/Doxyfile
@@ -40,6 +40,7 @@  PREDEFINED = __GNUC__ \
 	     __LITTLE_ENDIAN_BITFIELD \
 	     __x86_64__ \
 	     ODP_PACKED \
+	     ODP_DEPRECATED_FIELD(x)=x \
 	     "ODP_HANDLE_T(type)=odp_handle_t type"
 INTERNAL_DOCS = YES
 DOT_IMAGE_FORMAT = svg
diff --git a/doc/platform-api-guide/Doxyfile b/doc/platform-api-guide/Doxyfile
index fbe7c936..37175e09 100644
--- a/doc/platform-api-guide/Doxyfile
+++ b/doc/platform-api-guide/Doxyfile
@@ -17,4 +17,5 @@  PREDEFINED = __GNUC__ \
 	     __LITTLE_ENDIAN_BITFIELD \
 	     __x86_64__ \
 	     ODP_PACKED \
+	     ODP_DEPRECATED_FIELD(x)=x \
 	     "ODP_HANDLE_T(type)=odp_handle_t type"
diff --git a/helper/Makefile.am b/helper/Makefile.am
index 2c5452dc..3bd38a46 100644
--- a/helper/Makefile.am
+++ b/helper/Makefile.am
@@ -10,6 +10,7 @@  AM_CFLAGS += -I$(top_srcdir)/include
 AM_CFLAGS += -I$(top_srcdir)/include/odp/arch/@ARCH_ABI@
 AM_CFLAGS += -I$(top_builddir)/platform/@with_platform@/include
 AM_CFLAGS += -I$(top_builddir)/include
+AM_CFLAGS += -DODP_ALLOW_DEPRECATED
 
 AM_LDFLAGS += -version-number '$(ODPHELPER_LIBSO_VERSION)'
 
diff --git a/include/odp/api/spec/hints.h b/include/odp/api/spec/hints.h
index 82400f07..3b70db6f 100644
--- a/include/odp/api/spec/hints.h
+++ b/include/odp/api/spec/hints.h
@@ -54,7 +54,20 @@  extern "C" {
 /**
  * Indicate deprecated variables, functions or types
  */
+#ifdef ODP_ALLOW_DEPRECATED
 #define ODP_DEPRECATED __attribute__((__deprecated__))
+#else
+#define ODP_DEPRECATED
+#endif
+
+/**
+ * Indicate deprecated field, bitfield or enum value
+ */
+#ifndef ODP_ALLOW_DEPRECATED
+#define ODP_DEPRECATED_FIELD(x) __odp_deprecated_ ## x
+#else
+#define ODP_DEPRECATED_FIELD(x) x
+#endif
 
 /**
  * Intentionally unused variables of functions
diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am
index b21df449..800bf5e8 100644
--- a/platform/linux-generic/Makefile.am
+++ b/platform/linux-generic/Makefile.am
@@ -10,6 +10,7 @@  AM_CFLAGS +=  -I$(top_srcdir)/include/odp/arch/@ARCH_ABI@
 AM_CFLAGS +=  -I$(top_builddir)/include
 AM_CFLAGS +=  -Iinclude
 AM_CFLAGS +=  -DSYSCONFDIR=\"@sysconfdir@\"
+AM_CFLAGS +=  -DODP_ALLOW_DEPRECATED
 
 include_HEADERS = \
 		  $(top_srcdir)/include/odp.h \