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]

malloc on tiny systems


The r8c chip has, at most, 1k of RAM.  mallocr.o uses 512 bytes for
its av_ table (16 bit pointers).  For a trivial program, the only
reason we include malloc is because __call_exitprocs() calls free().
We call the regular exit() because that's what main() is supposed to
do on "exit" although I admit that's meaningless in an embedded
system, unless you've hacked your runtime to report exit codes across
the serial link or are using a simulator that can report true exit
codes, such as for running the gcc testsuite.

Anyway... ideas for avoiding this memory usage?  There doesn't seem to
be a configure knob for reducing the size of that array.  We could
make free() a weak symbol, so that it doesn't cause a link of
mallocr() (although malloc() itself would, and you shouldn't be using
free() if you haven't malloc()'d anything).

Or should I just cal _exit() instead of exit() from crt0?  It's
nonstandard, but I can't think of a legitimate (other than my testing)
reason to call exitprocs, other than proving they work, but the
simulator has more memory than the chips and can accomodate those.


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