]> git.baikalelectronics.ru Git - kernel.git/commit
Avoid 64-bit "switch()" statements on 32-bit architectures
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 17 Mar 2009 17:02:35 +0000 (10:02 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 17 Mar 2009 17:02:35 +0000 (10:02 -0700)
commit169752d4aaa8869b10760464b11743582ea18b54
treea29f070d82e6f787570213161c4c46c16ca6ef8a
parentb8160176f40e8c961c9c0c41f2049d22bf8af4c3
Avoid 64-bit "switch()" statements on 32-bit architectures

Commit ef3a0c3bb9164f21d06a226d3673bd5c26381c79 ("filp->f_pos not
correctly updated in proc_task_readdir") changed the proc code to use
filp->f_pos directly, rather than through a temporary variable.  In the
process, that caused the operations to be done on the full 64 bits, even
though the offset is never that big.

That's all fine and dandy per se, but for some unfathomable reason gcc
generates absolutely horrid code when using 64-bit values in switch()
statements.  To the point of actually calling out to gcc helper
functions like __cmpdi2 rather than just doing the trivial comparisons
directly the way gcc does for normal compares.  At which point we get
link failures, because we really don't want to support that kind of
crazy code.

Fix this by just casting the f_pos value to "unsigned long", which
is plenty big enough for /proc, and avoids the gcc code generation issue.

Reported-by: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Zhang Le <r0bertz@gentoo.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/proc/base.c