This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Re: [RFC] statically initialize spu FILE values
- From: Kazunori Asayama <asayama at sm dot sony dot co dot jp>
- To: patmans at us dot ibm dot com
- Cc: newlib at sourceware dot org, jschopp at austin dot ibm dot com
- Date: Mon, 09 Apr 2007 10:53:57 +0900 (LDT)
- Subject: Re: [RFC] statically initialize spu FILE values
- References: <20070406150041.GA10478@us.ibm.com>
Patrick Mansfield <patmans@us.ibm.com> wrote:
> Use a static initialization of the spu FILE values, and get rid of the
> runtime spu calls to CHECK_INIT.
>
> RFC especially on the location and use of the new defines.
>
> Ran some simple tests for predefined FILE streams.
>
> Hacked spu to test that it compiles OK without the special defines, and
> that spu _REENT_INIT_PTR compiled OK (spu code does not use
> _REENT_INIT_PTR).
With your changes, the cleanup function (__cleanup) seems no longer
called. We need to set the address of __cleanup to REENT->__cleanup
somewhere.
One major reason why CHECK_INIT is called on runtime, is to reduce
code size. This approach can avoid linking an SPE program with
__cleanup if the program doesn't use stdio functions.
I propose to modify CHECK_INIT macro as following instead of remove
it, to minimize runtime overhead and code size, and still to do
cleanup correctly:
#define CHECK_INIT(ptr) ((ptr)->__sdidinit = 1, (ptr)->__cleanup = __cleanup)
--
(ASAYAMA Kazunori
(asayama@sm.sony.co.jp))
t