Using GCC's builtin alloca without the C standard library

Iain Buclaw ibuclaw at gdcproject.org
Mon Jul 23 10:09:59 UTC 2018


On 23 July 2018 at 09:15, Johannes Pfau via D.gnu <d.gnu at puremagic.com> wrote:
> Am Mon, 23 Jul 2018 01:35:02 +0000 schrieb Mike Franklin:
>
>> I'd like to be able to use GCC's `__builtin_alloca` without the C
>> standard library.
>>
>
> Just import gcc.builtins for all GCC builtins:
>
> ----------------------------
> import gcc.builtins;
>
> void main()
> {
>     auto foo = __builtin_alloca(10);
> }
> ----------------------------
>

Assuming that you are already using the gcc.attribute module for
accessing various attributes, possibly via a wrapper module.

There's probably a project to be made for adding pragmas as an
alternative to the various magic modules and attributes we have in the
compiler, but first requires a little nip and tuck to make it more
friendly for us to add these to gdc.

https://issues.dlang.org/show_bug.cgi?id=3004
https://issues.dlang.org/show_bug.cgi?id=19108
https://issues.dlang.org/show_bug.cgi?id=19109
https://issues.dlang.org/show_bug.cgi?id=19110

As well as 'pragma(GNU_builtin)', there are these such options that
can't be done using UDAs.

https://gcc.gnu.org/onlinedocs/gcc/Loop-Specific-Pragmas.html

Iain.


More information about the D.gnu mailing list