[En-Nut-Discussion] Use of alloca in Nut/OS

Matthias Ringwald mringwal at inf.ethz.ch
Mon Aug 11 12:15:30 CEST 2008

HI Henrik

a quite straigt forward solution for you might be to use
avr-gcc 3.4.6 with a (more) recent avr-libc.

compiling avr-libc is less complicated than compiling nut/os with this  
configuration stuff.. :)


On 08.08.2008, at 10:03, Henrik Maier wrote:

> Hi everybody,
> I just tried to compile Nut/OS 4.6.0 stable with my old  
> WinAVR-20060421
> which uses avr-gcc 3.4.6. Compilation fails because this older avrlibc
> version does not support alloca(). Of course an upgrade to latest  
> WinAVR
> would fix this, however above version compiles very compact code  
> compared to
> avr-gcc 4.3.0: 10% saving in code space. So a good reason to use it.
> This incident brought my attention to alloca and I am wondering if  
> the main
> code of Nut/OS should use alloca at all?
> Alloca is used in two modules ssi.c and cgi.c.
> On systems with larger amounts of memory alloca would be a good  
> option for
> dynamic memory. However on the AVR stack space is very limited and  
> often
> only a few hundred bytes per thread. Allocating larger strings on  
> the stack
> can easily cause stack overflow.
> The other issue which arises is that Imagecraft does not support it  
> either.
> I suggest to use it only for the ARM/gcc combination and guard it's  
> use with
> conditional compilation of the form "#if defined(__GNUC__) &&
> defined(__arm__) "
> Any thoughts on this?
> Henrik
> _______________________________________________
> http://lists.egnite.de/mailman/listinfo/en-nut-discussion

More information about the En-Nut-Discussion mailing list