All of lore.kernel.org
 help / color / mirror / Atom feed
* V4L2: __ucmpdi2 undefined on ppc
@ 2006-12-13 12:11 Meelis Roos
  2006-12-13 12:59 ` Paweł Sikora
  2006-12-13 23:41 ` Mauro Carvalho Chehab
  0 siblings, 2 replies; 16+ messages in thread
From: Meelis Roos @ 2006-12-13 12:11 UTC (permalink / raw)
  To: Linux Kernel list

  MODPOST 618 modules
WARNING: "__ucmpdi2" [drivers/media/video/v4l2-common.ko] undefined!

This 32-bit ppc architecture, using gcc version 4.1.2 20061115 
(prerelease) (Debian 4.1.1-21). .config below if important.

__ucmpdi2 seems to be 64-bit comparision. gcc seems to use it for switch 
statements on 64-bit values.

drivers/media/video/v4l2-common.c::v4l2_norm_to_name seems to be one 
such switch statement - type of id is v4l2_std_id which is 64-bit.

Should ppc have __ucmpdi2 defined in arch-specific lib? Some other 
architectures seem to implement it (arm, arm26, frv, h8300).

-- 
Meelis Roos (mroos@linux.ee)

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

* Re: V4L2: __ucmpdi2 undefined on ppc
  2006-12-13 12:11 V4L2: __ucmpdi2 undefined on ppc Meelis Roos
@ 2006-12-13 12:59 ` Paweł Sikora
  2006-12-13 23:41 ` Mauro Carvalho Chehab
  1 sibling, 0 replies; 16+ messages in thread
From: Paweł Sikora @ 2006-12-13 12:59 UTC (permalink / raw)
  To: Meelis Roos; +Cc: Linux Kernel list

Meelis Roos napisał(a):
>   MODPOST 618 modules
> WARNING: "__ucmpdi2" [drivers/media/video/v4l2-common.ko] undefined!
> 
> This 32-bit ppc architecture, using gcc version 4.1.2 20061115 
> (prerelease) (Debian 4.1.1-21). .config below if important.
> 
> __ucmpdi2 seems to be 64-bit comparision. gcc seems to use it for switch 
> statements on 64-bit values.
> 
> drivers/media/video/v4l2-common.c::v4l2_norm_to_name seems to be one 
> such switch statement - type of id is v4l2_std_id which is 64-bit.
> 
> Should ppc have __ucmpdi2 defined in arch-specific lib? Some other 
> architectures seem to implement it (arm, arm26, frv, h8300).

maybe it's new gcc bug.

[ already fixed ]
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21237
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25724


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

* Re: V4L2: __ucmpdi2 undefined on ppc
  2006-12-13 12:11 V4L2: __ucmpdi2 undefined on ppc Meelis Roos
  2006-12-13 12:59 ` Paweł Sikora
@ 2006-12-13 23:41 ` Mauro Carvalho Chehab
  2006-12-14 19:58   ` Kyle McMartin
  1 sibling, 1 reply; 16+ messages in thread
From: Mauro Carvalho Chehab @ 2006-12-13 23:41 UTC (permalink / raw)
  To: Meelis Roos; +Cc: Linux Kernel list

Em Qua, 2006-12-13 às 14:11 +0200, Meelis Roos escreveu:
>   MODPOST 618 modules
> WARNING: "__ucmpdi2" [drivers/media/video/v4l2-common.ko] undefined!
> 
> This 32-bit ppc architecture, using gcc version 4.1.2 20061115 
> (prerelease) (Debian 4.1.1-21). .config below if important.
Hmm... does it work with gcc 4.0? 
> 
> __ucmpdi2 seems to be 64-bit comparision. gcc seems to use it for switch 
> statements on 64-bit values.
Argh! if this is caused by switch / ifs, compilation will fail on other
places.

Cheers, 
Mauro.


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

* Re: V4L2: __ucmpdi2 undefined on ppc
  2006-12-13 23:41 ` Mauro Carvalho Chehab
@ 2006-12-14 19:58   ` Kyle McMartin
  2006-12-16 18:15     ` Mauro Carvalho Chehab
  2006-12-17 13:29       ` David Woodhouse
  0 siblings, 2 replies; 16+ messages in thread
From: Kyle McMartin @ 2006-12-14 19:58 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: Meelis Roos, Linux Kernel list

On Wed, Dec 13, 2006 at 09:41:56PM -0200, Mauro Carvalho Chehab wrote:
> Argh! if this is caused by switch / ifs, compilation will fail on other
> places.
> 

I posted a patch to Paul this week to fix this, as saw we saw it on
Ubuntu's powerpc kernel builds.

Since ppc32 can't do a 64bit comparison on its own it seems, gcc
will generate a call to a helper function from libgcc. What other
arches do is link libgcc.a into libs-y, and export the symbol
they want from it. The build process will discard the rest of the
.a that is unused. parisc uses this method, for example.

Gcc targets can provide optimized versions of these helpers in
assembly, but at least in this case, the generic C version seems
to be used everywhere. It might be useful to provide kernel local
copies of these C versions linked __weak or something if the
arch happens to need them.

(Not going to sign off or anything, since I've already sent it to
paulus@ and I don't want it to get merged without his approval...)

Cheers,
	Kyle

---
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index a00fe72..5b60c05 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -139,6 +139,8 @@ core-$(CONFIG_XMON)		+= arch/powerpc/xmon/
 
 drivers-$(CONFIG_OPROFILE)	+= arch/powerpc/oprofile/
 
+libs-y				+= `$(CC) -print-libgcc-file-name`
+
 # Default to zImage, override when needed
 defaultimage-y			:= zImage
 defaultimage-$(CONFIG_PPC_ISERIES) := vmlinux
diff --git a/arch/powerpc/kernel/ppc_ksyms.c b/arch/powerpc/kernel/ppc_ksyms.c
index 9179f07..dea8384 100644
--- a/arch/powerpc/kernel/ppc_ksyms.c
+++ b/arch/powerpc/kernel/ppc_ksyms.c
@@ -164,6 +164,9 @@ long long __lshrdi3(long long, int);
 EXPORT_SYMBOL(__ashrdi3);
 EXPORT_SYMBOL(__ashldi3);
 EXPORT_SYMBOL(__lshrdi3);
+
+extern void __ucmpdi2(void);
+EXPORT_SYMBOL(__ucmpdi2);
 #endif
 
 EXPORT_SYMBOL(memcpy);

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

* Re: V4L2: __ucmpdi2 undefined on ppc
  2006-12-14 19:58   ` Kyle McMartin
@ 2006-12-16 18:15     ` Mauro Carvalho Chehab
  2006-12-17 13:29       ` David Woodhouse
  1 sibling, 0 replies; 16+ messages in thread
From: Mauro Carvalho Chehab @ 2006-12-16 18:15 UTC (permalink / raw)
  To: Kyle McMartin; +Cc: Meelis Roos, Linux Kernel list

> I posted a patch to Paul this week to fix this, as saw we saw it on
> Ubuntu's powerpc kernel builds.
> 
> Since ppc32 can't do a 64bit comparison on its own it seems, gcc
> will generate a call to a helper function from libgcc. What other
> arches do is link libgcc.a into libs-y, and export the symbol
> they want from it. The build process will discard the rest of the
> .a that is unused. parisc uses this method, for example.
> 
> Gcc targets can provide optimized versions of these helpers in
> assembly, but at least in this case, the generic C version seems
> to be used everywhere. It might be useful to provide kernel local
> copies of these C versions linked __weak or something if the
> arch happens to need them.
> 
> (Not going to sign off or anything, since I've already sent it to
> paulus@ and I don't want it to get merged without his approval...)

Seems to be a good way to solve it.


> ---
> diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
> index a00fe72..5b60c05 100644
> --- a/arch/powerpc/Makefile
> +++ b/arch/powerpc/Makefile
> @@ -139,6 +139,8 @@ core-$(CONFIG_XMON)		+= arch/powerpc/xmon/
>  
>  drivers-$(CONFIG_OPROFILE)	+= arch/powerpc/oprofile/
>  
> +libs-y				+= `$(CC) -print-libgcc-file-name`
> +
>  # Default to zImage, override when needed
>  defaultimage-y			:= zImage
>  defaultimage-$(CONFIG_PPC_ISERIES) := vmlinux
> diff --git a/arch/powerpc/kernel/ppc_ksyms.c b/arch/powerpc/kernel/ppc_ksyms.c
> index 9179f07..dea8384 100644
> --- a/arch/powerpc/kernel/ppc_ksyms.c
> +++ b/arch/powerpc/kernel/ppc_ksyms.c
> @@ -164,6 +164,9 @@ long long __lshrdi3(long long, int);
>  EXPORT_SYMBOL(__ashrdi3);
>  EXPORT_SYMBOL(__ashldi3);
>  EXPORT_SYMBOL(__lshrdi3);
> +
> +extern void __ucmpdi2(void);
> +EXPORT_SYMBOL(__ucmpdi2);
>  #endif
>  
>  EXPORT_SYMBOL(memcpy);
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
Cheers, 
Mauro.


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

* Re: V4L2: __ucmpdi2 undefined on ppc
  2006-12-14 19:58   ` Kyle McMartin
@ 2006-12-17 13:29       ` David Woodhouse
  2006-12-17 13:29       ` David Woodhouse
  1 sibling, 0 replies; 16+ messages in thread
From: David Woodhouse @ 2006-12-17 13:29 UTC (permalink / raw)
  To: Kyle McMartin
  Cc: linuxppc-dev, Meelis Roos, paulus, Linux Kernel list,
	Mauro Carvalho Chehab

On Thu, 2006-12-14 at 14:58 -0500, Kyle McMartin wrote:
> I posted a patch to Paul this week to fix this, 

Hm, I didn't see it on linuxppc-dev.

> Since ppc32 can't do a 64bit comparison on its own it seems, gcc
> will generate a call to a helper function from libgcc. What other
> arches do is link libgcc.a into libs-y, and export the symbol
> they want from it.

You still get to 'accidentally' do 64-bit arithmetic in-kernel that way
though. Might be better just to provide __ucmpdi2, just as we have for
the other functions which are required from libgcc 

It'd be better just to fix the compiler though -- which is in fact what
they've done: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25724
              http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21237

I've applied this as a temporary hack to the Fedora kernel until the
compiler is updated there...

--- linux-2.6.19.ppc/arch/powerpc/kernel/misc_32.S~	2006-11-29 21:57:37.000000000 +0000
+++ linux-2.6.19.ppc/arch/powerpc/kernel/misc_32.S	2006-12-17 12:19:48.000000000 +0000
@@ -728,6 +728,27 @@ _GLOBAL(__lshrdi3)
 	or	r4,r4,r7	# LSW |= t2
 	blr
 
+/*
+ * __ucmpdi2: 64-bit comparison
+ *
+ * R3/R4 has 64 bit value A
+ * R5/R6 has 64 bit value B
+ * result in R3: 0 for A < B
+ *		 1 for A == B
+ *		 2 for A > B
+ */
+_GLOBAL(__ucmpdi2)
+	cmplw	r7,r3,r5	# compare high words
+	li	r3,0
+	blt	r7,2f		# a < b ... return 0
+	bgt	r7,1f		# a > b ... return 2
+	cmplw	r6,r4,r6	# compare low words
+	blt	r6,2f		# a < b ... return 0
+	li	r3,1
+	ble	r6,2f		# a = b ... return 1
+1:	li	r3,2
+2:	blr
+
 _GLOBAL(abs)
 	srawi	r4,r3,31
 	xor	r3,r3,r4
--- linux-2.6.19.ppc/arch/powerpc/kernel/ppc_ksyms.c~	2006-12-15 17:19:56.000000000 +0000
+++ linux-2.6.19.ppc/arch/powerpc/kernel/ppc_ksyms.c	2006-12-17 12:16:54.000000000 +0000
@@ -161,9 +161,11 @@ EXPORT_SYMBOL(to_tm);
 long long __ashrdi3(long long, int);
 long long __ashldi3(long long, int);
 long long __lshrdi3(long long, int);
+int __ucmpdi2(uint64_t, uint64_t);
 EXPORT_SYMBOL(__ashrdi3);
 EXPORT_SYMBOL(__ashldi3);
 EXPORT_SYMBOL(__lshrdi3);
+EXPORT_SYMBOL(__ucmpdi2);
 #endif
 
 EXPORT_SYMBOL(memcpy);

-- 
dwmw2

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

* Re: V4L2: __ucmpdi2 undefined on ppc
@ 2006-12-17 13:29       ` David Woodhouse
  0 siblings, 0 replies; 16+ messages in thread
From: David Woodhouse @ 2006-12-17 13:29 UTC (permalink / raw)
  To: Kyle McMartin
  Cc: Mauro Carvalho Chehab, Meelis Roos, Linux Kernel list,
	linuxppc-dev, paulus

On Thu, 2006-12-14 at 14:58 -0500, Kyle McMartin wrote:
> I posted a patch to Paul this week to fix this, 

Hm, I didn't see it on linuxppc-dev.

> Since ppc32 can't do a 64bit comparison on its own it seems, gcc
> will generate a call to a helper function from libgcc. What other
> arches do is link libgcc.a into libs-y, and export the symbol
> they want from it.

You still get to 'accidentally' do 64-bit arithmetic in-kernel that way
though. Might be better just to provide __ucmpdi2, just as we have for
the other functions which are required from libgcc 

It'd be better just to fix the compiler though -- which is in fact what
they've done: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25724
              http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21237

I've applied this as a temporary hack to the Fedora kernel until the
compiler is updated there...

--- linux-2.6.19.ppc/arch/powerpc/kernel/misc_32.S~	2006-11-29 21:57:37.000000000 +0000
+++ linux-2.6.19.ppc/arch/powerpc/kernel/misc_32.S	2006-12-17 12:19:48.000000000 +0000
@@ -728,6 +728,27 @@ _GLOBAL(__lshrdi3)
 	or	r4,r4,r7	# LSW |= t2
 	blr
 
+/*
+ * __ucmpdi2: 64-bit comparison
+ *
+ * R3/R4 has 64 bit value A
+ * R5/R6 has 64 bit value B
+ * result in R3: 0 for A < B
+ *		 1 for A == B
+ *		 2 for A > B
+ */
+_GLOBAL(__ucmpdi2)
+	cmplw	r7,r3,r5	# compare high words
+	li	r3,0
+	blt	r7,2f		# a < b ... return 0
+	bgt	r7,1f		# a > b ... return 2
+	cmplw	r6,r4,r6	# compare low words
+	blt	r6,2f		# a < b ... return 0
+	li	r3,1
+	ble	r6,2f		# a = b ... return 1
+1:	li	r3,2
+2:	blr
+
 _GLOBAL(abs)
 	srawi	r4,r3,31
 	xor	r3,r3,r4
--- linux-2.6.19.ppc/arch/powerpc/kernel/ppc_ksyms.c~	2006-12-15 17:19:56.000000000 +0000
+++ linux-2.6.19.ppc/arch/powerpc/kernel/ppc_ksyms.c	2006-12-17 12:16:54.000000000 +0000
@@ -161,9 +161,11 @@ EXPORT_SYMBOL(to_tm);
 long long __ashrdi3(long long, int);
 long long __ashldi3(long long, int);
 long long __lshrdi3(long long, int);
+int __ucmpdi2(uint64_t, uint64_t);
 EXPORT_SYMBOL(__ashrdi3);
 EXPORT_SYMBOL(__ashldi3);
 EXPORT_SYMBOL(__lshrdi3);
+EXPORT_SYMBOL(__ucmpdi2);
 #endif
 
 EXPORT_SYMBOL(memcpy);

-- 
dwmw2


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

* Re: V4L2: __ucmpdi2 undefined on ppc
  2006-12-17 13:29       ` David Woodhouse
  (?)
@ 2008-02-06 14:39       ` Stephane Marchesin
  2008-03-02 18:48         ` Stephane Marchesin
  2008-03-02 21:53         ` Segher Boessenkool
  -1 siblings, 2 replies; 16+ messages in thread
From: Stephane Marchesin @ 2008-02-06 14:39 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: henrik.sorensen, David Woodhouse, paulus

On 12/17/06, David Woodhouse <dwmw2@infradead.org> wrote:
>
> You still get to 'accidentally' do 64-bit arithmetic in-kernel that way
> though. Might be better just to provide __ucmpdi2, just as we have for
> the other functions which are required from libgcc
>
> It'd be better just to fix the compiler though -- which is in fact what
> they've done: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25724
>               http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21237
>
> I've applied this as a temporary hack to the Fedora kernel until the
> compiler is updated there...
>

Hello,

We're hitting this i nouveau as well (http://nouveau.freedesktop.org),
since we make extensive use ot 64 bit ints. Over time, we've had a
number of reports on this issue, and at one point I read that it
should be fixed in gcc. But recently, a nouveau user on PPC32 (Henrik
in CC:) reported the issue again with gcc 4.2.3. Others have it on gcc
4.2.2 too:
http://bugs.freedesktop.org/show_bug.cgi?id=10547

So, the point of this email is to ask about the possibility of merging
in one of the __ucmpdi2 patches, like David's which is kept below for
reference. Most distros seem to ship with such a patch already, and it
seems that other drivers hit this as well.

Thanks,
Stephane


> --- linux-2.6.19.ppc/arch/powerpc/kernel/misc_32.S~     2006-11-29 21:57:37.000000000 +0000
> +++ linux-2.6.19.ppc/arch/powerpc/kernel/misc_32.S      2006-12-17 12:19:48.000000000 +0000
> @@ -728,6 +728,27 @@ _GLOBAL(__lshrdi3)
>         or      r4,r4,r7        # LSW |= t2
>         blr
>
> +/*
> + * __ucmpdi2: 64-bit comparison
> + *
> + * R3/R4 has 64 bit value A
> + * R5/R6 has 64 bit value B
> + * result in R3: 0 for A < B
> + *              1 for A == B
> + *              2 for A > B
> + */
> +_GLOBAL(__ucmpdi2)
> +       cmplw   r7,r3,r5        # compare high words
> +       li      r3,0
> +       blt     r7,2f           # a < b ... return 0
> +       bgt     r7,1f           # a > b ... return 2
> +       cmplw   r6,r4,r6        # compare low words
> +       blt     r6,2f           # a < b ... return 0
> +       li      r3,1
> +       ble     r6,2f           # a = b ... return 1
> +1:     li      r3,2
> +2:     blr
> +
>  _GLOBAL(abs)
>         srawi   r4,r3,31
>         xor     r3,r3,r4
> --- linux-2.6.19.ppc/arch/powerpc/kernel/ppc_ksyms.c~   2006-12-15 17:19:56.000000000 +0000
> +++ linux-2.6.19.ppc/arch/powerpc/kernel/ppc_ksyms.c    2006-12-17 12:16:54.000000000 +0000
> @@ -161,9 +161,11 @@ EXPORT_SYMBOL(to_tm);
>  long long __ashrdi3(long long, int);
>  long long __ashldi3(long long, int);
>  long long __lshrdi3(long long, int);
> +int __ucmpdi2(uint64_t, uint64_t);
>  EXPORT_SYMBOL(__ashrdi3);
>  EXPORT_SYMBOL(__ashldi3);
>  EXPORT_SYMBOL(__lshrdi3);
> +EXPORT_SYMBOL(__ucmpdi2);
>  #endif
>
>  EXPORT_SYMBOL(memcpy);
>
> --
> dwmw2
>

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

* Re: V4L2: __ucmpdi2 undefined on ppc
  2008-02-06 14:39       ` Stephane Marchesin
@ 2008-03-02 18:48         ` Stephane Marchesin
  2008-03-02 21:53         ` Segher Boessenkool
  1 sibling, 0 replies; 16+ messages in thread
From: Stephane Marchesin @ 2008-03-02 18:48 UTC (permalink / raw)
  To: linuxppc-dev, David Woodhouse, benh, paulus, henrik.sorensen,
	linux-kernel

On 2/6/08, Stephane Marchesin <marchesin@icps.u-strasbg.fr> wrote:
>
>  We're hitting this i nouveau as well (http://nouveau.freedesktop.org),
>  since we make extensive use ot 64 bit ints. Over time, we've had a
>  number of reports on this issue, and at one point I read that it
>  should be fixed in gcc. But recently, a nouveau user on PPC32 (Henrik
>  in CC:) reported the issue again with gcc 4.2.3. Others have it on gcc
>  4.2.2 too:
>  http://bugs.freedesktop.org/show_bug.cgi?id=10547
>
>  So, the point of this email is to ask about the possibility of merging
>  in one of the __ucmpdi2 patches, like David's which is kept below for
>  reference. Most distros seem to ship with such a patch already, and it
>  seems that other drivers hit this as well.
>

So, could we have that thing in main tree ? It's not like it's
untested, most distros carry that, and a couple of arches provide
their own ucmpdi2 implementation already. It's also such a small
function...

Stephane

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

* Re: V4L2: __ucmpdi2 undefined on ppc
  2008-02-06 14:39       ` Stephane Marchesin
  2008-03-02 18:48         ` Stephane Marchesin
@ 2008-03-02 21:53         ` Segher Boessenkool
  2008-03-04 16:37           ` David Woodhouse
  2008-03-04 21:44           ` Paul Mackerras
  1 sibling, 2 replies; 16+ messages in thread
From: Segher Boessenkool @ 2008-03-02 21:53 UTC (permalink / raw)
  To: Stephane Marchesin; +Cc: linuxppc-dev, henrik.sorensen, paulus, David Woodhouse

>> +/*
>> + * __ucmpdi2: 64-bit comparison
>> + *
>> + * R3/R4 has 64 bit value A
>> + * R5/R6 has 64 bit value B
>> + * result in R3: 0 for A < B
>> + *              1 for A == B
>> + *              2 for A > B
>> + */
>> +_GLOBAL(__ucmpdi2)
>> +       cmplw   r7,r3,r5        # compare high words
>> +       li      r3,0
>> +       blt     r7,2f           # a < b ... return 0
>> +       bgt     r7,1f           # a > b ... return 2
>> +       cmplw   r6,r4,r6        # compare low words
>> +       blt     r6,2f           # a < b ... return 0
>> +       li      r3,1
>> +       ble     r6,2f           # a = b ... return 1
>> +1:     li      r3,2
>> +2:     blr

Every occurrence of r7 here is wrong (and some of the r6).  Is there
any reason to do this in assembler code at all?


Segher

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

* Re: V4L2: __ucmpdi2 undefined on ppc
  2008-03-02 21:53         ` Segher Boessenkool
@ 2008-03-04 16:37           ` David Woodhouse
  2008-03-04 16:58             ` Scott Wood
  2008-03-04 20:32             ` Segher Boessenkool
  2008-03-04 21:44           ` Paul Mackerras
  1 sibling, 2 replies; 16+ messages in thread
From: David Woodhouse @ 2008-03-04 16:37 UTC (permalink / raw)
  To: Segher Boessenkool
  Cc: paulus, henrik.sorensen, Stephane Marchesin, linuxppc-dev


On Sun, 2008-03-02 at 22:53 +0100, Segher Boessenkool wrote:
> Every occurrence of r7 here is wrong (and some of the r6).

Can you elucidate?

>   Is there any reason to do this in assembler code at all?

Is there any particular reason not to?

-- 
dwmw2

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

* Re: V4L2: __ucmpdi2 undefined on ppc
  2008-03-04 16:37           ` David Woodhouse
@ 2008-03-04 16:58             ` Scott Wood
  2008-03-04 20:32             ` Segher Boessenkool
  1 sibling, 0 replies; 16+ messages in thread
From: Scott Wood @ 2008-03-04 16:58 UTC (permalink / raw)
  To: David Woodhouse; +Cc: Stephane Marchesin, henrik.sorensen, paulus, linuxppc-dev

On Tue, Mar 04, 2008 at 04:37:28PM +0000, David Woodhouse wrote:
> 
> On Sun, 2008-03-02 at 22:53 +0100, Segher Boessenkool wrote:
> > Every occurrence of r7 here is wrong (and some of the r6).
> 
> Can you elucidate?

They were being used as condition registers rather than GPRs.

> >   Is there any reason to do this in assembler code at all?
> 
> Is there any particular reason not to?

Same reason most of the rest of the kernel is in C rather than assembly.

Of course, a better question is why we don't just link libgcc...

-Scott

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

* Re: V4L2: __ucmpdi2 undefined on ppc
  2008-03-04 16:37           ` David Woodhouse
  2008-03-04 16:58             ` Scott Wood
@ 2008-03-04 20:32             ` Segher Boessenkool
  1 sibling, 0 replies; 16+ messages in thread
From: Segher Boessenkool @ 2008-03-04 20:32 UTC (permalink / raw)
  To: David Woodhouse; +Cc: paulus, henrik.sorensen, Stephane Marchesin, linuxppc-dev

>> Every occurrence of r7 here is wrong (and some of the r6).
>
> Can you elucidate?

Sure!  It should read either "7" or "cr7".

>>   Is there any reason to do this in assembler code at all?
>
> Is there any particular reason not to?

1) If written in assembler, it needs to be written for every 
architecture
separately, and sometimes even for every architecture variant (32 vs. 64
bit is only the tip of the iceberg).

2) As shown here as well as in the recent strncmp() patch, it is a lot 
harder
to write correct assembler code than it is to write correct C code(*), 
and
the C code isn't less efficient either.


Segher

(*) Well, the generic C strncmp() code in the kernel is broken too, bad
example perhaps :-)

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

* Re: V4L2: __ucmpdi2 undefined on ppc
  2008-03-02 21:53         ` Segher Boessenkool
  2008-03-04 16:37           ` David Woodhouse
@ 2008-03-04 21:44           ` Paul Mackerras
  2008-03-04 21:47             ` Scott Wood
  2008-03-04 22:43             ` Segher Boessenkool
  1 sibling, 2 replies; 16+ messages in thread
From: Paul Mackerras @ 2008-03-04 21:44 UTC (permalink / raw)
  To: Segher Boessenkool
  Cc: linuxppc-dev, henrik.sorensen, Stephane Marchesin,
	David Woodhouse

Segher Boessenkool writes:

> Every occurrence of r7 here is wrong (and some of the r6).  Is there
> any reason to do this in assembler code at all?

The fact that the obvious C code generates ... a call to __ucmpdi2? :)

Paul.

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

* Re: V4L2: __ucmpdi2 undefined on ppc
  2008-03-04 21:44           ` Paul Mackerras
@ 2008-03-04 21:47             ` Scott Wood
  2008-03-04 22:43             ` Segher Boessenkool
  1 sibling, 0 replies; 16+ messages in thread
From: Scott Wood @ 2008-03-04 21:47 UTC (permalink / raw)
  To: Paul Mackerras
  Cc: linuxppc-dev, henrik.sorensen, Stephane Marchesin,
	David Woodhouse

Paul Mackerras wrote:
> Segher Boessenkool writes:
> 
>> Every occurrence of r7 here is wrong (and some of the r6).  Is there
>> any reason to do this in assembler code at all?
> 
> The fact that the obvious C code generates ... a call to __ucmpdi2? :)

So use the correct C code, not the obvious C code. :-)

-Scott

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

* Re: V4L2: __ucmpdi2 undefined on ppc
  2008-03-04 21:44           ` Paul Mackerras
  2008-03-04 21:47             ` Scott Wood
@ 2008-03-04 22:43             ` Segher Boessenkool
  1 sibling, 0 replies; 16+ messages in thread
From: Segher Boessenkool @ 2008-03-04 22:43 UTC (permalink / raw)
  To: Paul Mackerras
  Cc: linuxppc-dev, henrik.sorensen, Stephane Marchesin,
	David Woodhouse

>> Every occurrence of r7 here is wrong (and some of the r6).  Is there
>> any reason to do this in assembler code at all?
>
> The fact that the obvious C code generates ... a call to __ucmpdi2? :)

Hrm?  Here's the "obvious" C code, portable to all architectures
(modulo the specific types used, this isn't a proposed patch):


unsigned int ucmpdi2(unsigned long long a, unsigned long long b)
{
         unsigned long ahi, bhi, alo, blo;

         ahi = a >> 32;
         bhi = b >> 32;
         if (ahi < bhi)
                 return 0;
         if (ahi > bhi)
                 return 2;

         alo = a;
         blo = b;
         if (alo < blo)
                 return 0;
         if (alo > blo)
                 return 2;

         return 1;
}


(libgcc does it a bit differently, with unions and stuff).


Segher

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

end of thread, other threads:[~2008-03-04 22:43 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-13 12:11 V4L2: __ucmpdi2 undefined on ppc Meelis Roos
2006-12-13 12:59 ` Paweł Sikora
2006-12-13 23:41 ` Mauro Carvalho Chehab
2006-12-14 19:58   ` Kyle McMartin
2006-12-16 18:15     ` Mauro Carvalho Chehab
2006-12-17 13:29     ` David Woodhouse
2006-12-17 13:29       ` David Woodhouse
2008-02-06 14:39       ` Stephane Marchesin
2008-03-02 18:48         ` Stephane Marchesin
2008-03-02 21:53         ` Segher Boessenkool
2008-03-04 16:37           ` David Woodhouse
2008-03-04 16:58             ` Scott Wood
2008-03-04 20:32             ` Segher Boessenkool
2008-03-04 21:44           ` Paul Mackerras
2008-03-04 21:47             ` Scott Wood
2008-03-04 22:43             ` Segher Boessenkool

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.