[v2] Unconditonally define alloca as __builtin_alloca

Submitted by Michael Forney on Nov. 19, 2019, 9:56 a.m.

Details

Message ID 20191119095634.24434-1-mforney@mforney.org
State New
Series "Unconditonally define alloca as __builtin_alloca"
Headers show

Commit Message

Michael Forney Nov. 19, 2019, 9:56 a.m.
This enables alternative compilers, which may not define __GNUC__,
to implement alloca, which is still fairly widely used.

This is similar to how stdarg.h already works in musl; compilers must
implement __builtin_va_arg, there is no fallback definition.
---

On 2019-11-19, Szabolcs Nagy <nsz@port70.net> wrote:
> i don't think removing the prototype is a good idea.
> 
> alloca is a builtin in gcc and won't generate an extern
> call even without optimization, so things work now with
> #undef alloca

OK, added back in v2.

 include/alloca.h | 2 --
 1 file changed, 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/include/alloca.h b/include/alloca.h
index d2e6f1c6..b8d183d1 100644
--- a/include/alloca.h
+++ b/include/alloca.h
@@ -10,9 +10,7 @@  extern "C" {
 
 void *alloca(size_t);
 
-#ifdef __GNUC__
 #define alloca __builtin_alloca
-#endif
 
 #ifdef __cplusplus
 }

Comments

Michael Forney Jan. 1, 2020, 8:02 p.m.
On 2019-11-19, Michael Forney <mforney@mforney.org> wrote:
> This enables alternative compilers, which may not define __GNUC__,
> to implement alloca, which is still fairly widely used.
>
> This is similar to how stdarg.h already works in musl; compilers must
> implement __builtin_va_arg, there is no fallback definition.

Ping.
Rich Felker Jan. 1, 2020, 8:08 p.m.
On Wed, Jan 01, 2020 at 12:02:01PM -0800, Michael Forney wrote:
> On 2019-11-19, Michael Forney <mforney@mforney.org> wrote:
> > This enables alternative compilers, which may not define __GNUC__,
> > to implement alloca, which is still fairly widely used.
> >
> > This is similar to how stdarg.h already works in musl; compilers must
> > implement __builtin_va_arg, there is no fallback definition.
> 
> Ping.

I'll go ahead and merge it; I don't think this is terribly
controversial and at worst it compile-time breaks something that's
already not working right.

Rich
Michael Forney Jan. 1, 2020, 8:28 p.m.
On 2020-01-01, Rich Felker <dalias@libc.org> wrote:
> I'll go ahead and merge it; I don't think this is terribly
> controversial and at worst it compile-time breaks something that's
> already not working right.

Thanks! Just wanted to make sure it didn't get forgotten before the
upcoming release.