There is an amazing feature in a language that is is in alpha called vox. Vox is actually inspired from the D language. This feature is described here and It's an attribute. I'm talking specifically about the @extern(syscall, <num>)
attribute that let's you make an system call and bind it under a name without having any library linked or without having to write any assembly. Is this possible in D?
Thread overview | |||||
---|---|---|---|---|---|
|
November 09, 2021 Can we do system calls like that in D? | ||||
---|---|---|---|---|
| ||||
November 09, 2021 Re: Can we do system calls like that in D? | ||||
---|---|---|---|---|
| ||||
Posted in reply to rempas | On Tuesday, 9 November 2021 at 11:52:10 UTC, rempas wrote:
> It's an attribute. I'm talking specifically about the `@extern(syscall, <num>)` attribute that let's you make an system call and bind it under a name without having any library linked or without having to write any assembly. Is this possible in D?
I'd be very easy to do that as a library mixin. You'd write
@syscall(45) void whatever();
mixin BindSyscalls;
and then the library generates the bodies as inline asm.
|
November 10, 2021 Re: Can we do system calls like that in D? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D Ruppe | On Tuesday, 9 November 2021 at 12:28:59 UTC, Adam D Ruppe wrote:
>
> I'd be very easy to do that as a library mixin. You'd write
>
> @syscall(45) void whatever();
>
> mixin BindSyscalls;
>
> and then the library generates the bodies as inline asm.
Hello Adam! Well this is not exactly the behavior I was looking for, you see in this solution, there are two problems:
1. The mixins will get generated by the compiler (if I'm not mistaken) so it will worsen the compilation times VS if it was a simple function like in Vox.
2. I don't care about the syntax, neither than the fact that you can give the function an name you want (aliases can be used for that) but for the fact that with these way in Vox, you don't have to manually write inline assembly.
It seems that I'm out of luck so inline assembly, here I go (unfortunately)! Thanks for your time and have a great day!
|
Copyright © 1999-2021 by the D Language Foundation