summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorNathan Sashihara <21227491+n8sh@users.noreply.github.com>2018-02-19 07:32:49 -0500
committerNathan Sashihara <21227491+n8sh@users.noreply.github.com>2018-02-21 04:49:48 -0500
commit7ee4af9e79f294033eaa51a2a272606e1630ffcc (patch)
tree022ce4c878192cb673e10a96b0b58ffaa779b903 /source
parentbd2b88f16ece2b0631175bc1f91afae56ba5b3ed (diff)
downloadtanya-7ee4af9e79f294033eaa51a2a272606e1630ffcc.tar.gz
Use correct getrandom linux syscall on non-x86_64
Diffstat (limited to 'source')
-rw-r--r--source/tanya/math/random.d19
1 files changed, 9 insertions, 10 deletions
diff --git a/source/tanya/math/random.d b/source/tanya/math/random.d
index 2275d98..c68f477 100644
--- a/source/tanya/math/random.d
+++ b/source/tanya/math/random.d
@@ -96,7 +96,8 @@ abstract class EntropySource
version (linux)
{
- extern (C) long syscall(long number, ...) nothrow @system @nogc;
+ import core.stdc.config : c_long;
+ extern (C) c_long syscall(c_long number, ...) nothrow @system @nogc;
/**
* Uses getrandom system call.
@@ -137,7 +138,8 @@ version (linux)
do
{
// int getrandom(void *buf, size_t buflen, unsigned int flags);
- auto length = syscall(318, output.ptr, output.length, 0);
+ import mir.linux._asm.unistd : NR_getrandom;
+ auto length = syscall(NR_getrandom, output.ptr, output.length, 0);
Nullable!ubyte ret;
if (length >= 0)
@@ -148,16 +150,13 @@ version (linux)
}
}
- version (X86_64)
+ @nogc @system unittest
{
- private unittest
- {
- auto entropy = defaultAllocator.make!Entropy();
- ubyte[blockSize] output;
- output = entropy.random;
+ auto entropy = defaultAllocator.make!Entropy();
+ ubyte[blockSize] output;
+ output = entropy.random;
- defaultAllocator.dispose(entropy);
- }
+ defaultAllocator.dispose(entropy);
}
}