diff mbox

[rdma-core] verbs: Fix C++ compilation break

Message ID 537d72a7-19c3-d13d-4b49-538744a73845@suse.de (mailing list archive)
State Rejected
Headers show

Commit Message

Nicolas Morey-Chaisemartin Oct. 9, 2017, 1:12 p.m. UTC
Le 09/10/2017 à 10:17, Leon Romanovsky a écrit :
> From: Leon Romanovsky <leonro@mellanox.com>
>
> The commit 983f80191923 ("verbs: fix compilation error with ICC") fixed
> warning by using UINTPTR_MAX, however such change breaks compilation
> of C++ applications.
>
> In C++ world, the UINTPTR_MAX is declared in <cstdint> and not stdint.h,
> so in order to avoid messing with various defines to decide which header
> file include: stdint.h or <cstdint>, we will check for the existence
> of UINTPTR_MAX and will fallback to old implementation.
>
> Fixes: 983f80191923 ("verbs: fix compilation error with ICC")
> Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
> Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
> Cc: Adrien Mazarguil <adrien.mazarguil@6wind.com>
> Cc: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
> ---
>  libibverbs/verbs.h | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/libibverbs/verbs.h b/libibverbs/verbs.h
> index cc633a12..f540b660 100644
> --- a/libibverbs/verbs.h
> +++ b/libibverbs/verbs.h
> @@ -82,7 +82,11 @@ union ibv_gid {
>
>  #define vext_field_avail(type, fld, sz) (offsetof(type, fld) < (sz))
>
> +#ifdef UINTPTR_MAX
>  static void *__VERBS_ABI_IS_EXTENDED = (void *)UINTPTR_MAX;
> +#else
> +static void *__VERBS_ABI_IS_EXTENDED = ((uint8_t *) NULL) - 1;
> +#endif
>
>  enum ibv_node_type {
>  	IBV_NODE_UNKNOWN	= -1,
> --
> 2.14.2
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
Wouldn't something like this solve the issue without messing up the code ?


--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Leon Romanovsky Oct. 9, 2017, 1:38 p.m. UTC | #1
On Mon, Oct 09, 2017 at 03:12:00PM +0200, Nicolas Morey-Chaisemartin wrote:
>
>
> Le 09/10/2017 à 10:17, Leon Romanovsky a écrit :
> > From: Leon Romanovsky <leonro@mellanox.com>
> >
> > The commit 983f80191923 ("verbs: fix compilation error with ICC") fixed
> > warning by using UINTPTR_MAX, however such change breaks compilation
> > of C++ applications.
> >
> > In C++ world, the UINTPTR_MAX is declared in <cstdint> and not stdint.h,
> > so in order to avoid messing with various defines to decide which header
> > file include: stdint.h or <cstdint>, we will check for the existence
> > of UINTPTR_MAX and will fallback to old implementation.
> >
> > Fixes: 983f80191923 ("verbs: fix compilation error with ICC")
> > Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
> > Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
> > Cc: Adrien Mazarguil <adrien.mazarguil@6wind.com>
> > Cc: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
> > ---
> >  libibverbs/verbs.h | 4 ++++
> >  1 file changed, 4 insertions(+)
> >
> > diff --git a/libibverbs/verbs.h b/libibverbs/verbs.h
> > index cc633a12..f540b660 100644
> > --- a/libibverbs/verbs.h
> > +++ b/libibverbs/verbs.h
> > @@ -82,7 +82,11 @@ union ibv_gid {
> >
> >  #define vext_field_avail(type, fld, sz) (offsetof(type, fld) < (sz))
> >
> > +#ifdef UINTPTR_MAX
> >  static void *__VERBS_ABI_IS_EXTENDED = (void *)UINTPTR_MAX;
> > +#else
> > +static void *__VERBS_ABI_IS_EXTENDED = ((uint8_t *) NULL) - 1;
> > +#endif
> >
> >  enum ibv_node_type {
> >  	IBV_NODE_UNKNOWN	= -1,
> > --
> > 2.14.2
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Wouldn't something like this solve the issue without messing up the code ?
>
> diff --git a/libibverbs/verbs.h b/libibverbs/verbs.h
> index 8cdf8ab5..c5d932bf 100644
> --- a/libibverbs/verbs.h
> +++ b/libibverbs/verbs.h
> @@ -44,6 +44,7 @@
>  #include <linux/types.h>
>  
>  #ifdef __cplusplus
> +#include  <cstdint>
>  #  define BEGIN_C_DECLS extern "C" {
>  #  define END_C_DECLS   }
>  #else /* !__cplusplus */
>

It will be enough, I'll resend the patch.

Thanks
diff mbox

Patch

diff --git a/libibverbs/verbs.h b/libibverbs/verbs.h
index 8cdf8ab5..c5d932bf 100644
--- a/libibverbs/verbs.h
+++ b/libibverbs/verbs.h
@@ -44,6 +44,7 @@ 
 #include <linux/types.h>
 
 #ifdef __cplusplus
+#include  <cstdint>
 #  define BEGIN_C_DECLS extern "C" {
 #  define END_C_DECLS   }
 #else /* !__cplusplus */