From 10f01db46cc86981ac3b49dd7efab3727fe1fafe Mon Sep 17 00:00:00 2001 From: David CARLIER Date: Fri, 25 Jun 2021 15:44:56 +0100 Subject: [PATCH] apple add platform specific random api --- libc-test/build.rs | 2 ++ libc-test/semver/apple.txt | 4 ++++ src/unix/bsd/apple/mod.rs | 21 +++++++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index 667585aa..81fcc3d3 100755 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -173,6 +173,8 @@ fn test_apple(target: &str) { headers! { cfg: "aio.h", + "CommonCrypto/CommonCrypto.h", + "CommonCrypto/CommonRandom.h", "ctype.h", "dirent.h", "dlfcn.h", diff --git a/libc-test/semver/apple.txt b/libc-test/semver/apple.txt index b0080c0c..b3a356c0 100644 --- a/libc-test/semver/apple.txt +++ b/libc-test/semver/apple.txt @@ -108,6 +108,10 @@ BS0 BS1 BSDLY BUFSIZ +CCStatus +CCCryptorStatus +CCRandomGenerateBytes +CCRNGStatus CIGNORE CLD_CONTINUED CLD_DUMPED diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index f50a2bcc..655c4c5d 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -77,6 +77,10 @@ pub type thread_latency_qos_policy_t = *mut thread_latency_qos_policy; pub type thread_throughput_qos_policy_data_t = thread_throughput_qos_policy; pub type thread_throughput_qos_policy_t = *mut thread_throughput_qos_policy; +pub type CCStatus = i32; +pub type CCCryptorStatus = i32; +pub type CCRNGStatus = ::CCCryptorStatus; + deprecated_mach! { pub type vm_prot_t = ::c_int; pub type vm_size_t = ::uintptr_t; @@ -3515,6 +3519,21 @@ pub const THREAD_BACKGROUND_POLICY_DARWIN_BG: ::c_int = 0x1000; pub const THREAD_LATENCY_QOS_POLICY: ::c_int = 7; pub const THREAD_THROUGHPUT_QOS_POLICY: ::c_int = 8; +// CommonCrypto/CommonCryptoError.h +pub const kCCSuccess: i32 = 0; +pub const kCCParamError: i32 = -4300; +pub const kCCBufferTooSmall: i32 = -4301; +pub const kCCMemoryFailure: i32 = -4302; +pub const kCCAlignmentError: i32 = -4303; +pub const kCCDecodeError: i32 = -4304; +pub const kCCUnimplemented: i32 = -4305; +pub const kCCOverflow: i32 = -4306; +pub const kCCRNGFailure: i32 = -4307; +pub const kCCUnspecifiedError: i32 = -4308; +pub const kCCCallSequenceError: i32 = -4309; +pub const kCCKeySizeError: i32 = -4310; +pub const kCCInvalidKey: i32 = -4311; + cfg_if! { if #[cfg(libc_const_extern_fn)] { const fn __DARWIN_ALIGN32(p: usize) -> usize { @@ -4139,6 +4158,8 @@ extern "C" { /// /// `id` is of type [`uuid_t`]. pub fn gethostuuid(id: *mut u8, timeout: *const ::timespec) -> ::c_int; + + pub fn CCRandomGenerateBytes(bytes: *mut ::c_void, size: ::size_t) -> ::CCRNGStatus; } cfg_if! {