Can I make system calls directly from D?

rempas rempas at tutanota.com
Fri Jul 9 08:40:28 UTC 2021


On Friday, 9 July 2021 at 08:28:25 UTC, Dennis wrote:
> On Friday, 9 July 2021 at 08:08:57 UTC, rempas wrote:
>> I just wonder if I'm able to do system calls directly from D 
>> or If I have to create bindings from "unistd.h" from C
>
> If with directly means 'without calling any C function' you can 
> use inline assembly:
> ```D
> version(linux)
> void rt_sigreturn() {
>      version(D_InlineAsm_X86_64) asm {
>         naked;
>         mov EAX, 15;
>         syscall;
>     }
> }
> ```

This is the most "direct" way possible. However I should probably 
not mess with assembly at this point and use the built-in D 
header file for unistd. Thanks a lot for your time tho, have a 
great day!


More information about the Digitalmars-d-learn mailing list