This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC] statically initialize spu FILE values


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]