| author | |
| committer | |
| log | a92be498517e316d6deaf42dbd51a3c9e28899ca |
| tree | c2e3a031a0184566b9b693f006c3aac5e894e77a |
| parent | 421022929a5b0d8b439796e92beb3acb665f7656 |
This reverts commit a11113097730693fb915114cec79df9cb4adcc93, reversing
changes made to 9f3f9fb40f605de2f2bdcd0ce7a396e06b8b8c0d.2 files changed, 2 insertions(+), 41 deletions(-)
lib/std/c/darwin.zig-28| ... | ... | @@ -895,35 +895,7 @@ pub extern "c" fn pthread_attr_get_qos_class_np(attr: *pthread_attr_t, qos_class |
| 895 | 895 | pub extern "c" fn pthread_set_qos_class_self_np(qos_class: qos_class_t, relative_priority: c_int) c_int; |
| 896 | 896 | pub extern "c" fn pthread_get_qos_class_np(pthread: std.c.pthread_t, qos_class: *qos_class_t, relative_priority: *c_int) c_int; |
| 897 | 897 | |
| 898 | pub const CCryptorStatus = enum(i32) { | |
| 899 | /// Operation completed | |
| 900 | kCCSuccess = 0, | |
| 901 | /// Illegal parameter | |
| 902 | kCCParamError = -4300, | |
| 903 | /// Provided buffer too small | |
| 904 | kCCBufferTooSmall = -4301, | |
| 905 | /// Failed memory allocation | |
| 906 | kCCMemoryFailure = -4302, | |
| 907 | /// Size alignment issue | |
| 908 | kCCAlignmentError = -4303, | |
| 909 | /// Decoding issue | |
| 910 | kCCDecodeError = -4304, | |
| 911 | /// Call not implemented | |
| 912 | kCCUnimplemented = -4305, | |
| 913 | kCCOverflow = -4306, | |
| 914 | kCCRNGFailure = -4307, | |
| 915 | /// Unspecified error | |
| 916 | kCCUnspecifiedError = -4308, | |
| 917 | kCCCallSequenceError = -4309, | |
| 918 | kCCKeySizeError = -4310, | |
| 919 | /// Invalid key | |
| 920 | kCCInvalidKey = -4311, | |
| 921 | }; | |
| 922 | ||
| 923 | pub const CCRNGStatus = CCryptorStatus; | |
| 924 | ||
| 925 | 898 | pub extern "c" fn arc4random_buf(buf: [*]u8, len: usize) void; |
| 926 | pub extern "c" fn CCRandomGenerateBytes(bytes: ?*anyopaque, count: usize) CCRNGStatus; | |
| 927 | 899 | |
| 928 | 900 | // Grand Central Dispatch is exposed by libSystem. |
| 929 | 901 | pub extern "c" fn dispatch_release(object: *anyopaque) void; |
lib/std/os.zig+2-13| ... | ... | @@ -517,18 +517,7 @@ pub fn getrandom(buffer: []u8) GetRandomError!void { |
| 517 | 517 | return; |
| 518 | 518 | } |
| 519 | 519 | switch (builtin.os.tag) { |
| 520 | .macos, .ios => { | |
| 521 | const rc = darwin.CCRandomGenerateBytes(buffer.ptr, buffer.len); | |
| 522 | if (rc != darwin.CCRNGStatus.kCCSuccess) { | |
| 523 | if (rc == darwin.CCRNGStatus.kCCParamError or rc == darwin.CCRNGStatus.kCCBufferTooSmall) { | |
| 524 | return error.InvalidHandle; | |
| 525 | } else { | |
| 526 | return error.SystemResources; | |
| 527 | } | |
| 528 | } | |
| 529 | return; | |
| 530 | }, | |
| 531 | .netbsd, .openbsd, .tvos, .watchos => { | |
| 520 | .netbsd, .openbsd, .macos, .ios, .tvos, .watchos => { | |
| 532 | 521 | system.arc4random_buf(buffer.ptr, buffer.len); |
| 533 | 522 | return; |
| 534 | 523 | }, |
| ... | ... | @@ -1001,7 +990,7 @@ pub fn preadv(fd: fd_t, iov: []const iovec, offset: u64) PReadError!usize { |
| 1001 | 990 | if (have_pread_but_not_preadv) { |
| 1002 | 991 | // We could loop here; but proper usage of `preadv` must handle partial reads anyway. |
| 1003 | 992 | // So we simply read into the first vector only. |
| 1004 | if (iov.len == 0) return @as(usize, @intCast(0)); | |
| 993 | if (iov.len == 0) return 0; | |
| 1005 | 994 | const first = iov[0]; |
| 1006 | 995 | return pread(fd, first.iov_base[0..first.iov_len], offset); |
| 1007 | 996 | } |