[klibc] [klibc:master] lseek: give gcc a little optimization hint

klibc-bot for H. Peter Anvin hpa at zytor.com
Mon May 21 14:47:39 PDT 2012


Commit-ID:  2024ab7832dea5dc004f712ffdf348b8239b8ffa
Gitweb:     http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=2024ab7832dea5dc004f712ffdf348b8239b8ffa
Author:     H. Peter Anvin <hpa at zytor.com>
AuthorDate: Mon, 21 May 2012 10:28:50 -0700
Committer:  H. Peter Anvin <hpa at zytor.com>
CommitDate: Mon, 21 May 2012 10:30:39 -0700

[klibc] lseek: give gcc a little optimization hint

It looks like gcc generates some epicly confused code for splitting
the two halves of the offset argument to lseek() at least on i386.
Copy it into an unsigned long long before breaking it apart seems to
help.

Signed-off-by: H. Peter Anvin <hpa at zytor.com>

---
 usr/klibc/lseek.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/usr/klibc/lseek.c b/usr/klibc/lseek.c
index a313bed..f262d19 100644
--- a/usr/klibc/lseek.c
+++ b/usr/klibc/lseek.c
@@ -18,13 +18,14 @@ extern int __llseek(int fd, unsigned long hi, unsigned long lo, off_t * res,
 
 off_t lseek(int fd, off_t offset, int whence)
 {
+	unsigned long long ullo = offset;
 	off_t result;
 	int rv;
 
-	rv = __llseek(fd, (unsigned long)(offset >> 32), (unsigned long)offset,
+	rv = __llseek(fd, (unsigned long)(ullo >> 32), (unsigned long)ullo,
 		      &result, whence);
 
-	return rv ? (off_t) - 1 : result;
+	return rv ? (off_t)-1 : result;
 }
 
 #endif


More information about the klibc mailing list