[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] Proposal for handling alloca(). Anyone see a problem

From: Dave Dodge
Subject: Re: [Tinycc-devel] Proposal for handling alloca(). Anyone see a problem with it?
Date: Tue, 8 May 2007 04:37:48 -0400
User-agent: Mutt/1.5.12-2006-07-14

On Mon, May 07, 2007 at 12:31:00PM -0400, David A. Wheeler wrote:
> There are minor downsides. It's not QUITE as efficient as a
> traditional alloca(), because you're fiddling with malloc() instead
> of changing the stack pointer.  If threading were introduced, these
> alloca lists would need to be stored per-thread and malloc would
> have to be thread-safe, which is doable though annoying.

POSIX requires malloc() to be thread-safe, so in the presence of
threads you'd be okay with this design once you had the per-thread
lists worked out.

There is however a more subtle issue: POSIX does not require malloc()
to be async-signal-safe.  So if alloca() invokes malloc(), that makes
calling alloca() within a signal handler potentially undefined.  Since
alloca() is not a very well standardized function to begin with, I
don't know if there is any code that expects that to work.

                                                  -Dave Dodge

reply via email to

[Prev in Thread] Current Thread [Next in Thread]