linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] crypto: Fix build for clang
@ 2019-06-21  7:13 Mathieu Malaterre
  2019-06-21  7:29 ` Joel Stanley
  2019-06-21 19:55 ` [PATCH v2] lib/mpi: fix build with clang Mathieu Malaterre
  0 siblings, 2 replies; 6+ messages in thread
From: Mathieu Malaterre @ 2019-06-21  7:13 UTC (permalink / raw)
  To: Dmitry Kasatkin
  Cc: Mathieu Malaterre, Joel Stanley, Masahiro Yamada, linux-kernel

The header file `longlong.h` makes uses of GNU extensions, this trigger
an error when compiling this code with clang. Add a special flag to make
clang tolerate this syntax.

Silence the following warnings triggered using W=1:

    CC      lib/mpi/generic_mpih-mul1.o
  ../lib/mpi/generic_mpih-mul1.c:37:13: error: invalid use of a cast in a inline asm context requiring an l-value: remove the cast or build with
        -fheinous-gnu-extensions
                  umul_ppmm(prod_high, prod_low, s1_ptr[j], s2_limb);
                  ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ../lib/mpi/longlong.h:824:20: note: expanded from macro 'umul_ppmm'
          : "=r" ((USItype) ph) \
                  ~~~~~~~~~~^~

and

    CC      lib/mpi/generic_mpih-mul2.o
  ../lib/mpi/generic_mpih-mul2.c:36:13: error: invalid use of a cast in a inline asm context requiring an l-value: remove the cast or build with
        -fheinous-gnu-extensions
                  umul_ppmm(prod_high, prod_low, s1_ptr[j], s2_limb);
                  ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ../lib/mpi/longlong.h:824:20: note: expanded from macro 'umul_ppmm'
          : "=r" ((USItype) ph) \
                  ~~~~~~~~~~^~

  1 warning generated.
    CC      lib/mpi/generic_mpih-mul3.o
  ../lib/mpi/generic_mpih-mul3.c:36:13: error: invalid use of a cast in a inline asm context requiring an l-value: remove the cast or build with
        -fheinous-gnu-extensions
                  umul_ppmm(prod_high, prod_low, s1_ptr[j], s2_limb);
                  ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ../lib/mpi/longlong.h:824:20: note: expanded from macro 'umul_ppmm'
          : "=r" ((USItype) ph) \
                  ~~~~~~~~~~^~

Or even:

  ../lib/mpi/mpih-div.c:99:16: error: invalid use of a cast in a inline asm context requiring an l-value: remove the cast or build with -fheinous-gnu-extensions
                                  sub_ddmmss(n1, n0, n1, n0, d1, d0);
                                  ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~

Cc: Joel Stanley <joel@jms.id.au>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Mathieu Malaterre <malat@debian.org>
---
 lib/mpi/Makefile | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/lib/mpi/Makefile b/lib/mpi/Makefile
index d5874a7f5ff9..de4d96e988a3 100644
--- a/lib/mpi/Makefile
+++ b/lib/mpi/Makefile
@@ -5,6 +5,13 @@
 
 obj-$(CONFIG_MPILIB) = mpi.o
 
+ifdef CONFIG_CC_IS_CLANG
+CFLAGS_generic_mpih-mul1.o  += -fheinous-gnu-extensions
+CFLAGS_generic_mpih-mul2.o  += -fheinous-gnu-extensions
+CFLAGS_generic_mpih-mul3.o  += -fheinous-gnu-extensions
+CFLAGS_mpih-div.o  += -fheinous-gnu-extensions
+endif
+
 mpi-y = \
 	generic_mpih-lshift.o		\
 	generic_mpih-mul1.o		\
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] crypto: Fix build for clang
  2019-06-21  7:13 [PATCH] crypto: Fix build for clang Mathieu Malaterre
@ 2019-06-21  7:29 ` Joel Stanley
  2019-06-21  7:44   ` Mathieu Malaterre
  2019-06-21 19:55 ` [PATCH v2] lib/mpi: fix build with clang Mathieu Malaterre
  1 sibling, 1 reply; 6+ messages in thread
From: Joel Stanley @ 2019-06-21  7:29 UTC (permalink / raw)
  To: Mathieu Malaterre
  Cc: Dmitry Kasatkin, Masahiro Yamada, Linux Kernel Mailing List,
	Michael Ellerman, Segher Boessenkool

On Fri, 21 Jun 2019 at 07:13, Mathieu Malaterre <malat@debian.org> wrote:
>
> The header file `longlong.h` makes uses of GNU extensions, this trigger
> an error when compiling this code with clang. Add a special flag to make
> clang tolerate this syntax.

Another old copy of longlong.h in the kernel!

This looks similar to another clang related warnings I fixed in the
powerpc math-emu code. There's an updated version of these macros in
GCC, and we updated the kernel version to match the GCC version. Can
you see if a similar change would work here?

https://lore.kernel.org/linuxppc-dev/43BCRQ6ZqDz9s55@ozlabs.org/
https://git.kernel.org/torvalds/c/b682c8692442711684befe413cf93cf01c5324ea

Cheers,

Joel

>
> Silence the following warnings triggered using W=1:
>
>     CC      lib/mpi/generic_mpih-mul1.o
>   ../lib/mpi/generic_mpih-mul1.c:37:13: error: invalid use of a cast in a inline asm context requiring an l-value: remove the cast or build with
>         -fheinous-gnu-extensions
>                   umul_ppmm(prod_high, prod_low, s1_ptr[j], s2_limb);
>                   ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>   ../lib/mpi/longlong.h:824:20: note: expanded from macro 'umul_ppmm'
>           : "=r" ((USItype) ph) \
>                   ~~~~~~~~~~^~
>
> and
>
>     CC      lib/mpi/generic_mpih-mul2.o
>   ../lib/mpi/generic_mpih-mul2.c:36:13: error: invalid use of a cast in a inline asm context requiring an l-value: remove the cast or build with
>         -fheinous-gnu-extensions
>                   umul_ppmm(prod_high, prod_low, s1_ptr[j], s2_limb);
>                   ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>   ../lib/mpi/longlong.h:824:20: note: expanded from macro 'umul_ppmm'
>           : "=r" ((USItype) ph) \
>                   ~~~~~~~~~~^~
>
>   1 warning generated.
>     CC      lib/mpi/generic_mpih-mul3.o
>   ../lib/mpi/generic_mpih-mul3.c:36:13: error: invalid use of a cast in a inline asm context requiring an l-value: remove the cast or build with
>         -fheinous-gnu-extensions
>                   umul_ppmm(prod_high, prod_low, s1_ptr[j], s2_limb);
>                   ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>   ../lib/mpi/longlong.h:824:20: note: expanded from macro 'umul_ppmm'
>           : "=r" ((USItype) ph) \
>                   ~~~~~~~~~~^~
>
> Or even:
>
>   ../lib/mpi/mpih-div.c:99:16: error: invalid use of a cast in a inline asm context requiring an l-value: remove the cast or build with -fheinous-gnu-extensions
>                                   sub_ddmmss(n1, n0, n1, n0, d1, d0);
>                                   ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
>
> Cc: Joel Stanley <joel@jms.id.au>
> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
> Signed-off-by: Mathieu Malaterre <malat@debian.org>
> ---
>  lib/mpi/Makefile | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/lib/mpi/Makefile b/lib/mpi/Makefile
> index d5874a7f5ff9..de4d96e988a3 100644
> --- a/lib/mpi/Makefile
> +++ b/lib/mpi/Makefile
> @@ -5,6 +5,13 @@
>
>  obj-$(CONFIG_MPILIB) = mpi.o
>
> +ifdef CONFIG_CC_IS_CLANG
> +CFLAGS_generic_mpih-mul1.o  += -fheinous-gnu-extensions
> +CFLAGS_generic_mpih-mul2.o  += -fheinous-gnu-extensions
> +CFLAGS_generic_mpih-mul3.o  += -fheinous-gnu-extensions
> +CFLAGS_mpih-div.o  += -fheinous-gnu-extensions
> +endif
> +
>  mpi-y = \
>         generic_mpih-lshift.o           \
>         generic_mpih-mul1.o             \
> --
> 2.20.1
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] crypto: Fix build for clang
  2019-06-21  7:29 ` Joel Stanley
@ 2019-06-21  7:44   ` Mathieu Malaterre
  0 siblings, 0 replies; 6+ messages in thread
From: Mathieu Malaterre @ 2019-06-21  7:44 UTC (permalink / raw)
  To: Joel Stanley
  Cc: Dmitry Kasatkin, Masahiro Yamada, Linux Kernel Mailing List,
	Michael Ellerman, Segher Boessenkool

Joel,

On Fri, Jun 21, 2019 at 9:30 AM Joel Stanley <joel@jms.id.au> wrote:
>
> On Fri, 21 Jun 2019 at 07:13, Mathieu Malaterre <malat@debian.org> wrote:
> >
> > The header file `longlong.h` makes uses of GNU extensions, this trigger
> > an error when compiling this code with clang. Add a special flag to make
> > clang tolerate this syntax.
>
> Another old copy of longlong.h in the kernel!
>
> This looks similar to another clang related warnings I fixed in the
> powerpc math-emu code. There's an updated version of these macros in
> GCC, and we updated the kernel version to match the GCC version. Can
> you see if a similar change would work here?
>
> https://lore.kernel.org/linuxppc-dev/43BCRQ6ZqDz9s55@ozlabs.org/
> https://git.kernel.org/torvalds/c/b682c8692442711684befe413cf93cf01c5324ea

Great ! Thanks for the pointer. Looks like a much bettter solution in
the long term. Will try asap.

> Cheers,
>
> Joel
>
> >
> > Silence the following warnings triggered using W=1:
> >
> >     CC      lib/mpi/generic_mpih-mul1.o
> >   ../lib/mpi/generic_mpih-mul1.c:37:13: error: invalid use of a cast in a inline asm context requiring an l-value: remove the cast or build with
> >         -fheinous-gnu-extensions
> >                   umul_ppmm(prod_high, prod_low, s1_ptr[j], s2_limb);
> >                   ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >   ../lib/mpi/longlong.h:824:20: note: expanded from macro 'umul_ppmm'
> >           : "=r" ((USItype) ph) \
> >                   ~~~~~~~~~~^~
> >
> > and
> >
> >     CC      lib/mpi/generic_mpih-mul2.o
> >   ../lib/mpi/generic_mpih-mul2.c:36:13: error: invalid use of a cast in a inline asm context requiring an l-value: remove the cast or build with
> >         -fheinous-gnu-extensions
> >                   umul_ppmm(prod_high, prod_low, s1_ptr[j], s2_limb);
> >                   ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >   ../lib/mpi/longlong.h:824:20: note: expanded from macro 'umul_ppmm'
> >           : "=r" ((USItype) ph) \
> >                   ~~~~~~~~~~^~
> >
> >   1 warning generated.
> >     CC      lib/mpi/generic_mpih-mul3.o
> >   ../lib/mpi/generic_mpih-mul3.c:36:13: error: invalid use of a cast in a inline asm context requiring an l-value: remove the cast or build with
> >         -fheinous-gnu-extensions
> >                   umul_ppmm(prod_high, prod_low, s1_ptr[j], s2_limb);
> >                   ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >   ../lib/mpi/longlong.h:824:20: note: expanded from macro 'umul_ppmm'
> >           : "=r" ((USItype) ph) \
> >                   ~~~~~~~~~~^~
> >
> > Or even:
> >
> >   ../lib/mpi/mpih-div.c:99:16: error: invalid use of a cast in a inline asm context requiring an l-value: remove the cast or build with -fheinous-gnu-extensions
> >                                   sub_ddmmss(n1, n0, n1, n0, d1, d0);
> >                                   ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
> >
> > Cc: Joel Stanley <joel@jms.id.au>
> > Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
> > Signed-off-by: Mathieu Malaterre <malat@debian.org>
> > ---
> >  lib/mpi/Makefile | 7 +++++++
> >  1 file changed, 7 insertions(+)
> >
> > diff --git a/lib/mpi/Makefile b/lib/mpi/Makefile
> > index d5874a7f5ff9..de4d96e988a3 100644
> > --- a/lib/mpi/Makefile
> > +++ b/lib/mpi/Makefile
> > @@ -5,6 +5,13 @@
> >
> >  obj-$(CONFIG_MPILIB) = mpi.o
> >
> > +ifdef CONFIG_CC_IS_CLANG
> > +CFLAGS_generic_mpih-mul1.o  += -fheinous-gnu-extensions
> > +CFLAGS_generic_mpih-mul2.o  += -fheinous-gnu-extensions
> > +CFLAGS_generic_mpih-mul3.o  += -fheinous-gnu-extensions
> > +CFLAGS_mpih-div.o  += -fheinous-gnu-extensions
> > +endif
> > +
> >  mpi-y = \
> >         generic_mpih-lshift.o           \
> >         generic_mpih-mul1.o             \
> > --
> > 2.20.1
> >

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2] lib/mpi: fix build with clang
  2019-06-21  7:13 [PATCH] crypto: Fix build for clang Mathieu Malaterre
  2019-06-21  7:29 ` Joel Stanley
@ 2019-06-21 19:55 ` Mathieu Malaterre
  2019-06-25  4:03   ` Joel Stanley
  2019-06-25 18:15   ` Segher Boessenkool
  1 sibling, 2 replies; 6+ messages in thread
From: Mathieu Malaterre @ 2019-06-21 19:55 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: Mathieu Malaterre, Joel Stanley, Segher Boessenkool, linux-kernel

Remove superfluous casts on output operands to avoid warnings on the
following macros:

* add_ssaaaa(sh, sl, ah, al, bh, bl)
* sub_ddmmss(sh, sl, ah, al, bh, bl)
* umul_ppmm(ph, pl, m0, m1)

Special care has been taken to keep the diff as minimal as possible from
the original header file `longlong.h` from gcc, only importing the
minimal change to make the compilation with clang pass.

Silence the following warnings triggered using W=1:

    CC      lib/mpi/generic_mpih-mul1.o
  ../lib/mpi/generic_mpih-mul1.c:37:13: error: invalid use of a cast in a inline asm context requiring an l-value: remove the cast or build with
        -fheinous-gnu-extensions
                  umul_ppmm(prod_high, prod_low, s1_ptr[j], s2_limb);
                  ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ../lib/mpi/longlong.h:824:20: note: expanded from macro 'umul_ppmm'
          : "=r" ((USItype) ph) \
                  ~~~~~~~~~~^~

and

    CC      lib/mpi/generic_mpih-mul2.o
  ../lib/mpi/generic_mpih-mul2.c:36:13: error: invalid use of a cast in a inline asm context requiring an l-value: remove the cast or build with
        -fheinous-gnu-extensions
                  umul_ppmm(prod_high, prod_low, s1_ptr[j], s2_limb);
                  ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ../lib/mpi/longlong.h:824:20: note: expanded from macro 'umul_ppmm'
          : "=r" ((USItype) ph) \
                  ~~~~~~~~~~^~

  1 warning generated.
    CC      lib/mpi/generic_mpih-mul3.o
  ../lib/mpi/generic_mpih-mul3.c:36:13: error: invalid use of a cast in a inline asm context requiring an l-value: remove the cast or build with
        -fheinous-gnu-extensions
                  umul_ppmm(prod_high, prod_low, s1_ptr[j], s2_limb);
                  ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ../lib/mpi/longlong.h:824:20: note: expanded from macro 'umul_ppmm'
          : "=r" ((USItype) ph) \
                  ~~~~~~~~~~^~

Or even:

  ../lib/mpi/mpih-div.c:99:16: error: invalid use of a cast in a inline asm context requiring an l-value: remove the cast or build with -fheinous-gnu-extensions
                                  sub_ddmmss(n1, n0, n1, n0, d1, d0);
                                  ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~

Inspiration is taken from commit b682c8692442 ("powerpc/math-emu: Update
macros from GCC").

Suggested-by: Joel Stanley <joel@jms.id.au>
Cc: Segher Boessenkool <segher@kernel.crashing.org>
Signed-off-by: Mathieu Malaterre <malat@debian.org>
---
v2: Instead of passing compat flag to clang to behave as gcc, remove the superfluous cast

 lib/mpi/longlong.h | 105 +++++++++++++++------------------------------
 1 file changed, 35 insertions(+), 70 deletions(-)

diff --git a/lib/mpi/longlong.h b/lib/mpi/longlong.h
index 08c60d10747f..f5503dfa42ed 100644
--- a/lib/mpi/longlong.h
+++ b/lib/mpi/longlong.h
@@ -753,79 +753,44 @@ do {									\
 	***************************************/
 #if (defined(_ARCH_PPC) || defined(_IBMR2)) && W_TYPE_SIZE == 32
 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
-do { \
-	if (__builtin_constant_p(bh) && (bh) == 0) \
-		__asm__ ("{a%I4|add%I4c} %1,%3,%4\n\t{aze|addze} %0,%2" \
-		: "=r" ((USItype)(sh)), \
-		"=&r" ((USItype)(sl)) \
-		: "%r" ((USItype)(ah)), \
-		"%r" ((USItype)(al)), \
-		"rI" ((USItype)(bl))); \
-	else if (__builtin_constant_p(bh) && (bh) == ~(USItype) 0) \
-		__asm__ ("{a%I4|add%I4c} %1,%3,%4\n\t{ame|addme} %0,%2" \
-		: "=r" ((USItype)(sh)), \
-		"=&r" ((USItype)(sl)) \
-		: "%r" ((USItype)(ah)), \
-		"%r" ((USItype)(al)), \
-		"rI" ((USItype)(bl))); \
-	else \
-		__asm__ ("{a%I5|add%I5c} %1,%4,%5\n\t{ae|adde} %0,%2,%3" \
-		: "=r" ((USItype)(sh)), \
-		"=&r" ((USItype)(sl)) \
-		: "%r" ((USItype)(ah)), \
-		"r" ((USItype)(bh)), \
-		"%r" ((USItype)(al)), \
-		"rI" ((USItype)(bl))); \
-} while (0)
+  do {									\
+    if (__builtin_constant_p (bh) && (bh) == 0)				\
+      __asm__ ("add%I4c %1,%3,%4\n\taddze %0,%2"		\
+	     : "=r" (sh), "=&r" (sl) : "r" (ah), "%r" (al), "rI" (bl));\
+    else if (__builtin_constant_p (bh) && (bh) == ~(USItype) 0)		\
+      __asm__ ("add%I4c %1,%3,%4\n\taddme %0,%2"		\
+	     : "=r" (sh), "=&r" (sl) : "r" (ah), "%r" (al), "rI" (bl));\
+    else								\
+      __asm__ ("add%I5c %1,%4,%5\n\tadde %0,%2,%3"		\
+	     : "=r" (sh), "=&r" (sl)					\
+	     : "%r" (ah), "r" (bh), "%r" (al), "rI" (bl));		\
+  } while (0)
 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
-do { \
-	if (__builtin_constant_p(ah) && (ah) == 0) \
-		__asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{sfze|subfze} %0,%2" \
-		: "=r" ((USItype)(sh)), \
-		"=&r" ((USItype)(sl)) \
-		: "r" ((USItype)(bh)), \
-		"rI" ((USItype)(al)), \
-		"r" ((USItype)(bl))); \
-	else if (__builtin_constant_p(ah) && (ah) == ~(USItype) 0) \
-		__asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{sfme|subfme} %0,%2" \
-		: "=r" ((USItype)(sh)), \
-		"=&r" ((USItype)(sl)) \
-		: "r" ((USItype)(bh)), \
-		"rI" ((USItype)(al)), \
-		"r" ((USItype)(bl))); \
-	else if (__builtin_constant_p(bh) && (bh) == 0) \
-		__asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{ame|addme} %0,%2" \
-		: "=r" ((USItype)(sh)), \
-		"=&r" ((USItype)(sl)) \
-		: "r" ((USItype)(ah)), \
-		"rI" ((USItype)(al)), \
-		"r" ((USItype)(bl))); \
-	else if (__builtin_constant_p(bh) && (bh) == ~(USItype) 0) \
-		__asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{aze|addze} %0,%2" \
-		: "=r" ((USItype)(sh)), \
-		"=&r" ((USItype)(sl)) \
-		: "r" ((USItype)(ah)), \
-		"rI" ((USItype)(al)), \
-		"r" ((USItype)(bl))); \
-	else \
-		__asm__ ("{sf%I4|subf%I4c} %1,%5,%4\n\t{sfe|subfe} %0,%3,%2" \
-		: "=r" ((USItype)(sh)), \
-		"=&r" ((USItype)(sl)) \
-		: "r" ((USItype)(ah)), \
-		"r" ((USItype)(bh)), \
-		"rI" ((USItype)(al)), \
-		"r" ((USItype)(bl))); \
-} while (0)
+  do {									\
+    if (__builtin_constant_p (ah) && (ah) == 0)				\
+      __asm__ ("subf%I3c %1,%4,%3\n\tsubfze %0,%2"	\
+	       : "=r" (sh), "=&r" (sl) : "r" (bh), "rI" (al), "r" (bl));\
+    else if (__builtin_constant_p (ah) && (ah) == ~(USItype) 0)		\
+      __asm__ ("subf%I3c %1,%4,%3\n\tsubfme %0,%2"	\
+	       : "=r" (sh), "=&r" (sl) : "r" (bh), "rI" (al), "r" (bl));\
+    else if (__builtin_constant_p (bh) && (bh) == 0)			\
+      __asm__ ("subf%I3c %1,%4,%3\n\taddme %0,%2"		\
+	       : "=r" (sh), "=&r" (sl) : "r" (ah), "rI" (al), "r" (bl));\
+    else if (__builtin_constant_p (bh) && (bh) == ~(USItype) 0)		\
+      __asm__ ("subf%I3c %1,%4,%3\n\taddze %0,%2"		\
+	       : "=r" (sh), "=&r" (sl) : "r" (ah), "rI" (al), "r" (bl));\
+    else								\
+      __asm__ ("subf%I4c %1,%5,%4\n\tsubfe %0,%3,%2"	\
+	       : "=r" (sh), "=&r" (sl)					\
+	       : "r" (ah), "r" (bh), "rI" (al), "r" (bl));		\
+  } while (0)
 #if defined(_ARCH_PPC)
 #define umul_ppmm(ph, pl, m0, m1) \
-do { \
-	USItype __m0 = (m0), __m1 = (m1); \
-	__asm__ ("mulhwu %0,%1,%2" \
-	: "=r" ((USItype) ph) \
-	: "%r" (__m0), \
-	"r" (__m1)); \
-	(pl) = __m0 * __m1; \
-} while (0)
+  do {									\
+    USItype __m0 = (m0), __m1 = (m1);					\
+    __asm__ ("mulhwu %0,%1,%2" : "=r" (ph) : "%r" (m0), "r" (m1));	\
+    (pl) = __m0 * __m1;							\
+  } while (0)
 #define UMUL_TIME 15
 #define smul_ppmm(ph, pl, m0, m1) \
 do { \
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] lib/mpi: fix build with clang
  2019-06-21 19:55 ` [PATCH v2] lib/mpi: fix build with clang Mathieu Malaterre
@ 2019-06-25  4:03   ` Joel Stanley
  2019-06-25 18:15   ` Segher Boessenkool
  1 sibling, 0 replies; 6+ messages in thread
From: Joel Stanley @ 2019-06-25  4:03 UTC (permalink / raw)
  To: Mathieu Malaterre
  Cc: Michael Ellerman, Segher Boessenkool, Linux Kernel Mailing List

On Fri, 21 Jun 2019 at 19:56, Mathieu Malaterre <malat@debian.org> wrote:
>
> Remove superfluous casts on output operands to avoid warnings on the
> following macros:
>
> * add_ssaaaa(sh, sl, ah, al, bh, bl)
> * sub_ddmmss(sh, sl, ah, al, bh, bl)
> * umul_ppmm(ph, pl, m0, m1)
>
> Special care has been taken to keep the diff as minimal as possible from
> the original header file `longlong.h` from gcc, only importing the
> minimal change to make the compilation with clang pass.


> Suggested-by: Joel Stanley <joel@jms.id.au>
> Cc: Segher Boessenkool <segher@kernel.crashing.org>
> Signed-off-by: Mathieu Malaterre <malat@debian.org>
> ---
> v2: Instead of passing compat flag to clang to behave as gcc, remove the superfluous cast

Thanks, I checked your patch against GCC's longlong.h and it looks good.

Reviewed-by: Joel Stanley <joel@jms.id.au>

Cheers,

Joel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] lib/mpi: fix build with clang
  2019-06-21 19:55 ` [PATCH v2] lib/mpi: fix build with clang Mathieu Malaterre
  2019-06-25  4:03   ` Joel Stanley
@ 2019-06-25 18:15   ` Segher Boessenkool
  1 sibling, 0 replies; 6+ messages in thread
From: Segher Boessenkool @ 2019-06-25 18:15 UTC (permalink / raw)
  To: Mathieu Malaterre; +Cc: Michael Ellerman, Joel Stanley, linux-kernel

Hi Mathieu,

On Fri, Jun 21, 2019 at 09:55:54PM +0200, Mathieu Malaterre wrote:
> Remove superfluous casts on output operands to avoid warnings on the
> following macros:
> 
> * add_ssaaaa(sh, sl, ah, al, bh, bl)
> * sub_ddmmss(sh, sl, ah, al, bh, bl)
> * umul_ppmm(ph, pl, m0, m1)

The patch is fine of course, but you might want to look at not using
these asm macros at all: GCC can handle multi-word arithmetic just fine
by itself, probably better than these macros do even.


Segher

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-06-25 18:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-21  7:13 [PATCH] crypto: Fix build for clang Mathieu Malaterre
2019-06-21  7:29 ` Joel Stanley
2019-06-21  7:44   ` Mathieu Malaterre
2019-06-21 19:55 ` [PATCH v2] lib/mpi: fix build with clang Mathieu Malaterre
2019-06-25  4:03   ` Joel Stanley
2019-06-25 18:15   ` Segher Boessenkool

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).