authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-07-31 11:13:27-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-07-31 11:13:27-07:00
loga92be498517e316d6deaf42dbd51a3c9e28899ca
treec2e3a031a0184566b9b693f006c3aac5e894e77a
parent421022929a5b0d8b439796e92beb3acb665f7656

Revert "Merge pull request #15317 from devnexen/darwin_rand_nativegen"

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,35 +895,7 @@ pub extern "c" fn pthread_attr_get_qos_class_np(attr: *pthread_attr_t, qos_class
895pub extern "c" fn pthread_set_qos_class_self_np(qos_class: qos_class_t, relative_priority: c_int) c_int;895pub extern "c" fn pthread_set_qos_class_self_np(qos_class: qos_class_t, relative_priority: c_int) c_int;
896pub extern "c" fn pthread_get_qos_class_np(pthread: std.c.pthread_t, qos_class: *qos_class_t, relative_priority: *c_int) c_int;896pub extern "c" fn pthread_get_qos_class_np(pthread: std.c.pthread_t, qos_class: *qos_class_t, relative_priority: *c_int) c_int;
897897
898pub 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
923pub const CCRNGStatus = CCryptorStatus;
924
925pub extern "c" fn arc4random_buf(buf: [*]u8, len: usize) void;898pub extern "c" fn arc4random_buf(buf: [*]u8, len: usize) void;
926pub extern "c" fn CCRandomGenerateBytes(bytes: ?*anyopaque, count: usize) CCRNGStatus;
927899
928// Grand Central Dispatch is exposed by libSystem.900// Grand Central Dispatch is exposed by libSystem.
929pub extern "c" fn dispatch_release(object: *anyopaque) void;901pub 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,18 +517,7 @@ pub fn getrandom(buffer: []u8) GetRandomError!void {
517 return;517 return;
518 }518 }
519 switch (builtin.os.tag) {519 switch (builtin.os.tag) {
520 .macos, .ios => {520 .netbsd, .openbsd, .macos, .ios, .tvos, .watchos => {
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 => {
532 system.arc4random_buf(buffer.ptr, buffer.len);521 system.arc4random_buf(buffer.ptr, buffer.len);
533 return;522 return;
534 },523 },
...@@ -1001,7 +990,7 @@ pub fn preadv(fd: fd_t, iov: []const iovec, offset: u64) PReadError!usize {...@@ -1001,7 +990,7 @@ pub fn preadv(fd: fd_t, iov: []const iovec, offset: u64) PReadError!usize {
1001 if (have_pread_but_not_preadv) {990 if (have_pread_but_not_preadv) {
1002 // We could loop here; but proper usage of `preadv` must handle partial reads anyway.991 // We could loop here; but proper usage of `preadv` must handle partial reads anyway.
1003 // So we simply read into the first vector only.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 const first = iov[0];994 const first = iov[0];
1006 return pread(fd, first.iov_base[0..first.iov_len], offset);995 return pread(fd, first.iov_base[0..first.iov_len], offset);
1007 }996 }