alloca without runtime?

岩倉 澪 via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed May 10 17:47:33 PDT 2017


On Wednesday, 10 May 2017 at 20:25:45 UTC, aberba wrote:
> On Thursday, 4 May 2017 at 14:54:58 UTC, 岩倉 澪 wrote:
>> On Thursday, 4 May 2017 at 12:50:02 UTC, Kagamin wrote:
>>> You can try ldc and llvm intrinsics
>>> http://llvm.org/docs/LangRef.html#alloca-instruction
>>> http://llvm.org/docs/LangRef.html#llvm-stacksave-intrinsic
>>
>> Ah, yep!
>>
>> pragma(LDC_alloca) void* alloca(size_t);
>>
>> This appears to work with ldc. It would be nice if there was a 
>> way to do this with dmd/other compilers as well though. If it 
>> were up to me I'd have alloca defined by the language standard 
>> and every compiler would have to provide an implementation 
>> like this. At the very least I'd like to have an alloca that 
>> works with dmd, as I want to do debug builds with dmd and 
>> release builds with ldc.
>
> embedded platform?

An embedded platform would be a good use-case for this, but I'm 
just trying to do this on Linux x86_64 personally. It's a fun 
experiment to see how far I can push D to give me low-level 
control without dependencies


More information about the Digitalmars-d-learn mailing list