Re: [PATCH] Avoid ARM SWI Seek when querying file position

Corinna Vinschen <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <[email protected]>
On Aug 31 12:30, Andy Koppe wrote:
> On 31 August 2018 at 12:10, Andy Koppe wrote:
> > Issuing an ARM semi-hosting Seek command when just querying file
> > position with SEEK_CUR and offset zero is unnecessary, because unlike
> > the lseek() Unix system call the Seek command does not actually return
> > the file position. For that reason, syscalls.c for ARM keeps track of
> > file position in the 'poslog', so we can just return that.
> >
> > Moreover, since the Seek command only accepts an absolute file position,
> > SEEK_CUR operations are implemented by adding the relative offset to the
> > position in the poslog. If the host implements non-binary files with
> > implicit carriage return characters but doesn't discount those implicit
> > CRs when implementing Seek (by just mapping straight to Windows file
> > operations), this actually ended up wrongly changing file position when
> > using SEEK_CUR with offset zero or functions like ftell() or fgetpos()
> > that are based on that.
> >
> > The ARM semi-hosting Seek command is documented at
> > http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0040d/BACDFGCG.html
> >
> > (There's a wider problem in that using the position returned by the
> > likes of ftell() in a later seek operation gets you to the wrong place
> > if the host adds implicit CRs without discounting them in Seek
> > commands. Not sure there's anything that can be done about it on the
> > newlib side though.)
> 
> Slightly amended patch attached: Use off_t rather than int for the poslog.

Pushed.


Thanks,
Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
Red Hat
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEoVYPmneWZnwT6kwF9TYGna5ET6AFAluM5gAACgkQ9TYGna5E
T6AdDg//WrDh6EH+oY5Dg68cF08BqqMrZywUmrBt5eLZY7QyhBgClcWaEeJjaffN
/UE18YKkIGOKYT4nLvMRTMkV8plrxWNk6n3D/W5VtK8OFWIi/7c4qrszfOfRZQ67
1MIYPt8S8O6yymJuilBQ5DnS7SD33m/wPCOa5Ma6NiYdcmuRCMWSVW08v5sfpEns
HEsvFaEXjPL9ECd3xEKd4R8QgxjCLjzJNOMIXoyeQNo5Ne6qKC/HS9iaIA0A5ArT
iipIF6YjfQkby+x1V0UjRzyMxSH4aGe0Tl0HzL8/rSAJL6nf/Q5wKoNBC17j6rEl
JaufSiFnrGTLm/XoXBJI7Ka1gQv4G23Rul+IZMjElHu/fG9BRtxKTLclUjXQiuUo
rJJnVC7hIE97Jj7HIZAAPBVAO7r3DqnSmbHESrioEw0oupRJXt8hWN7E52DkmbSb
F7Q24c3TpaTBUnC/T2G7BQHjCxN2FdzctTNgPd7hrbvwiTY4+NLVJosXM2UrOkVV
9oN9JZ3Dr+vna0OkTPOyWzA3cwX1ztnDo+tffsiJn8aDrf/S4HMz88Tc+gTxJSjx
6Qm+kxjHZLa6w+m6PxUGkOqk3CDfbTLCGNZQX+LnFPvE6FHtpBTJOrTyrofBwEhI
+bgyuKEMYRZxmja6ojsJB1ADoTACtJSA80uKPS+VbWkbd2e3waA=
=AruJ
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.