Skip to content

Commit 9d36a00

Browse files
committed
Auto merge of #2258 - devnexen:crypto_apple_api, r=JohnTitor
apple add platform specific random api
2 parents 783c075 + 10f01db commit 9d36a00

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

libc-test/build.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ fn test_apple(target: &str) {
173173

174174
headers! { cfg:
175175
"aio.h",
176+
"CommonCrypto/CommonCrypto.h",
177+
"CommonCrypto/CommonRandom.h",
176178
"ctype.h",
177179
"dirent.h",
178180
"dlfcn.h",

libc-test/semver/apple.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ BS0
108108
BS1
109109
BSDLY
110110
BUFSIZ
111+
CCStatus
112+
CCCryptorStatus
113+
CCRandomGenerateBytes
114+
CCRNGStatus
111115
CIGNORE
112116
CLD_CONTINUED
113117
CLD_DUMPED

src/unix/bsd/apple/mod.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ pub type thread_latency_qos_policy_t = *mut thread_latency_qos_policy;
7777
pub type thread_throughput_qos_policy_data_t = thread_throughput_qos_policy;
7878
pub type thread_throughput_qos_policy_t = *mut thread_throughput_qos_policy;
7979

80+
pub type CCStatus = i32;
81+
pub type CCCryptorStatus = i32;
82+
pub type CCRNGStatus = ::CCCryptorStatus;
83+
8084
deprecated_mach! {
8185
pub type vm_prot_t = ::c_int;
8286
pub type vm_size_t = ::uintptr_t;
@@ -3515,6 +3519,21 @@ pub const THREAD_BACKGROUND_POLICY_DARWIN_BG: ::c_int = 0x1000;
35153519
pub const THREAD_LATENCY_QOS_POLICY: ::c_int = 7;
35163520
pub const THREAD_THROUGHPUT_QOS_POLICY: ::c_int = 8;
35173521

3522+
// CommonCrypto/CommonCryptoError.h
3523+
pub const kCCSuccess: i32 = 0;
3524+
pub const kCCParamError: i32 = -4300;
3525+
pub const kCCBufferTooSmall: i32 = -4301;
3526+
pub const kCCMemoryFailure: i32 = -4302;
3527+
pub const kCCAlignmentError: i32 = -4303;
3528+
pub const kCCDecodeError: i32 = -4304;
3529+
pub const kCCUnimplemented: i32 = -4305;
3530+
pub const kCCOverflow: i32 = -4306;
3531+
pub const kCCRNGFailure: i32 = -4307;
3532+
pub const kCCUnspecifiedError: i32 = -4308;
3533+
pub const kCCCallSequenceError: i32 = -4309;
3534+
pub const kCCKeySizeError: i32 = -4310;
3535+
pub const kCCInvalidKey: i32 = -4311;
3536+
35183537
cfg_if! {
35193538
if #[cfg(libc_const_extern_fn)] {
35203539
const fn __DARWIN_ALIGN32(p: usize) -> usize {
@@ -4139,6 +4158,8 @@ extern "C" {
41394158
///
41404159
/// `id` is of type [`uuid_t`].
41414160
pub fn gethostuuid(id: *mut u8, timeout: *const ::timespec) -> ::c_int;
4161+
4162+
pub fn CCRandomGenerateBytes(bytes: *mut ::c_void, size: ::size_t) -> ::CCRNGStatus;
41424163
}
41434164

41444165
cfg_if! {

0 commit comments

Comments
 (0)