Mail Archives: djgpp-workers/2001/01/14/13:52:09
Hello.
Martin Str|mberg wrote:
> Of course you can't cast "int *" to "long long *" and expect anything
> to work. But you can cast "int" to "long long" (not necessarily the
> return value).
OK, I wasn't quite sure what you meant, but it's clear now.
> > The problem is returning a good (int-sized) offset to the FSEXT caller
> > for __FSEXT_llseek. If you can't return a good offset, then it's
> > broken.
>
> There is a good (well, sufficiently non-broken at least) int-sized
> return value: the range [-1, 2^32-2] which will be represented as the
> range [-2^31, 2^31-1].
Perhaps with a conversion like (untested):
int return_offset_as_int (offset_t offset, int *rv)
{
offset_t t = offset;
if (t > INT_MAX) {
t -= INT_MAX;
/* Handle offset > 2^32 - 2 */
if (t > INT_MAX)
return(-1);
*rv = -1 - (int) offset;
} else if (t >= 0) {
*rv = (int) offset;
} else {
/* Do not handle negative offset */
return(-1);
}
return(0);
}
and then back conversion like:
offset_t return_int_as_offset (int rv)
{
if (rv < -1)
return((offset_t) - (rv + 1));
else
return((offset_t) rv);
}
I guess these conversion functions would be FSEXT convenience functions.
So we get one bit extra for llseek()'s offsets over normal lseek() for
FSEXTs.
Another possible solution is to have llseek() return an error if too big
an offset is used (greater than INT_MAX), otherwise call the __FSEXT_lseek
handler. Then __FSEXT_llseek could be fixed later to support the full long
long offsets.
Bye, Rich =]
--
Richard Dawe
[ mailto:richdawe AT bigfoot DOT com | http://www.bigfoot.com/~richdawe/ ]
- Raw text -