summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-06-28 11:04:52 +0000
committerbors <bors@rust-lang.org>2021-06-28 11:04:52 +0000
commit9d36a00eae27c9fea1b17304001767910db0e52a (patch)
tree9cadbbff8f8905605d4c844bccc5754f10dd4134
parent783c075d3d5064f7c6be142f0949636e6df8aa4a (diff)
parent10f01db46cc86981ac3b49dd7efab3727fe1fafe (diff)
downloadrust-libc-9d36a00eae27c9fea1b17304001767910db0e52a.tar.gz
Auto merge of #2258 - devnexen:crypto_apple_api, r=JohnTitor
apple add platform specific random api
-rwxr-xr-xlibc-test/build.rs2
-rw-r--r--libc-test/semver/apple.txt4
-rw-r--r--src/unix/bsd/apple/mod.rs21
3 files changed, 27 insertions, 0 deletions
diff --git a/libc-test/build.rs b/libc-test/build.rs
index 667585aaf8..81fcc3d308 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 b0080c0cbe..b3a356c05e 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 f50a2bcc9a..655c4c5df4 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! {