mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 23:28:48 +00:00
add crypto.rand_bytes for Darwin and FreeBSD
This commit is contained in:
@@ -0,0 +1,12 @@
|
|||||||
|
//+build freebsd, openbsd, darwin
|
||||||
|
package crypto
|
||||||
|
|
||||||
|
foreign import libc "system:c"
|
||||||
|
|
||||||
|
foreign libc {
|
||||||
|
arc4random_buf :: proc(buf: [^]byte, nbytes: uint) ---
|
||||||
|
}
|
||||||
|
|
||||||
|
_rand_bytes :: proc(dst: []byte) {
|
||||||
|
arc4random_buf(raw_data(dst), len(dst))
|
||||||
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
|
//+build !linux !windows !openbsd !freebsd !darwin !js
|
||||||
package crypto
|
package crypto
|
||||||
|
|
||||||
when ODIN_OS != .Linux && ODIN_OS != .OpenBSD && ODIN_OS != .Windows && ODIN_OS != .JS {
|
_rand_bytes :: proc(dst: []byte) {
|
||||||
_rand_bytes :: proc(dst: []byte) {
|
unimplemented("crypto: rand_bytes not supported on this OS")
|
||||||
unimplemented("crypto: rand_bytes not supported on this OS")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
package crypto
|
|
||||||
|
|
||||||
import "core:c"
|
|
||||||
|
|
||||||
foreign import libc "system:c"
|
|
||||||
foreign libc {
|
|
||||||
arc4random_buf :: proc "c" (buf: rawptr, nbytes: c.size_t) ---
|
|
||||||
}
|
|
||||||
|
|
||||||
_rand_bytes :: proc (dst: []byte) {
|
|
||||||
arc4random_buf(raw_data(dst), len(dst))
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user