@@ -226,7 +226,8 @@ fn test_apple(target: &str) {
226
226
let x86_64 = target. contains ( "x86_64" ) ;
227
227
let i686 = target. contains ( "i686" ) ;
228
228
229
- let mut cfg = ctest_cfg ( ) ;
229
+ let mut cfg = ctest_next_cfg ( ) ;
230
+
230
231
cfg. flag ( "-Wno-deprecated-declarations" ) ;
231
232
cfg. define ( "__APPLE_USE_RFC_3542" , None ) ;
232
233
@@ -347,31 +348,28 @@ fn test_apple(target: &str) {
347
348
[ x86_64] : "crt_externs.h" ,
348
349
}
349
350
350
- cfg. skip_struct ( move |ty| {
351
- if ty. starts_with ( "__c_anonymous_" ) {
352
- return true ;
353
- }
354
- match ty {
351
+ // Skip anonymous unions/structs.
352
+ cfg. skip_union ( |u| u. ident ( ) . starts_with ( "__c_anonymous_" ) ) ;
353
+ cfg. skip_struct ( |s| s. ident ( ) . starts_with ( "__c_anonymous_" ) ) ;
354
+
355
+ cfg. skip_struct ( |s| {
356
+ match s. ident ( ) {
355
357
// FIXME(union): actually a union
356
358
"sigval" => true ,
357
-
358
359
// FIXME(macos): The size is changed in recent macOSes.
359
360
"malloc_zone_t" => true ,
360
361
// it is a moving target, changing through versions
361
362
// also contains bitfields members
362
363
"tcp_connection_info" => true ,
363
364
// FIXME(macos): The size is changed in recent macOSes.
364
365
"malloc_introspection_t" => true ,
365
-
366
366
_ => false ,
367
367
}
368
368
} ) ;
369
369
370
- cfg. skip_type ( move |ty| {
371
- if ty. starts_with ( "__c_anonymous_" ) {
372
- return true ;
373
- }
374
- match ty {
370
+ cfg. skip_alias ( |ty| ty. ident ( ) . starts_with ( "__c_anonymous_" ) ) ;
371
+ cfg. skip_alias ( |ty| {
372
+ match ty. ident ( ) {
375
373
// FIXME(macos): Requires the macOS 14.4 SDK.
376
374
"os_sync_wake_by_address_flags_t" | "os_sync_wait_on_address_flags_t" => true ,
377
375
@@ -382,12 +380,10 @@ fn test_apple(target: &str) {
382
380
}
383
381
} ) ;
384
382
385
- cfg. skip_const ( move |name| {
386
- // They're declared via `deprecated_mach` and we don't support it anymore.
387
- if name. starts_with ( "VM_FLAGS_" ) {
388
- return true ;
389
- }
390
- match name {
383
+ cfg. skip_const ( move |constant| {
384
+ match constant. ident ( ) {
385
+ // They're declared via `deprecated_mach` and we don't support it anymore.
386
+ x if x. starts_with ( "VM_FLAGS_" ) => true ,
391
387
// These OSX constants are removed in Sierra.
392
388
// https://developer.apple.com/library/content/releasenotes/General/APIDiffsMacOS10_12/Swift/Darwin.html
393
389
"KERN_KDENABLE_BG_TRACE" | "KERN_KDDISABLE_BG_TRACE" => true ,
@@ -407,12 +403,11 @@ fn test_apple(target: &str) {
407
403
}
408
404
} ) ;
409
405
410
- cfg. skip_fn ( move |name | {
406
+ cfg. skip_fn ( move |func | {
411
407
// skip those that are manually verified
412
- match name {
408
+ match func . ident ( ) {
413
409
// FIXME: https://github.com/rust-lang/libc/issues/1272
414
410
"execv" | "execve" | "execvp" => true ,
415
-
416
411
// close calls the close_nocancel system call
417
412
"close" => true ,
418
413
@@ -441,8 +436,8 @@ fn test_apple(target: &str) {
441
436
}
442
437
} ) ;
443
438
444
- cfg. skip_field ( move |struct_, field| {
445
- match ( struct_, field) {
439
+ cfg. skip_struct_field ( move |struct_, field| {
440
+ match ( struct_. ident ( ) , field. ident ( ) ) {
446
441
// FIXME(macos): the array size has been changed since macOS 10.15 ([8] -> [7]).
447
442
( "statfs" , "f_reserved" ) => true ,
448
443
( "__darwin_arm_neon_state64" , "__v" ) => true ,
@@ -459,47 +454,39 @@ fn test_apple(target: &str) {
459
454
}
460
455
} ) ;
461
456
462
- cfg. skip_field_type ( move |struct_, field| {
463
- match ( struct_, field) {
457
+ cfg. skip_struct_field_type ( move |struct_, field| {
458
+ match ( struct_. ident ( ) , field. ident ( ) ) {
464
459
// FIXME(union): actually a union
465
460
( "sigevent" , "sigev_value" ) => true ,
466
461
_ => false ,
467
462
}
468
463
} ) ;
469
464
470
- cfg. volatile_item ( |i| {
471
- use ctest:: VolatileItemKind :: * ;
472
- match i {
473
- StructField ( ref n, ref f) if n == "aiocb" && f == "aio_buf" => true ,
474
- _ => false ,
475
- }
465
+ cfg. volatile_struct_field ( |s, f| s. ident ( ) == "aiocb" && f. ident ( ) == "aio_buf" ) ;
466
+
467
+ cfg. rename_struct_ty ( move |ty| {
468
+ // Just pass all these through, no need for a "struct" prefix
469
+ [ "FILE" , "DIR" , "Dl_info" ]
470
+ . contains ( & ty)
471
+ . then_some ( ty. to_string ( ) )
476
472
} ) ;
477
473
478
- cfg. type_name ( move |ty, is_struct, is_union| {
479
- match ty {
480
- // Just pass all these through, no need for a "struct" prefix
481
- "FILE" | "DIR" | "Dl_info" => ty. to_string ( ) ,
474
+ // OSX calls this something else
475
+ cfg. rename_type ( |ty| ( ty == "sighandler_t" ) . then_some ( "sig_t" . to_string ( ) ) ) ;
482
476
483
- // OSX calls this something else
484
- "sighandler_t" => "sig_t" . to_string ( ) ,
477
+ cfg . rename_struct_ty ( |ty| ty . ends_with ( "_t" ) . then_some ( ty . to_string ( ) ) ) ;
478
+ cfg . rename_union_ty ( |ty| ty . ends_with ( "_t" ) . then_some ( ty . to_string ( ) ) ) ;
485
479
486
- t if is_union => format ! ( "union {t}" ) ,
487
- t if t. ends_with ( "_t" ) => t. to_string ( ) ,
488
- t if is_struct => format ! ( "struct {t}" ) ,
489
- t => t. to_string ( ) ,
490
- }
491
- } ) ;
492
-
493
- cfg. field_name ( move |struct_, field| {
494
- match field {
495
- s if s. ends_with ( "_nsec" ) && struct_. starts_with ( "stat" ) => {
496
- s. replace ( "e_nsec" , "espec.tv_nsec" )
480
+ cfg. rename_struct_field ( |s, f| {
481
+ match f. ident ( ) {
482
+ n if n. ends_with ( "_nsec" ) && s. ident ( ) . starts_with ( "stat" ) => {
483
+ Some ( n. replace ( "e_nsec" , "espec.tv_nsec" ) )
497
484
}
498
485
// FIXME(macos): sigaction actually contains a union with two variants:
499
486
// a sa_sigaction with type: (*)(int, struct __siginfo *, void *)
500
487
// a sa_handler with type sig_t
501
- "sa_sigaction" if struct_ == "sigaction" => "sa_handler" . to_string ( ) ,
502
- s => s . to_string ( ) ,
488
+ "sa_sigaction" if s . ident ( ) == "sigaction" => Some ( "sa_handler" . to_string ( ) ) ,
489
+ _ => None ,
503
490
}
504
491
} ) ;
505
492
@@ -510,7 +497,8 @@ fn test_apple(target: &str) {
510
497
"uuid_t" | "vol_capabilities_set_t" => true ,
511
498
_ => false ,
512
499
} ) ;
513
- cfg. generate ( src_hotfix_dir ( ) . join ( "lib.rs" ) , "ctest_output.rs" ) ;
500
+
501
+ ctest_next:: generate_test ( & mut cfg, "../src/lib.rs" , "ctest_output.rs" ) . unwrap ( ) ;
514
502
}
515
503
516
504
fn test_openbsd ( target : & str ) {
@@ -881,7 +869,7 @@ fn test_windows(target: &str) {
881
869
let i686 = target. contains ( "i686" ) ;
882
870
883
871
let mut cfg = ctest_next_cfg ( ) ;
884
- cfg . skip_private ( true ) ;
872
+
885
873
if target. contains ( "msvc" ) {
886
874
cfg. flag ( "/wd4324" ) ;
887
875
}
0 commit comments