mir-linux-kernel 1.0.0: Linux system call numbers for different architectures

Nathan S. no.public.email at example.com
Fri Nov 10 18:27:36 UTC 2017


About package
--------------
Linux system call numbers for different architectures. That's all.

https://code.dlang.org/packages/mir-linux-kernel


Motivating Example
--------------
Linux 3.17 added the getrandom syscall. Using it instead of 
/dev/[u]?random was a win. But we didn't think about all of the 
architectures that people might try building our library on, and 
soon we got a report from a user that our latest and greatest 
release was failing to compile on Raspberry Pi.


Example
--------------
import mir.linux._asm.unistd: NR_getrandom;

/*
  *   If the GRND_NONBLOCK flag is set, then
  *   getrandom() does not block in these cases, but instead
  *   immediately returns -1 with errno set to EAGAIN.
  */
private ptrdiff_t genRandomImplSysNonBlocking(scope void* ptr, 
size_t len) @nogc nothrow @system
{
     return syscall(NR_getrandom, cast(size_t) ptr, len, 
GRND_NONBLOCK);
}



More information about the Digitalmars-d-announce mailing list