[Cbe-oss-dev] [PATCH] libspe2: cast assist call off_t arguments to int

Patrick Mansfield patmans at us.ibm.com
Wed Jul 18 08:46:10 EST 2007


On Tue, Jul 17, 2007 at 10:55:07PM +0200, Arnd Bergmann wrote:
> On Tuesday 17 July 2007, Patrick Mansfield wrote:
> > The cast of assist call arguments from 32 bit unsigned int (in
> > argn->slot[m]) to an off_t 64 bit signed value are incorrect with 64 bit
> > libspe, and some casts are missing for the newer assist calls. 
> > 
> > This patch casts all off_t assist call arguments to int.
> > 
> > lseek is the worst, without this change it gives incorrect behaviour for
> > negative offsets.
> > 
> > Only large or negative values for lseek and lockf (negative value is an
> > error) were tested.
> > 
> > Signed-off-by: Patrick Mansfield <patmans at us.ibm.com>
> 
> Shouldn't the fix be to change the SPU side to always use a 64 bit off_t
> in the argument list? I'd expect __USE_FILE_OFFSET64 to be always
> set on the SPU since we don't need to handle backwards compatibility.

> With the patch you posted, you would limit the file size for certain system
> calls to 4GB, which is not all that much these days.

We are already limited to 32 bits with the current assist call interface,
and SPU is already using an off_t of 32 bits.

I don't see any way to change that and maintain compatibility (for the
assist calls, we use the first 32 of 128 bits for arguments and results,
and do not clear the unused portions).

Yeh, we should probably have used 64 bits to start with.

So, we need 64 bit assist calls and support for __USE_FILE_OFFSET64 (or
-D_FILE_OFFSET_BITS=64, _LARGEFILE_SOURCE and _LARGEFILE64_SOURCE, or
whatever the appropriate defines) in order to keep compatibility.

And we also need assist call and newlib support for off64_t, lseek64 and
other *64 functions.

newlib has some support for large file interfaces, but no compile time
support for changing the off_t size (no _FILE_OFFSET_BITS or
__USE_FILE_OFFSET64).

We have some similar issues with [s]size_t, some results are truncated to
32 bits without any checking.

-- Patrick Mansfield



More information about the cbe-oss-dev mailing list