mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
remove "import const" everywhere
This commit is contained in:
@@ -8,10 +8,6 @@ import math
|
||||
|
||||
#include <sys/syscall.h>
|
||||
|
||||
import const(
|
||||
SYS_getrandom
|
||||
)
|
||||
|
||||
// const (
|
||||
// SYS_getrandom = 278 // AArch65
|
||||
// SYS_getrandom = 384 // ARM
|
||||
@@ -47,5 +43,5 @@ fn _getrandom(bytes_needed int, buffer voidptr) int {
|
||||
if bytes_needed > ReadBatchSize {
|
||||
panic('_getrandom() dont request more thane $ReadBatchSize bytes at once.')
|
||||
}
|
||||
return C.syscall(SYS_getrandom, buffer, bytes_needed, 0)
|
||||
return C.syscall(C.SYS_getrandom, buffer, bytes_needed, 0)
|
||||
}
|
||||
|
||||
@@ -6,20 +6,10 @@ module rand
|
||||
|
||||
#flag darwin -framework Security
|
||||
|
||||
// import const (
|
||||
// kSecRandomDefault
|
||||
// errSecSuccess
|
||||
// )
|
||||
|
||||
const (
|
||||
kSecRandomDefault = 0
|
||||
errSecSuccess = 0
|
||||
)
|
||||
|
||||
pub fn read(bytes_needed int) ?[]byte {
|
||||
mut buffer := malloc(bytes_needed)
|
||||
status := C.SecRandomCopyBytes(kSecRandomDefault, bytes_needed, buffer)
|
||||
if status != errSecSuccess {
|
||||
status := C.SecRandomCopyBytes(0, bytes_needed, buffer)
|
||||
if status != 0 {
|
||||
return ReadError
|
||||
}
|
||||
return c_array_to_bytes_tmp(bytes_needed, buffer)
|
||||
|
||||
Reference in New Issue
Block a user