radeon warning on 64-bit platforms
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Linus and Michel,
Here is a proposed patch for fixing the compile-warning that shows up when compiling radeon_state.c on a 64-bit platform (Itanium, in my case). According to Michel, RADEON_PARAM_SAREA_HANDLE is used only on embedded platforms and since it is not possible to fix the problem without breaking backwards-compatibility for those platforms, the interim fix is to simply desupport this particular ioctl() on 64-bit platforms (i.e., make it fail with EINVAL).
If there are no objections, please apply.
--david
=== drivers/char/drm/radeon_state.c 1.23 vs edited ==--- 1.23/drivers/char/drm/radeon_state.c Tue Feb 3 21:29:26 2004
+++ edited/drivers/char/drm/radeon_state.c Tue Feb 17 15:23:01 2004
@@ -2186,9 +2186,24 @@
value = dev_priv->ring_rptr_offset; break;
case RADEON_PARAM_SAREA_HANDLE:
- /* The lock is the first dword in the sarea. */
- value = (int)dev->lock.hw_lock;
- break;
+ /*
+ * This ioctl() doesn't work on 64-bit platforms because hw_lock is a
+ * pointer which can't fit into an int-sized variable. According to
+ * Michael Dänzer, the ioctl() is only used on embedded platforms, so not
+ * supporting it shouldn't be a problem. If the same functionality is
+ * needed on 64-bit platforms, a new ioctl() would have to be added, so
+ * backwards-compatibility for the embedded platforms can be maintained.
+ * --davidm 4-Feb-2004.
+ */
+ if (sizeof (dev->lock.hw_lock) <= sizeof (int))
+ /*
+ * The lock is the first dword in the sarea. Cast to "long" so it + * compiles without warning on 64-bit platforms. + */
+ value = (long)dev->lock.hw_lock;
+ else
+ return DRM_ERR(EINVAL);
+ break;
case RADEON_PARAM_GART_TEX_HANDLE:
value = dev_priv->gart_textures_offset; break;
David,
looks good to me, except for a detail:
Review
Quoted 1 line
(quoted diff) +1
-0+ * Michael Dänzer, the ioctl() is only used on embedded platforms, so not
^^^^^^^
That's not quite my first name. :)
I'd appreciate a heads up when this (or whatever becomes of it) goes in so I can apply it to DRI CVS as well. On the other hand, I'll probably see it at the latest when Ben merges it into his tree. :)
Signature · 2 lines
Earthling Michel Dänzer | Debian (powerpc), X and DRI developer Libre software enthusiast | http://svcs.affero.net/rm.php?rÚenzer
Quoted 10 lines
Here is a proposed patch for fixing the compile-warning that shows up when compiling
radeon_state.con a 64-bit platform (Itanium, in my case). According to Michel,RADEON_PARAM_SAREA_HANDLEis used only on embedded platforms and since it is not possible to fix the problem without breaking backwards-compatibility for those platforms, the interim fix is to simply desupport this particularioctl()on 64-bit platforms (i.e., make it fail with EINVAL).If there are no objections, please apply.
A small thing, could the comment be constrained to 80 columns? :)
Anton
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Anton Blanchard
Anton> A small thing, could the comment be constrained to 80 Anton> columns? :)
I don't really see the point of that, given that pretty much all existing Linux source code is formatted for 100 columns. I don't feel strongly about it, however, so I changed it.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Linus Torvalds
Linus> How about this alternate edited one that gets indentation Linus> right and is more explicit about what's going on? Does this Linus> work for you?
Fine by me.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Michel Dänzer
Michel> looks good to me, except for a detail:
Quoted 2 lines
Quoted 2 lines
+ * Michael Dänzer, the
ioctl()is only used on embedded platforms, so not
Michel> ^^^^^^^ That's not quite my first name. :)
Sorry about that, fixed below (or so I hope).
--david
=== drivers/char/drm/radeon_state.c 1.23 vs edited ==--- 1.23/drivers/char/drm/radeon_state.c Tue Feb 3 21:29:26 2004
+++ edited/drivers/char/drm/radeon_state.c Tue Feb 17 16:49:15 2004
@@ -2185,10 +2185,21 @@
case RADEON_PARAM_STATUS_HANDLE:
value = dev_priv->ring_rptr_offset; break;
+#if BITS_PER_LONG = 32
+ /*
+ * This ioctl() doesn't work on 64-bit platforms because hw_lock is a
+ * pointer which can't fit into an int-sized variable. According to
+ * Michel Dänzer, the ioctl() is only used on embedded platforms, so
+ * not supporting it shouldn't be a problem. If the same functionality
+ * is needed on 64-bit platforms, a new ioctl() would have to be added,
+ * so backwards-compatibility for the embedded platforms can be
+ * maintained. --davidm 4-Feb-2004.
+ */
case RADEON_PARAM_SAREA_HANDLE:
/* The lock is the first dword in the sarea. */
- value = (int)dev->lock.hw_lock;
- break;
+ value = (long)dev->lock.hw_lock;
+ break;
+#endif
case RADEON_PARAM_GART_TEX_HANDLE:
value = dev_priv->gart_textures_offset; break;
Quoted 8 lines · David Mosberger
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Anton Blanchard
Anton> A small thing, could the comment be constrained to 80 Anton> columns? :)
I don't really see the point of that, given that pretty much all existing Linux source code is formatted for 100 columns. I don't feel strongly about it, however, so I changed it.
Um, only your crap. Everybody else follows Documentation/CodingStyle. This is mentioned in a couple of places:
Now, some people will claim that having 8-character indentations makes the code move too far to the right, and makes it hard to read on a 80-character terminal screen. The answer to that is that if you need more than 3 levels of indentation, you're screwed anyway, and should fix your program.
...
Functions should be short and sweet, and do just one thing. They should fit on one or two screenfuls of text (the ISO/ANSI screen size is 80x24, as we all know), and do one thing and do that well.
I wish the ia64 code weren't indented to 100 columns. It's why I hate working with your code.
Signature · 6 lines
"Next the statesmen will invent cheap lies, putting the blame upon the nation that is attacked, and every man will be glad of those conscience-soothing falsities, and will diligently study them, and refuse to examine any refutations of them; and thus he will by and by convince himself that the war is just, and will thank God for the better sleep he enjoys after this process of grotesque self-deception." -- Mark Twain
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line · Matthew Wilcox
I don't really see the point of that, given that pretty much all existing Linux source code is formatted for 100 columns. I don't feel strongly about it, however, so I changed it.
Matthew> Um, only your crap. Everybody else follows Matthew> Documentation/CodingStyle.
Wow. Revisionists at work? ;-)
I personally would be more than happy to reformat things to 80 cols, but it's a waste of time unless almost all Linux code gets reformatted.
--david
Quoted 3 lines · David Mosberger
I personally would be more than happy to reformat things to 80 cols, but it's a waste of time unless almost all Linux code gets reformatted.
Hm? I don't know where you're getting that from. Let's talk numbers.
Of the 60525 lines in .c files in arch/i386, 460 are longer than 80 cols. Of the 67398 lines in .c files in arch/ia64, 1189 are longer than 80 cols. Of the 496510 lines in .c files in drivers/net, 4044 are longer than 80 cols.
So arch/i386 has 0.76% > 80 column lines, drivers/net is 0.81% and arch/ia64 is 1.76%. Seems fairly convincing to me that ia64 is out of step with the rest of Linux.
Signature · 6 lines
"Next the statesmen will invent cheap lies, putting the blame upon the nation that is attacked, and every man will be glad of those conscience-soothing falsities, and will diligently study them, and refuse to examine any refutations of them; and thus he will by and by convince himself that the war is just, and will thank God for the better sleep he enjoys after this process of grotesque self-deception." -- Mark Twain
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Matthew Wilcox
Matthew> On Tue, Feb 17, 2004 at 05:59:12PM -0800, David Mosberger
Quoted 3 lines · Matthew> wrote:
Quoted 3 lines
I personally would be more than happy to reformat things to 80 cols, but it's a waste of time unless almost all Linux code gets reformatted.
Matthew> Hm? I don't know where you're getting that from. Let's Matthew> talk numbers.
If it bothers you, you're perfectly free to submit patches. Source-code width is not something I get overly excited about.
--david
Quoted 10 lines · Matthew Wilcox
Quoted 3 lines · David Mosberger
I personally would be more than happy to reformat things to 80 cols, but it's a waste of time unless almost all Linux code gets reformatted.
Hm? I don't know where you're getting that from. Let's talk numbers.
Of the 60525 lines in .c files in
arch/i386, 460 are longer than 80 cols. Of the 67398 lines in .c files inarch/ia64, 1189 are longer than 80 cols. Of the 496510 lines in .c files indrivers/net, 4044 are longer than 80 cols.
You apparently made the mistake of looking at character count < 80, not lines that extend past column 80.
For 2.6.3-mm1, I see:
[/usr/src/linux-2.6.3-mm1/arch/i386]2 find . -name '*.c' | xargs cat | wc -l
64542
[/usr/src/linux-2.6.3-mm1/arch/i386]2 find . -name '*.c' | xargs cat | awk 'length() > 80 { print $0}' | wc -l
477
[/usr/src/linux-2.6.3-mm1/arch/i386]2 find . -name '*.c' | xargs cat |sed 's/\t/ /g'| awk 'length() > 80 { print $0}' | wc -l
1291
(replace \t with whatever your shell needs to enter a literal tab . Yes, this botches on the relatively rare line that has an embedded tab. Deal with it. ;).
In other words, the situation is a lot worse if you count columns, not characters.
(For IA64, it's 67,376 and either 1,185 or 3,222, and for drivers/net I see 493,027 and either 4,004 or 15,606 - ia64 is worse at the 80-col thing either way)
Quoted 5 lines · [email protected] writes:
[/usr/src/linux-2.6.3-mm1/arch/i386]2 find . -name '*.c' | xargs cat |sed 's/\t/ /g'| awk '
length()> 80 { print $0}' | wc -l
1291(replace \t with whatever your shell needs to enter a literal tab . Yes, this botches on the relatively rare line that has an embedded tab. Deal with it. ;).
Use expand.
$ find . -name '*.c' | xargs cat | expand | awk 'length() > 80 { print $0}' | wc -l
1125Andreas.
Signature · 4 lines
Andreas Schwab, SuSE Labs, [email protected] SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
Quoted 1 line · Andreas Schwab
Use expand.
Learn something new every day. Usually, the task at hand is the inverse task - fixing a file that has leading blanks to have leading tabs instead. ;)
Quoted 4 lines · David Mosberger
Here is a proposed patch for fixing the compile-warning that shows up when compiling
radeon_state.con a 64-bit platform (Itanium, in my case).
How about this alternate edited one that gets indentation right and is more explicit about what's going on? Does this work for you?
Linus
---
=== drivers/char/drm/radeon_state.c 1.23 vs edited ==--- 1.23/drivers/char/drm/radeon_state.c Tue Feb 3 21:29:26 2004
+++ edited/drivers/char/drm/radeon_state.c Tue Feb 17 15:51:53 2004
@@ -2185,10 +2185,21 @@
case RADEON_PARAM_STATUS_HANDLE:
value = dev_priv->ring_rptr_offset; break;
+#if BITS_PER_LONG = 32
+ /*
+ * This ioctl() doesn't work on 64-bit platforms because hw_lock is a
+ * pointer which can't fit into an int-sized variable. According to
+ * Michel Dänzer, the ioctl() is only used on embedded platforms, so not
+ * supporting it shouldn't be a problem. If the same functionality is
+ * needed on 64-bit platforms, a new ioctl() would have to be added, so
+ * backwards-compatibility for the embedded platforms can be maintained.
+ * --davidm 4-Feb-2004.
+ */
case RADEON_PARAM_SAREA_HANDLE:
/* The lock is the first dword in the sarea. */ value = (int)dev->lock.hw_lock; break;
+#endif
case RADEON_PARAM_GART_TEX_HANDLE:
value = dev_priv->gart_textures_offset; break;