[dpdk-dev,v5,2/4] eal: move gcc version definition to common header

Message ID 20170512101535.7221-3-ashwin.sekhar@caviumnetworks.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Ashwin Sekhar T K May 12, 2017, 10:15 a.m. UTC
  Moved the definition of GCC_VERSION from lib/librte_table/rte_lru.h
to lib/librte_eal/common/include/rte_common.h.

Tested compilation on:
 * arm64 with gcc
 * x86 with gcc and clang

Signed-off-by: Ashwin Sekhar T K <ashwin.sekhar@caviumnetworks.com>
Reviewed-by: Jan Viktorin <viktorin@rehivetech.com>
---
 lib/librte_eal/common/include/rte_common.h |  6 ++++++
 lib/librte_table/rte_lru.h                 | 10 ++--------
 2 files changed, 8 insertions(+), 8 deletions(-)
  

Comments

Jianbo Liu May 15, 2017, 2:07 a.m. UTC | #1
On 12 May 2017 at 18:15, Ashwin Sekhar T K
<ashwin.sekhar@caviumnetworks.com> wrote:
> Moved the definition of GCC_VERSION from lib/librte_table/rte_lru.h
> to lib/librte_eal/common/include/rte_common.h.
>
> Tested compilation on:
>  * arm64 with gcc
>  * x86 with gcc and clang
>
> Signed-off-by: Ashwin Sekhar T K <ashwin.sekhar@caviumnetworks.com>
> Reviewed-by: Jan Viktorin <viktorin@rehivetech.com>
> ---
>  lib/librte_eal/common/include/rte_common.h |  6 ++++++
>  lib/librte_table/rte_lru.h                 | 10 ++--------
>  2 files changed, 8 insertions(+), 8 deletions(-)
>

Acked-by: Jianbo Liu <jianbo.liu@linaro.org>
  
Thomas Monjalon July 3, 2017, 8:51 p.m. UTC | #2
12/05/2017 12:15, Ashwin Sekhar T K:
> Moved the definition of GCC_VERSION from lib/librte_table/rte_lru.h
> to lib/librte_eal/common/include/rte_common.h.
> 
> Tested compilation on:
>  * arm64 with gcc
>  * x86 with gcc and clang
> 
> Signed-off-by: Ashwin Sekhar T K <ashwin.sekhar@caviumnetworks.com>
> Reviewed-by: Jan Viktorin <viktorin@rehivetech.com>
> ---
> --- a/lib/librte_eal/common/include/rte_common.h
> +++ b/lib/librte_eal/common/include/rte_common.h
> +/** Define GCC_VERSION **/
> +#ifdef RTE_TOOLCHAIN_GCC
> +#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 +	\
> +		__GNUC_PATCHLEVEL__)
> +#endif
[...]
> --- a/lib/librte_table/rte_lru.h
> +++ b/lib/librte_table/rte_lru.h
> -#ifdef __INTEL_COMPILER
> -#define GCC_VERSION (0)
> -#else
> -#define GCC_VERSION (__GNUC__ * 10000+__GNUC_MINOR__*100 + __GNUC_PATCHLEVEL__)
> -#endif

The ICC check is lost when moving in rte_common.h.
  
Sekhar, Ashwin July 4, 2017, 8:48 a.m. UTC | #3
On Mon, 2017-07-03 at 22:51 +0200, Thomas Monjalon wrote:
> 12/05/2017 12:15, Ashwin Sekhar T K:

> > 

> > Moved the definition of GCC_VERSION from lib/librte_table/rte_lru.h

> > to lib/librte_eal/common/include/rte_common.h.

> > 

> > Tested compilation on:

> >  * arm64 with gcc

> >  * x86 with gcc and clang

> > 

> > Signed-off-by: Ashwin Sekhar T K <ashwin.sekhar@caviumnetworks.com>

> > Reviewed-by: Jan Viktorin <viktorin@rehivetech.com>

> > ---

> > --- a/lib/librte_eal/common/include/rte_common.h

> > +++ b/lib/librte_eal/common/include/rte_common.h

> > +/** Define GCC_VERSION **/

> > +#ifdef RTE_TOOLCHAIN_GCC

> > +#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 +	

> > \

> > +		__GNUC_PATCHLEVEL__)

> > +#endif

> [...]

> > 

> > --- a/lib/librte_table/rte_lru.h

> > +++ b/lib/librte_table/rte_lru.h

> > -#ifdef __INTEL_COMPILER

> > -#define GCC_VERSION (0)

> > -#else

> > -#define GCC_VERSION (__GNUC__ * 10000+__GNUC_MINOR__*100 +

> > __GNUC_PATCHLEVEL__)

> > -#endif

> The ICC check is lost when moving in rte_common.h.


All usage of GCC_VERSION is kept under #ifdef RTE_TOOLCHAIN_GCC. So the
ICC check is not required.

Ashwin
  

Patch

diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h
index e057f6e21..ff4a12bbe 100644
--- a/lib/librte_eal/common/include/rte_common.h
+++ b/lib/librte_eal/common/include/rte_common.h
@@ -66,6 +66,12 @@  extern "C" {
 #define RTE_STD_C11
 #endif
 
+/** Define GCC_VERSION **/
+#ifdef RTE_TOOLCHAIN_GCC
+#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 +	\
+		__GNUC_PATCHLEVEL__)
+#endif
+
 #ifdef RTE_ARCH_STRICT_ALIGN
 typedef uint64_t unaligned_uint64_t __attribute__ ((aligned(1)));
 typedef uint32_t unaligned_uint32_t __attribute__ ((aligned(1)));
diff --git a/lib/librte_table/rte_lru.h b/lib/librte_table/rte_lru.h
index e87e062d0..5cc596613 100644
--- a/lib/librte_table/rte_lru.h
+++ b/lib/librte_table/rte_lru.h
@@ -40,12 +40,6 @@  extern "C" {
 
 #include <stdint.h>
 
-#ifdef __INTEL_COMPILER
-#define GCC_VERSION (0)
-#else
-#define GCC_VERSION (__GNUC__ * 10000+__GNUC_MINOR__*100 + __GNUC_PATCHLEVEL__)
-#endif
-
 #ifndef RTE_TABLE_HASH_LRU_STRATEGY
 #ifdef __SSE4_2__
 #define RTE_TABLE_HASH_LRU_STRATEGY                        2
@@ -120,7 +114,7 @@  do {									\
 
 #elif RTE_TABLE_HASH_LRU_STRATEGY == 2
 
-#if GCC_VERSION > 40306
+#if defined(RTE_TOOLCHAIN_GCC) && (GCC_VERSION > 40306)
 #include <x86intrin.h>
 #else
 #include <emmintrin.h>
@@ -166,7 +160,7 @@  do {									\
 
 #elif RTE_TABLE_HASH_LRU_STRATEGY == 3
 
-#if GCC_VERSION > 40306
+#if defined(RTE_TOOLCHAIN_GCC) && (GCC_VERSION > 40306)
 #include <x86intrin.h>
 #else
 #include <emmintrin.h>