[llvmlinux] Can alloca() be used in the kernel instead of VLAIS or VLA?

Behan Webster behanw at converseincode.com
Mon Feb 2 19:28:58 UTC 2015

On 02/02/15 12:12, David Woodhouse wrote:
> On Mon, 2015-02-02 at 10:54 +0100, Behan Webster wrote:
>> The kernel can't use the standard c library. It appears to since the
>> kernel has implemented functions which look like those in the c
>> library. But the kernel is in fact compiled with a bare compiler
>> (essentially all userspace OS related stuff like libraries turned off)
> alloca() isn't really a library thing — it's not as if it can be
> implemented as a function you can call. The compiler has to handle it
> innately.
Look at that, it's a __builtin. That makes sense now that I look at it
more carefully. Cool.

> The real reason we don't use alloca() in the kernel is because the
> kernel has very limited stack space.
That makes sense.

Though for a similarly sized piece of memory you would allocate as an
automatic variable, wouldn't alloca then also be okay?


Behan Webster
behanw at converseincode.com

More information about the LLVMLinux mailing list