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: [patch] Remove --disable-newlib-atexit-alloc.


Ralf Corsepius wrote:
On Wed, 2008-11-05 at 19:30 -0800, Kazu Hirata wrote:
Hi,

Attached is a patch to remove --disable-newlib-atexit-alloc and make
malloc a weak symbol in the support functions for atexit.

A while ago, Mark Mitchell added --disable-newlib-atexit-dynamic-alloc
to prevent atexit from pulling malloc.  This was a bit inflexible
because once newlib was built with --disable-newlib-atexit-alloc, the
user couldn't enable malloc without rebuilding newlib.

This patch makes malloc a weak symbol in the support functions of
atexit.  This way, if malloc is available for some other reason, we
use that.  Otherwise, we don't to conserve space.

OK to apply?
I am not sure, for 2 (hypothetical) reasons:

* You can't be sure weak symbols are available on a particular target.
newlib is being used for embedded targets, often using antiquated
compilers and "odd" object formats.

* The syntax you are using presumes using GCC.
I am not aware about anybody using newlib without GCC, but you never
know.

Ralf

Agreed. The current option should be left in place, but if you wanted to add a 2nd mechanism that doesn't require the option, that would be fine.

There is an _ATTRIBUTE macro defined in _ansi.h which can be used which will ignore any attributes for non __GNUC__ compilers or you could also make the __GNUC__ check yourself. As well, the weak attribute should be specified as __weak__ to avoid any user-conflict.

-- Jeff J.




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