Commit 01fda6199e

Andrew Kelley <superjoe30@gmail.com>
2016-02-14 06:59:49
dummy implementation of os_get_random_bytes for windows
1 parent 1d3c25e
Changed files (1)
std
std/os.zig
@@ -5,13 +5,24 @@ pub error SigInterrupt;
 pub error Unexpected;
 
 pub fn os_get_random_bytes(buf: []u8) -> %void {
-    const amt_got = getrandom(buf.ptr, buf.len, 0);
-    if (amt_got < 0) {
-        return switch (-amt_got) {
-            EINVAL => unreachable{},
-            EFAULT => unreachable{},
-            EINTR  => error.SigInterrupt,
-            else   => error.Unexpected,
-        }
+    switch (@compile_var("os")) {
+        linux => {
+            const amt_got = getrandom(buf.ptr, buf.len, 0);
+            if (amt_got < 0) {
+                return switch (-amt_got) {
+                    EINVAL => unreachable{},
+                    EFAULT => unreachable{},
+                    EINTR  => error.SigInterrupt,
+                    else   => error.Unexpected,
+                }
+            }
+        },
+        windows => {
+            // TODO
+            for (buf) |_, i| {
+                buf[i] = 4;
+            }
+        },
+        else => unreachable{},
     }
 }