delorie.com/archives/browse.cgi | search |
From: | Martin Str|mberg <ams AT ludd DOT luth DOT se> |
Message-Id: | <200301191314.h0JDE1j23762@brother.ludd.luth.se> |
Subject: | Re: lseek() calling llseek() |
To: | djgpp-workers AT delorie DOT com |
Date: | Sun, 19 Jan 2003 14:14:01 +0100 (MET) |
In-Reply-To: | <3E2A9590.BDDE0371@phekda.freeserve.co.uk> from "Richard Dawe" at Jan 19, 2003 12:09:52 PM |
X-Mailer: | ELM [version 2.5 PL2] |
MIME-Version: | 1.0 |
Reply-To: | djgpp-workers AT delorie DOT com |
Errors-To: | nobody AT delorie DOT com |
X-Mailing-List: | djgpp-workers AT delorie DOT com |
X-Unsubscribes-To: | listserv AT delorie DOT com |
According to Richard Dawe: > Martin Str|mberg wrote: > > Comments are welcome. In particular on my documentation changes and the > > last return statement in lseek() (which could be made safer with some more > > lines of code). > > It looks fine to me with your safer return code (from another mail) and some > texinfo fixes. Here's the latest C code. llseek_offset = llseek(handle, offset, whence); if( offset == -1 ) { return -1; /* llseek sets errno. */ } /* Here we rely on that llseek()'s return range is [-1, 2^32-2]. * All this removal of the bits 31-63 (of which only bit 31 * potentially could be set) in the long long (offset_t) and then * merging it into the long (off_t) is because if a value is * (de)promoted and it doesn't fit in the target variable * implementation defined behaviour is invoked. So we make sure it * temporarily fits. After that it's ok to or in the sign bit * again. */ if( llseek_offset&0x80000000 ) { return ((off_t)(llseek_offset&0x7fffffff))|0x80000000; } else { return llseek_offset&0x7fffffff; } Right, MartinS
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |