This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Re: [PATCH 2/3] SPU stdio: FILE related stuffs
Patrick Mansfield <patmans@us.ibm.com> wrote:
> On Thu, Feb 01, 2007 at 11:41:38AM +0900, Kazunori Asayama wrote:
> > As you say, PPE's libc will perform such cleanups, but such things
> > will be done at the end of the PPE process. So if we don't perform
> > cleanups at the end of each SPE execution, the files which are not
> > closed explicitly by SPE, are left open until the corresponding
> > process exits.
>
> Can we just call fcloseall()? I don't fully understand the reent code.
Unfortunatelly, we have no implementation of fcloseall() yet. I think
that if it becomes available, the current cleanup code can be replaced
with it as you are saying.
> Or better, add code in libspe to track and close them all for us? That
> sounds better as it would save space in the LS.
Maybe. And such an improvement is possible. But I guess that some
refactoring works against libspe will be needed, because currently
PPE's FILEs are managed globally in libspe, not for each SPE context.
> > In general, because multiple SPE contexts can be run in a PPE process
> > and/or because a PPE process may not exit as soon as an SPE exits, we
> > should do cleanups for each SPE execution.
>
> What about close()? Looks like we also need to close all files opened by
> SPU code (not just the ones opened via fopen()).
Good point.
The current behavior, i.e. flushing and closing all streams at exit(),
is defined in POSIX, but I'm not sure how we should handle 'raw' file
descriptors.
Anyway, some kind of additional management will be needed in newlib or
in libspe if we want to close all file descriptors at exit(), because
file descriptors themselves are managed by OS, not by newlib/libspe.
--
(ASAYAMA Kazunori
(asayama@sm.sony.co.jp))
t