@@ -219,7 +219,8 @@ fn test_apple(target: &str) {
219
219
let x86_64 = target. contains ( "x86_64" ) ;
220
220
let i686 = target. contains ( "i686" ) ;
221
221
222
- let mut cfg = ctest_cfg ( ) ;
222
+ let mut cfg = ctest_next_cfg ( ) ;
223
+
223
224
cfg. flag ( "-Wno-deprecated-declarations" ) ;
224
225
cfg. define ( "__APPLE_USE_RFC_3542" , None ) ;
225
226
@@ -332,11 +333,12 @@ fn test_apple(target: &str) {
332
333
[ x86_64] : "crt_externs.h" ,
333
334
}
334
335
335
- cfg. skip_struct ( move |ty| {
336
- if ty. starts_with ( "__c_anonymous_" ) {
337
- return true ;
338
- }
339
- match ty {
336
+ // Skip anonymous unions/structs.
337
+ cfg. skip_union ( |u| u. ident ( ) . starts_with ( "__c_anonymous_" ) ) ;
338
+ cfg. skip_struct ( |s| s. ident ( ) . starts_with ( "__c_anonymous_" ) ) ;
339
+
340
+ cfg. skip_struct ( |s| {
341
+ match s. ident ( ) {
340
342
// FIXME(macos): The size is changed in recent macOSes.
341
343
"malloc_zone_t" => true ,
342
344
// it is a moving target, changing through versions
@@ -346,16 +348,13 @@ fn test_apple(target: &str) {
346
348
"malloc_introspection_t" => true ,
347
349
// sonoma changes the padding `rmx_filler` field.
348
350
"rt_metrics" => true ,
349
-
350
351
_ => false ,
351
352
}
352
353
} ) ;
353
354
354
- cfg. skip_type ( move |ty| {
355
- if ty. starts_with ( "__c_anonymous_" ) {
356
- return true ;
357
- }
358
- match ty {
355
+ cfg. skip_alias ( |ty| ty. ident ( ) . starts_with ( "__c_anonymous_" ) ) ;
356
+ cfg. skip_alias ( |ty| {
357
+ match ty. ident ( ) {
359
358
// FIXME(macos): Requires the macOS 14.4 SDK.
360
359
"os_sync_wake_by_address_flags_t" | "os_sync_wait_on_address_flags_t" => true ,
361
360
@@ -366,8 +365,8 @@ fn test_apple(target: &str) {
366
365
}
367
366
} ) ;
368
367
369
- cfg. skip_const ( move |name | {
370
- match name {
368
+ cfg. skip_const ( move |constant | {
369
+ match constant . ident ( ) {
371
370
// These OSX constants are removed in Sierra.
372
371
// https://developer.apple.com/library/content/releasenotes/General/APIDiffsMacOS10_12/Swift/Darwin.html
373
372
"KERN_KDENABLE_BG_TRACE" | "KERN_KDDISABLE_BG_TRACE" => true ,
@@ -387,9 +386,9 @@ fn test_apple(target: &str) {
387
386
}
388
387
} ) ;
389
388
390
- cfg. skip_fn ( move |name | {
389
+ cfg. skip_fn ( move |func | {
391
390
// skip those that are manually verified
392
- match name {
391
+ match func . ident ( ) {
393
392
// close calls the close_nocancel system call
394
393
"close" => true ,
395
394
@@ -418,8 +417,8 @@ fn test_apple(target: &str) {
418
417
}
419
418
} ) ;
420
419
421
- cfg. skip_field ( move |struct_, field| {
422
- match ( struct_, field) {
420
+ cfg. skip_struct_field ( move |struct_, field| {
421
+ match ( struct_. ident ( ) , field. ident ( ) ) {
423
422
// FIXME(macos): the array size has been changed since macOS 10.15 ([8] -> [7]).
424
423
( "statfs" , "f_reserved" ) => true ,
425
424
( "__darwin_arm_neon_state64" , "__v" ) => true ,
@@ -432,39 +431,31 @@ fn test_apple(target: &str) {
432
431
}
433
432
} ) ;
434
433
435
- cfg. volatile_item ( |i| {
436
- use ctest:: VolatileItemKind :: * ;
437
- match i {
438
- StructField ( ref n, ref f) if n == "aiocb" && f == "aio_buf" => true ,
439
- _ => false ,
440
- }
441
- } ) ;
434
+ cfg. volatile_struct_field ( |s, f| s. ident ( ) == "aiocb" && f. ident ( ) == "aio_buf" ) ;
442
435
443
- cfg. type_name ( move |ty, is_struct, is_union| {
444
- match ty {
445
- // Just pass all these through, no need for a "struct" prefix
446
- "FILE" | "DIR" | "Dl_info" => ty. to_string ( ) ,
436
+ cfg. rename_struct_ty ( move |ty| {
437
+ // Just pass all these through, no need for a "struct" prefix
438
+ [ "FILE" , "DIR" , "Dl_info" ]
439
+ . contains ( & ty)
440
+ . then_some ( ty. to_string ( ) )
441
+ } ) ;
447
442
448
- // OSX calls this something else
449
- "sighandler_t" => "sig_t" . to_string ( ) ,
443
+ // OSX calls this something else
444
+ cfg . rename_type ( |ty| ( ty == "sighandler_t" ) . then_some ( "sig_t" . to_string ( ) ) ) ;
450
445
451
- t if is_union => format ! ( "union {t}" ) ,
452
- t if t. ends_with ( "_t" ) => t. to_string ( ) ,
453
- t if is_struct => format ! ( "struct {t}" ) ,
454
- t => t. to_string ( ) ,
455
- }
456
- } ) ;
446
+ cfg. rename_struct_ty ( |ty| ty. ends_with ( "_t" ) . then_some ( ty. to_string ( ) ) ) ;
447
+ cfg. rename_union_ty ( |ty| ty. ends_with ( "_t" ) . then_some ( ty. to_string ( ) ) ) ;
457
448
458
- cfg. field_name ( move |struct_ , field | {
459
- match field {
460
- s if s . ends_with ( "_nsec" ) && struct_ . starts_with ( "stat" ) => {
461
- s . replace ( "e_nsec" , "espec.tv_nsec" )
449
+ cfg. rename_struct_field ( |s , f | {
450
+ match f . ident ( ) {
451
+ n if n . ends_with ( "_nsec" ) && s . ident ( ) . starts_with ( "stat" ) => {
452
+ Some ( n . replace ( "e_nsec" , "espec.tv_nsec" ) )
462
453
}
463
454
// FIXME(macos): sigaction actually contains a union with two variants:
464
455
// a sa_sigaction with type: (*)(int, struct __siginfo *, void *)
465
456
// a sa_handler with type sig_t
466
- "sa_sigaction" if struct_ == "sigaction" => "sa_handler" . to_string ( ) ,
467
- s => s . to_string ( ) ,
457
+ "sa_sigaction" if s . ident ( ) == "sigaction" => Some ( "sa_handler" . to_string ( ) ) ,
458
+ _ => None ,
468
459
}
469
460
} ) ;
470
461
@@ -475,7 +466,8 @@ fn test_apple(target: &str) {
475
466
"uuid_t" | "vol_capabilities_set_t" => true ,
476
467
_ => false ,
477
468
} ) ;
478
- cfg. generate ( src_hotfix_dir ( ) . join ( "lib.rs" ) , "ctest_output.rs" ) ;
469
+
470
+ ctest_next:: generate_test ( & mut cfg, "../src/lib.rs" , "ctest_output.rs" ) . unwrap ( ) ;
479
471
}
480
472
481
473
fn test_openbsd ( target : & str ) {
@@ -806,7 +798,7 @@ fn test_windows(target: &str) {
806
798
let i686 = target. contains ( "i686" ) ;
807
799
808
800
let mut cfg = ctest_next_cfg ( ) ;
809
- cfg . skip_private ( true ) ;
801
+
810
802
if target. contains ( "msvc" ) {
811
803
cfg. flag ( "/wd4324" ) ;
812
804
}
0 commit comments