diff mbox

[3/3] debug: Convert ODP_ASSERT to a runtime assertion

Message ID 1405963033-29230-4-git-send-email-taras.kondratiuk@linaro.org
State Accepted
Commit f9c3c07126c2d91e671464450cceb9c389a13cc9
Headers show

Commit Message

Taras Kondratiuk July 21, 2014, 5:17 p.m. UTC
Accordingly to architecture document this should be a runtime
assertion and call abort() in case of failure.

Signed-off-by: Taras Kondratiuk <taras.kondratiuk@linaro.org>
---
 include/odp_debug.h |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Anders Roxell July 22, 2014, 8:57 p.m. UTC | #1
On 2014-07-21 20:17, Taras Kondratiuk wrote:
> Accordingly to architecture document this should be a runtime
> assertion and call abort() in case of failure.
> 
> Signed-off-by: Taras Kondratiuk <taras.kondratiuk@linaro.org>

Reviewed-by: Anders Roxell <anders.roxell@linaro.org>

> ---
>  include/odp_debug.h |    9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/include/odp_debug.h b/include/odp_debug.h
> index edc775f..9a5ea2a 100644
> --- a/include/odp_debug.h
> +++ b/include/odp_debug.h
> @@ -38,9 +38,14 @@ extern "C" {
>  #endif
>  
>  /**
> - * Compile time assertion-macro - fail compilation if cond is false.
> + * Runtime assertion-macro - aborts if 'cond' is false.
>   */
> -#define ODP_ASSERT(cond, msg)  typedef char msg[(cond) ? 1 : -1]
> +#ifndef ODP_NO_DEBUG
> +#define ODP_ASSERT(cond, msg) \
> +	do { if (!(cond)) {ODP_ERR("%s\n", msg); abort(); } } while (0)
> +#else
> +#define ODP_ASSERT(cond, msg)
> +#endif
>  
>  /**
>   * Compile time assertion-macro - fail compilation if cond is false.
> -- 
> 1.7.9.5
> 
> 
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
Mike Holmes July 22, 2014, 9:13 p.m. UTC | #2
Tested-by: Mike Holmes <mike.holmes@linaro.org>


On 22 July 2014 16:57, Anders Roxell <anders.roxell@linaro.org> wrote:

> On 2014-07-21 20:17, Taras Kondratiuk wrote:
> > Accordingly to architecture document this should be a runtime
> > assertion and call abort() in case of failure.
> >
> > Signed-off-by: Taras Kondratiuk <taras.kondratiuk@linaro.org>
>
> Reviewed-by: Anders Roxell <anders.roxell@linaro.org>
>
> > ---
> >  include/odp_debug.h |    9 +++++++--
> >  1 file changed, 7 insertions(+), 2 deletions(-)
> >
> > diff --git a/include/odp_debug.h b/include/odp_debug.h
> > index edc775f..9a5ea2a 100644
> > --- a/include/odp_debug.h
> > +++ b/include/odp_debug.h
> > @@ -38,9 +38,14 @@ extern "C" {
> >  #endif
> >
> >  /**
> > - * Compile time assertion-macro - fail compilation if cond is false.
> > + * Runtime assertion-macro - aborts if 'cond' is false.
> >   */
> > -#define ODP_ASSERT(cond, msg)  typedef char msg[(cond) ? 1 : -1]
> > +#ifndef ODP_NO_DEBUG
> > +#define ODP_ASSERT(cond, msg) \
> > +     do { if (!(cond)) {ODP_ERR("%s\n", msg); abort(); } } while (0)
> > +#else
> > +#define ODP_ASSERT(cond, msg)
> > +#endif
> >
> >  /**
> >   * Compile time assertion-macro - fail compilation if cond is false.
> > --
> > 1.7.9.5
> >
> >
> > _______________________________________________
> > lng-odp mailing list
> > lng-odp@lists.linaro.org
> > http://lists.linaro.org/mailman/listinfo/lng-odp
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
>
diff mbox

Patch

diff --git a/include/odp_debug.h b/include/odp_debug.h
index edc775f..9a5ea2a 100644
--- a/include/odp_debug.h
+++ b/include/odp_debug.h
@@ -38,9 +38,14 @@  extern "C" {
 #endif
 
 /**
- * Compile time assertion-macro - fail compilation if cond is false.
+ * Runtime assertion-macro - aborts if 'cond' is false.
  */
-#define ODP_ASSERT(cond, msg)  typedef char msg[(cond) ? 1 : -1]
+#ifndef ODP_NO_DEBUG
+#define ODP_ASSERT(cond, msg) \
+	do { if (!(cond)) {ODP_ERR("%s\n", msg); abort(); } } while (0)
+#else
+#define ODP_ASSERT(cond, msg)
+#endif
 
 /**
  * Compile time assertion-macro - fail compilation if cond is false.