|
9 | 9 | //! |
10 | 10 | //! [ABI]: https://clang.llvm.org/docs/Block-ABI-Apple.html |
11 | 11 |
|
| 12 | +#![no_std] |
12 | 13 | // Update in Cargo.toml as well. |
13 | 14 | #![doc(html_root_url = "https://docs.rs/block-sys/0.0.3")] |
14 | 15 |
|
| 16 | +extern crate std; |
| 17 | + |
15 | 18 | // Ensure linkage actually happens |
16 | 19 | #[cfg(feature = "gnustep-1-7")] |
17 | 20 | extern crate objc_sys as _; |
@@ -298,7 +301,6 @@ pub struct Block_descriptor { |
298 | 301 | /// |
299 | 302 | /// Requires BLOCK_HAS_SIGNATURE |
300 | 303 | #[repr(C)] |
301 | | -#[cfg(not(feature = "objfw"))] |
302 | 304 | pub struct Block_descriptor_basic { |
303 | 305 | pub header: Block_descriptor_header, |
304 | 306 |
|
@@ -388,3 +390,50 @@ pub struct Block_byref_extended { |
388 | 390 | pub inner: Block_byref, |
389 | 391 | pub layout: *const c_char, |
390 | 392 | } |
| 393 | + |
| 394 | +#[cfg(test)] |
| 395 | +mod tests { |
| 396 | + use super::*; |
| 397 | + use core::ptr; |
| 398 | + use std::println; |
| 399 | + |
| 400 | + #[test] |
| 401 | + fn smoke() { |
| 402 | + assert_eq!(unsafe { _Block_copy(ptr::null()) }, ptr::null_mut()); |
| 403 | + } |
| 404 | + |
| 405 | + #[test] |
| 406 | + fn test_linkable() { |
| 407 | + println!("{:p}", unsafe { &_NSConcreteGlobalBlock }); |
| 408 | + println!("{:p}", unsafe { &_NSConcreteStackBlock }); |
| 409 | + println!("{:p}", unsafe { &_NSConcreteMallocBlock }); |
| 410 | + println!( |
| 411 | + "{:p}", |
| 412 | + _Block_copy as unsafe extern "C" fn(*const c_void) -> *mut c_void |
| 413 | + ); |
| 414 | + println!( |
| 415 | + "{:p}", |
| 416 | + _Block_object_assign |
| 417 | + as unsafe extern "C" fn(*mut c_void, *const c_void, block_assign_dispose_flags) |
| 418 | + ); |
| 419 | + println!( |
| 420 | + "{:p}", |
| 421 | + _Block_object_dispose |
| 422 | + as unsafe extern "C" fn(*const c_void, block_assign_dispose_flags) |
| 423 | + ); |
| 424 | + println!( |
| 425 | + "{:p}", |
| 426 | + _Block_release as unsafe extern "C" fn(*const c_void) |
| 427 | + ); |
| 428 | + #[cfg(any(feature = "apple", feature = "compiler-rt"))] |
| 429 | + { |
| 430 | + println!("{:p}", unsafe { &_NSConcreteAutoBlock }); |
| 431 | + println!("{:p}", unsafe { &_NSConcreteFinalizingBlock }); |
| 432 | + println!("{:p}", unsafe { &_NSConcreteWeakBlockVariable }); |
| 433 | + println!( |
| 434 | + "{:p}", |
| 435 | + Block_size as unsafe extern "C" fn(*mut c_void) -> c_ulong |
| 436 | + ); |
| 437 | + } |
| 438 | + } |
| 439 | +} |
0 commit comments