all OS functions should be "nothrow @trusted @nogc"
Steven Schveighoffer via Digitalmars-d
digitalmars-d at puremagic.com
Tue Jul 25 08:12:30 PDT 2017
On 7/25/17 10:27 AM, Shachar Shemesh wrote:
> On 25/07/17 17:12, Stefan Koch wrote:
>> On Tuesday, 25 July 2017 at 13:50:16 UTC, Shachar Shemesh wrote:
>>> The title really does says it all. I keep copying OS function
>>> declarations into my code, just so I can add those attributes to
>>> them. Otherwise I simply cannot call "signalfd" and "sigemptyset" (to
>>> name a couple from my most recent history) from @safe code.
>>>
>>> I can try and set up a PR when I have the time. If anyone else wants
>>> to take an easy one before then, you're welcome to :-)
>>>
>>> Shachar
>>
>> these functions are supposed to have trused wrappers if used in safe
>> code.
>
> I'd love to hear the difference between:
> extern(C) int signalfd (int __fd, const(sigset_t)* __mask, int __flags)
> nothrow @nogc;
>
> and
> int signalfdWrapper(int __fd, const(sigset_t)* __mask, int __flags)
> nothrow @trusted @nogc {
> return signalfd(__fd, __mask, __flags);
> }
I think signalfd can be marked @trusted, as @safe code supports pointing
at a single element.
Other system calls that accept a pointer/length combo cannot be marked
@trusted.
-Steve
More information about the Digitalmars-d
mailing list