@@ -3587,6 +3587,26 @@ fn test_vxworks(target: &str) {
35873587 cfg. generate ( src_hotfix_dir ( ) . join ( "lib.rs" ) , "main.rs" ) ;
35883588}
35893589
3590+ fn config_gnu_bits ( target : & str , cfg : & mut ctest:: TestGenerator ) {
3591+ match env:: var ( "RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS" ) {
3592+ Ok ( val) if val == "64" => {
3593+ if target. contains ( "gnu" )
3594+ && target. contains ( "linux" )
3595+ && !target. ends_with ( "x32" )
3596+ && !target. contains ( "riscv32" )
3597+ && env:: var ( "CARGO_CFG_TARGET_POINTER_WIDTH" ) . unwrap ( ) == "32"
3598+ {
3599+ cfg. define ( "_FILE_OFFSET_BITS" , Some ( "64" ) ) ;
3600+ cfg. cfg ( "gnu_file_offset_bits64" , None ) ;
3601+ }
3602+ }
3603+ Ok ( val) if val != "32" => {
3604+ panic ! ( "RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS may only be set to '32' or '64'" )
3605+ }
3606+ _ => { }
3607+ }
3608+ }
3609+
35903610fn test_linux ( target : & str ) {
35913611 assert ! ( target. contains( "linux" ) ) ;
35923612
@@ -3630,6 +3650,8 @@ fn test_linux(target: &str) {
36303650 // glibc versions older than 2.29.
36313651 cfg. define ( "__GLIBC_USE_DEPRECATED_SCANF" , None ) ;
36323652
3653+ config_gnu_bits ( target, & mut cfg) ;
3654+
36333655 headers ! { cfg:
36343656 "ctype.h" ,
36353657 "dirent.h" ,
@@ -4791,6 +4813,7 @@ fn test_linux_like_apis(target: &str) {
47914813 if linux || android || emscripten {
47924814 // test strerror_r from the `string.h` header
47934815 let mut cfg = ctest_cfg ( ) ;
4816+ config_gnu_bits ( target, & mut cfg) ;
47944817 cfg. skip_type ( |_| true ) . skip_static ( |_| true ) ;
47954818
47964819 headers ! { cfg: "string.h" }
@@ -4807,6 +4830,7 @@ fn test_linux_like_apis(target: &str) {
48074830 // test fcntl - see:
48084831 // http://man7.org/linux/man-pages/man2/fcntl.2.html
48094832 let mut cfg = ctest_cfg ( ) ;
4833+ config_gnu_bits ( target, & mut cfg) ;
48104834
48114835 if musl {
48124836 cfg. header ( "fcntl.h" ) ;
@@ -4836,6 +4860,7 @@ fn test_linux_like_apis(target: &str) {
48364860 if ( linux && !wali) || android {
48374861 // test termios
48384862 let mut cfg = ctest_cfg ( ) ;
4863+ config_gnu_bits ( target, & mut cfg) ;
48394864 cfg. header ( "asm/termbits.h" ) ;
48404865 cfg. header ( "linux/termios.h" ) ;
48414866 cfg. skip_type ( |_| true )
@@ -4860,6 +4885,7 @@ fn test_linux_like_apis(target: &str) {
48604885 if linux || android {
48614886 // test IPV6_ constants:
48624887 let mut cfg = ctest_cfg ( ) ;
4888+ config_gnu_bits ( target, & mut cfg) ;
48634889 headers ! {
48644890 cfg:
48654891 "linux/in6.h"
@@ -4891,6 +4917,7 @@ fn test_linux_like_apis(target: &str) {
48914917 // "resolve.h" defines a `p_type` macro that expands to `__p_type`
48924918 // making the tests for these fails when both are included.
48934919 let mut cfg = ctest_cfg ( ) ;
4920+ config_gnu_bits ( target, & mut cfg) ;
48944921 cfg. header ( "elf.h" ) ;
48954922 cfg. skip_fn ( |_| true )
48964923 . skip_static ( |_| true )
@@ -4910,6 +4937,7 @@ fn test_linux_like_apis(target: &str) {
49104937 if ( linux && !wali) || android {
49114938 // Test `ARPHRD_CAN`.
49124939 let mut cfg = ctest_cfg ( ) ;
4940+ config_gnu_bits ( target, & mut cfg) ;
49134941 cfg. header ( "linux/if_arp.h" ) ;
49144942 cfg. skip_fn ( |_| true )
49154943 . skip_static ( |_| true )
0 commit comments