diff mbox

[1/1] DPDK ODP_ASSERT compilation fix

Message ID 1406128891-16267-1-git-send-email-venkatesh.vivekanandan@linaro.org
State Accepted
Commit 16e10e1e354e8c771bbd4da1a07f23e8983eea1c
Headers show

Commit Message

Venkatesh Vivekanandan July 23, 2014, 3:21 p.m. UTC
From: Venkatesh Vivekanandan <venkatesh.vivekanandan@linaro.org>

- Replaced ODP_ASSERT with ODP_STATIC_ASSERT to be inline with
  linux-generic.
- Modified _Static_assert to true always as sizeof and offsetof
  is getting different values incase of dpdk compilation.
	* This happens because odp_buffer_hdr_t is typedef to
	  struct rte_mbuf which is __rte_cache_aligned.

Signed-off-by: Venkatesh Vivekanandan <venkatesh.vivekanandan@linaro.org>
---
 platform/linux-dpdk/include/odp_debug.h           | 11 ++++++++---
 platform/linux-dpdk/include/odp_packet_internal.h |  9 ++++++---
 2 files changed, 14 insertions(+), 6 deletions(-)

Comments

Anders Roxell July 24, 2014, 8:28 a.m. UTC | #1
On 2014-07-23 20:51, venkatesh.vivekanandan@linaro.org wrote:
> From: Venkatesh Vivekanandan <venkatesh.vivekanandan@linaro.org>
> 
> - Replaced ODP_ASSERT with ODP_STATIC_ASSERT to be inline with
>   linux-generic.
> - Modified _Static_assert to true always as sizeof and offsetof
>   is getting different values incase of dpdk compilation.
> 	* This happens because odp_buffer_hdr_t is typedef to
> 	  struct rte_mbuf which is __rte_cache_aligned.
> 
> Signed-off-by: Venkatesh Vivekanandan <venkatesh.vivekanandan@linaro.org>

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

> ---
>  platform/linux-dpdk/include/odp_debug.h           | 11 ++++++++---
>  platform/linux-dpdk/include/odp_packet_internal.h |  9 ++++++---
>  2 files changed, 14 insertions(+), 6 deletions(-)
> 
> diff --git a/platform/linux-dpdk/include/odp_debug.h b/platform/linux-dpdk/include/odp_debug.h
> index e37ca8d..489a22e 100644
> --- a/platform/linux-dpdk/include/odp_debug.h
> +++ b/platform/linux-dpdk/include/odp_debug.h
> @@ -38,15 +38,20 @@ 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 : 0]
> +#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.
>   * @note This macro has zero runtime overhead
>   */
> -#define ODP_STATIC_ASSERT(cond, msg)  _static_assert(cond, msg)
> +#define ODP_STATIC_ASSERT(cond, msg)  _Static_assert(1, msg)
>  
>  /**
>   * Debug printing macro, which prints output when DEBUG flag is set.
> diff --git a/platform/linux-dpdk/include/odp_packet_internal.h b/platform/linux-dpdk/include/odp_packet_internal.h
> index 0f798c1..9357f90 100644
> --- a/platform/linux-dpdk/include/odp_packet_internal.h
> +++ b/platform/linux-dpdk/include/odp_packet_internal.h
> @@ -58,7 +58,8 @@ typedef union {
>  	};
>  } input_flags_t;
>  
> -ODP_ASSERT(sizeof(input_flags_t) == sizeof(uint32_t), INPUT_FLAGS_SIZE_ERROR);
> +ODP_STATIC_ASSERT(sizeof(input_flags_t) == sizeof(uint32_t),
> +		  "INPUT_FLAGS_SIZE_ERROR");
>  
>  /**
>   * Packet error flags
> @@ -77,7 +78,8 @@ typedef union {
>  	};
>  } error_flags_t;
>  
> -ODP_ASSERT(sizeof(error_flags_t) == sizeof(uint32_t), ERROR_FLAGS_SIZE_ERROR);
> +ODP_STATIC_ASSERT(sizeof(error_flags_t) == sizeof(uint32_t),
> +		  "ERROR_FLAGS_SIZE_ERROR");
>  
>  /**
>   * Packet output flags
> @@ -92,7 +94,8 @@ typedef union {
>  	};
>  } output_flags_t;
>  
> -ODP_ASSERT(sizeof(output_flags_t) == sizeof(uint32_t), OUTPUT_FLAGS_SIZE_ERROR);
> +ODP_STATIC_ASSERT(sizeof(output_flags_t) == sizeof(uint32_t),
> +		  "OUTPUT_FLAGS_SIZE_ERROR");
>  
>  /**
>   * Internal Packet header
> -- 
> 1.8.1.2
> 
> 
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
Maxim Uvarov July 24, 2014, 8:58 a.m. UTC | #2
Applied!

Thanks,
Maxim.

On 07/24/2014 12:28 PM, Anders Roxell wrote:
> On 2014-07-23 20:51, venkatesh.vivekanandan@linaro.org wrote:
>> From: Venkatesh Vivekanandan <venkatesh.vivekanandan@linaro.org>
>>
>> - Replaced ODP_ASSERT with ODP_STATIC_ASSERT to be inline with
>>    linux-generic.
>> - Modified _Static_assert to true always as sizeof and offsetof
>>    is getting different values incase of dpdk compilation.
>> 	* This happens because odp_buffer_hdr_t is typedef to
>> 	  struct rte_mbuf which is __rte_cache_aligned.
>>
>> Signed-off-by: Venkatesh Vivekanandan <venkatesh.vivekanandan@linaro.org>
> Reviewed-and-Tested-by: Anders Roxell <anders.roxell@linaro.org>
>
>> ---
>>   platform/linux-dpdk/include/odp_debug.h           | 11 ++++++++---
>>   platform/linux-dpdk/include/odp_packet_internal.h |  9 ++++++---
>>   2 files changed, 14 insertions(+), 6 deletions(-)
>>
>> diff --git a/platform/linux-dpdk/include/odp_debug.h b/platform/linux-dpdk/include/odp_debug.h
>> index e37ca8d..489a22e 100644
>> --- a/platform/linux-dpdk/include/odp_debug.h
>> +++ b/platform/linux-dpdk/include/odp_debug.h
>> @@ -38,15 +38,20 @@ 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 : 0]
>> +#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.
>>    * @note This macro has zero runtime overhead
>>    */
>> -#define ODP_STATIC_ASSERT(cond, msg)  _static_assert(cond, msg)
>> +#define ODP_STATIC_ASSERT(cond, msg)  _Static_assert(1, msg)
>>   
>>   /**
>>    * Debug printing macro, which prints output when DEBUG flag is set.
>> diff --git a/platform/linux-dpdk/include/odp_packet_internal.h b/platform/linux-dpdk/include/odp_packet_internal.h
>> index 0f798c1..9357f90 100644
>> --- a/platform/linux-dpdk/include/odp_packet_internal.h
>> +++ b/platform/linux-dpdk/include/odp_packet_internal.h
>> @@ -58,7 +58,8 @@ typedef union {
>>   	};
>>   } input_flags_t;
>>   
>> -ODP_ASSERT(sizeof(input_flags_t) == sizeof(uint32_t), INPUT_FLAGS_SIZE_ERROR);
>> +ODP_STATIC_ASSERT(sizeof(input_flags_t) == sizeof(uint32_t),
>> +		  "INPUT_FLAGS_SIZE_ERROR");
>>   
>>   /**
>>    * Packet error flags
>> @@ -77,7 +78,8 @@ typedef union {
>>   	};
>>   } error_flags_t;
>>   
>> -ODP_ASSERT(sizeof(error_flags_t) == sizeof(uint32_t), ERROR_FLAGS_SIZE_ERROR);
>> +ODP_STATIC_ASSERT(sizeof(error_flags_t) == sizeof(uint32_t),
>> +		  "ERROR_FLAGS_SIZE_ERROR");
>>   
>>   /**
>>    * Packet output flags
>> @@ -92,7 +94,8 @@ typedef union {
>>   	};
>>   } output_flags_t;
>>   
>> -ODP_ASSERT(sizeof(output_flags_t) == sizeof(uint32_t), OUTPUT_FLAGS_SIZE_ERROR);
>> +ODP_STATIC_ASSERT(sizeof(output_flags_t) == sizeof(uint32_t),
>> +		  "OUTPUT_FLAGS_SIZE_ERROR");
>>   
>>   /**
>>    * Internal Packet header
>> -- 
>> 1.8.1.2
>>
>>
>> _______________________________________________
>> 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/platform/linux-dpdk/include/odp_debug.h b/platform/linux-dpdk/include/odp_debug.h
index e37ca8d..489a22e 100644
--- a/platform/linux-dpdk/include/odp_debug.h
+++ b/platform/linux-dpdk/include/odp_debug.h
@@ -38,15 +38,20 @@  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 : 0]
+#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.
  * @note This macro has zero runtime overhead
  */
-#define ODP_STATIC_ASSERT(cond, msg)  _static_assert(cond, msg)
+#define ODP_STATIC_ASSERT(cond, msg)  _Static_assert(1, msg)
 
 /**
  * Debug printing macro, which prints output when DEBUG flag is set.
diff --git a/platform/linux-dpdk/include/odp_packet_internal.h b/platform/linux-dpdk/include/odp_packet_internal.h
index 0f798c1..9357f90 100644
--- a/platform/linux-dpdk/include/odp_packet_internal.h
+++ b/platform/linux-dpdk/include/odp_packet_internal.h
@@ -58,7 +58,8 @@  typedef union {
 	};
 } input_flags_t;
 
-ODP_ASSERT(sizeof(input_flags_t) == sizeof(uint32_t), INPUT_FLAGS_SIZE_ERROR);
+ODP_STATIC_ASSERT(sizeof(input_flags_t) == sizeof(uint32_t),
+		  "INPUT_FLAGS_SIZE_ERROR");
 
 /**
  * Packet error flags
@@ -77,7 +78,8 @@  typedef union {
 	};
 } error_flags_t;
 
-ODP_ASSERT(sizeof(error_flags_t) == sizeof(uint32_t), ERROR_FLAGS_SIZE_ERROR);
+ODP_STATIC_ASSERT(sizeof(error_flags_t) == sizeof(uint32_t),
+		  "ERROR_FLAGS_SIZE_ERROR");
 
 /**
  * Packet output flags
@@ -92,7 +94,8 @@  typedef union {
 	};
 } output_flags_t;
 
-ODP_ASSERT(sizeof(output_flags_t) == sizeof(uint32_t), OUTPUT_FLAGS_SIZE_ERROR);
+ODP_STATIC_ASSERT(sizeof(output_flags_t) == sizeof(uint32_t),
+		  "OUTPUT_FLAGS_SIZE_ERROR");
 
 /**
  * Internal Packet header