Use core::ffi over std::os::raw and libc::c_* (#692)

`core::ffi` is the preferred way to access these type definitions.
Begin removing uses of the versions from `libc`.

`libc::c_void` is not exactly the same as `core::ffi::c_void` but
some code has tried using them interchangeably (like in io-surface).

`libc::size_t` is `usize` on all current platforms.
This commit is contained in:
Bruce Mitchener
2024-08-12 03:24:22 +07:00
committed by GitHub
parent 42ec06106d
commit 9f33b121fb
75 changed files with 302 additions and 322 deletions
+1 -1
View File
@@ -7,7 +7,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::c_void;
use core::ffi::c_void;
use crate::base::{Boolean, CFAllocatorRef, CFComparatorFunction, CFIndex, CFRange, CFTypeID};
use crate::string::CFStringRef;
+1 -1
View File
@@ -11,7 +11,7 @@ use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFRange, CFTypeID, CFTypeRef
use crate::dictionary::CFDictionaryRef;
use crate::string::CFMutableStringRef;
use crate::string::CFStringRef;
use std::os::raw::c_void;
use core::ffi::c_void;
#[repr(C)]
pub struct __CFAttributedString(c_void);
+1 -1
View File
@@ -7,7 +7,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::c_void;
use core::ffi::c_void;
use crate::base::{Boolean, CFAllocatorRef, CFHashCode, CFIndex, CFTypeID};
use crate::string::CFStringRef;
+1 -1
View File
@@ -8,8 +8,8 @@
// except according to those terms.
use crate::string::CFStringRef;
use core::ffi::{c_int, c_short, c_uchar, c_uint, c_ushort, c_void};
use std::cmp::Ordering;
use std::os::raw::{c_int, c_short, c_uchar, c_uint, c_ushort, c_void};
pub type Boolean = u8;
pub type mach_port_t = c_uint;
+1 -1
View File
@@ -7,7 +7,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::c_void;
use core::ffi::c_void;
use crate::base::{Boolean, CFAllocatorRef, CFComparisonResult, CFIndex, CFTypeID};
use crate::string::CFStringRef;
+1 -1
View File
@@ -7,7 +7,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::c_void;
use core::ffi::c_void;
use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFRange, CFTypeID, UInt32, UInt8};
+2 -2
View File
@@ -7,7 +7,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::c_void;
use core::ffi::c_void;
use crate::array::CFArrayRef;
#[cfg(target_os = "macos")]
@@ -17,7 +17,7 @@ use crate::dictionary::CFDictionaryRef;
use crate::error::CFErrorRef;
use crate::string::CFStringRef;
use crate::url::CFURLRef;
use std::os::raw::{c_int, c_uint};
use core::ffi::{c_int, c_uint};
#[repr(C)]
pub struct __CFBundle(c_void);
+1 -1
View File
@@ -7,7 +7,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::{c_char, c_void};
use core::ffi::{c_char, c_void};
use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFOptionFlags, CFRange, CFTypeID};
use crate::date::{CFAbsoluteTime, CFTimeInterval};
+1 -1
View File
@@ -10,7 +10,7 @@
use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFRange, CFTypeID, UTF32Char};
use crate::data::CFDataRef;
use crate::string::{CFStringRef, UniChar};
use std::os::raw::c_void;
use core::ffi::c_void;
pub type CFCharacterSetPredefinedSet = CFIndex;
+1 -1
View File
@@ -8,7 +8,7 @@
// except according to those terms.
use crate::base::{CFAllocatorRef, CFIndex, CFOptionFlags, CFRange, CFTypeID};
use std::os::raw::c_void;
use core::ffi::c_void;
#[repr(C)]
pub struct __CFData(c_void);
+1 -1
View File
@@ -7,7 +7,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::c_void;
use core::ffi::c_void;
use crate::base::{CFAllocatorRef, CFComparisonResult, CFTypeID};
+1 -1
View File
@@ -7,7 +7,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::c_void;
use core::ffi::c_void;
use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFOptionFlags, CFRange, CFTypeID, CFTypeRef};
use crate::date::{CFAbsoluteTime, CFDateRef};
+1 -1
View File
@@ -7,7 +7,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::c_void;
use core::ffi::c_void;
use crate::base::{Boolean, CFAllocatorRef, CFHashCode, CFIndex, CFTypeID};
use crate::string::CFStringRef;
+1 -1
View File
@@ -7,7 +7,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::c_void;
use core::ffi::c_void;
use crate::base::{CFAllocatorRef, CFIndex, CFTypeID};
use crate::dictionary::CFDictionaryRef;
+1 -1
View File
@@ -7,7 +7,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::c_void;
use core::ffi::c_void;
#[cfg(feature = "mac_os_10_8_features")]
use crate::base::CFOptionFlags;
+1 -1
View File
@@ -7,7 +7,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::{c_int, c_void};
use core::ffi::{c_int, c_void};
use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFOptionFlags, CFTypeID};
use crate::runloop::CFRunLoopSourceRef;
+1 -1
View File
@@ -12,7 +12,7 @@ use crate::base::{CFAllocatorRef, CFIndex, CFTypeID, CFTypeRef, LangCode, Region
use crate::dictionary::CFDictionaryRef;
use crate::notification_center::CFNotificationName;
use crate::string::CFStringRef;
use std::os::raw::c_void;
use core::ffi::c_void;
#[repr(C)]
pub struct __CFLocale(c_void);
+1 -1
View File
@@ -11,7 +11,7 @@ use crate::base::{mach_port_t, Boolean};
pub use crate::base::{CFAllocatorRef, CFIndex, CFTypeID};
use crate::runloop::CFRunLoopSourceRef;
use crate::string::CFStringRef;
use std::os::raw::c_void;
use core::ffi::c_void;
#[repr(C)]
pub struct __CFMachPort(c_void);
+1 -1
View File
@@ -7,7 +7,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::c_void;
use core::ffi::c_void;
use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFTypeID, SInt32};
use crate::data::CFDataRef;
@@ -7,7 +7,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::c_void;
use core::ffi::c_void;
use crate::base::{Boolean, CFIndex, CFOptionFlags, CFTypeID};
use crate::dictionary::CFDictionaryRef;
+1 -1
View File
@@ -7,7 +7,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::c_void;
use core::ffi::c_void;
use crate::base::{Boolean, CFAllocatorRef, CFComparisonResult, CFIndex, CFTypeID};
+1 -1
View File
@@ -7,7 +7,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::{c_double, c_void};
use core::ffi::{c_double, c_void};
use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFOptionFlags, CFRange, CFTypeID, CFTypeRef};
use crate::locale::CFLocaleRef;
+1 -1
View File
@@ -7,7 +7,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::c_void;
use core::ffi::c_void;
use crate::array::CFArrayRef;
use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFTypeID};
+1 -1
View File
@@ -7,7 +7,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::c_void;
use core::ffi::c_void;
use crate::array::CFArrayRef;
use crate::base::{
+1 -1
View File
@@ -7,7 +7,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::c_void;
use core::ffi::c_void;
use crate::base::{Boolean, CFAllocatorRef, CFHashCode, CFIndex, CFTypeID};
use crate::string::CFStringRef;
+3 -3
View File
@@ -7,7 +7,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::c_void;
use core::ffi::c_void;
use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFOptionFlags, CFTypeID, SInt32, UInt16};
use crate::data::CFDataRef;
@@ -31,9 +31,9 @@ pub type CFSocketCallBack = extern "C" fn(
info: *mut c_void,
);
#[cfg(not(target_os = "windows"))]
pub type CFSocketNativeHandle = std::os::raw::c_int;
pub type CFSocketNativeHandle = core::ffi::c_int;
#[cfg(target_os = "windows")]
pub type CFSocketNativeHandle = std::os::raw::c_ulong;
pub type CFSocketNativeHandle = core::ffi::c_ulong;
pub const kCFSocketSuccess: CFSocketError = 0;
pub const kCFSocketError: CFSocketError = -1;
+1 -1
View File
@@ -7,7 +7,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::{c_int, c_void};
use core::ffi::{c_int, c_void};
use crate::base::{
Boolean, CFAllocatorRef, CFIndex, CFOptionFlags, CFTypeID, CFTypeRef, SInt32, UInt32, UInt8,
+1 -1
View File
@@ -16,7 +16,7 @@ use crate::characterset::CFCharacterSetRef;
use crate::data::CFDataRef;
use crate::dictionary::CFDictionaryRef;
use crate::locale::CFLocaleRef;
use std::os::raw::{c_char, c_double, c_ulong, c_ushort, c_void};
use core::ffi::{c_char, c_double, c_ulong, c_ushort, c_void};
pub type CFStringCompareFlags = CFOptionFlags;
pub const kCFCompareCaseInsensitive: CFStringCompareFlags = 1;
+1 -1
View File
@@ -7,7 +7,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::c_void;
use core::ffi::c_void;
use crate::array::CFMutableArrayRef;
use crate::base::{CFAllocatorRef, CFIndex, CFOptionFlags, CFRange, CFTypeID, CFTypeRef};
+1 -1
View File
@@ -7,7 +7,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::c_void;
use core::ffi::c_void;
use crate::array::CFArrayRef;
use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFTypeID};
+1 -1
View File
@@ -7,7 +7,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::c_void;
use core::ffi::c_void;
use crate::base::{CFAllocatorRef, CFComparatorFunction, CFIndex, CFTypeID};
use crate::string::CFStringRef;
+1 -1
View File
@@ -7,7 +7,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::c_void;
use core::ffi::c_void;
use crate::array::CFArrayRef;
use crate::base::{
+1 -1
View File
@@ -7,7 +7,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::c_void;
use core::ffi::c_void;
use crate::array::CFArrayRef;
use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFOptionFlags, CFTypeID};
+1 -1
View File
@@ -7,7 +7,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::c_void;
use core::ffi::c_void;
use crate::base::{CFAllocatorRef, CFIndex, CFOptionFlags, CFTypeID, SInt32};
use crate::date::CFTimeInterval;
+1 -1
View File
@@ -7,7 +7,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::c_void;
use core::ffi::c_void;
use crate::base::{CFAllocatorRef, CFTypeID};
use crate::string::CFStringRef;
+1 -1
View File
@@ -7,7 +7,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::{c_char, c_void};
use core::ffi::{c_char, c_void};
use crate::array::CFArrayRef;
use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFTypeID};
+1 -1
View File
@@ -7,7 +7,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::c_void;
use core::ffi::c_void;
use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFOptionFlags, CFTypeID};
use crate::data::CFDataRef;