@@ -3664,6 +3664,26 @@ fn test_vxworks(target: &str) {
36643664 cfg. generate ( src_hotfix_dir ( ) . join ( "lib.rs" ) , "main.rs" ) ;
36653665}
36663666
3667+ fn config_gnu_bits ( target : & str , cfg : & mut ctest:: TestGenerator ) {
3668+ match env:: var ( "RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS" ) {
3669+ Ok ( val) if val == "64" => {
3670+ if target. contains ( "gnu" )
3671+ && target. contains ( "linux" )
3672+ && !target. ends_with ( "x32" )
3673+ && !target. contains ( "riscv32" )
3674+ && env:: var ( "CARGO_CFG_TARGET_POINTER_WIDTH" ) . unwrap ( ) == "32"
3675+ {
3676+ cfg. define ( "_FILE_OFFSET_BITS" , Some ( "64" ) ) ;
3677+ cfg. cfg ( "gnu_file_offset_bits64" , None ) ;
3678+ }
3679+ }
3680+ Ok ( val) if val != "32" => {
3681+ panic ! ( "RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS may only be set to '32' or '64'" )
3682+ }
3683+ _ => { }
3684+ }
3685+ }
3686+
36673687fn test_linux ( target : & str ) {
36683688 assert ! ( target. contains( "linux" ) ) ;
36693689
@@ -3707,6 +3727,8 @@ fn test_linux(target: &str) {
37073727 // glibc versions older than 2.29.
37083728 cfg. define ( "__GLIBC_USE_DEPRECATED_SCANF" , None ) ;
37093729
3730+ config_gnu_bits ( target, & mut cfg) ;
3731+
37103732 headers ! { cfg:
37113733 "ctype.h" ,
37123734 "dirent.h" ,
@@ -4869,6 +4891,7 @@ fn test_linux_like_apis(target: &str) {
48694891 if linux || android || emscripten {
48704892 // test strerror_r from the `string.h` header
48714893 let mut cfg = ctest_cfg ( ) ;
4894+ config_gnu_bits ( target, & mut cfg) ;
48724895 cfg. skip_type ( |_| true ) . skip_static ( |_| true ) ;
48734896
48744897 headers ! { cfg: "string.h" }
@@ -4885,6 +4908,7 @@ fn test_linux_like_apis(target: &str) {
48854908 // test fcntl - see:
48864909 // http://man7.org/linux/man-pages/man2/fcntl.2.html
48874910 let mut cfg = ctest_cfg ( ) ;
4911+ config_gnu_bits ( target, & mut cfg) ;
48884912
48894913 if musl {
48904914 cfg. header ( "fcntl.h" ) ;
@@ -4914,6 +4938,7 @@ fn test_linux_like_apis(target: &str) {
49144938 if ( linux && !wali) || android {
49154939 // test termios
49164940 let mut cfg = ctest_cfg ( ) ;
4941+ config_gnu_bits ( target, & mut cfg) ;
49174942 cfg. header ( "asm/termbits.h" ) ;
49184943 cfg. header ( "linux/termios.h" ) ;
49194944 cfg. skip_type ( |_| true )
@@ -4938,6 +4963,7 @@ fn test_linux_like_apis(target: &str) {
49384963 if linux || android {
49394964 // test IPV6_ constants:
49404965 let mut cfg = ctest_cfg ( ) ;
4966+ config_gnu_bits ( target, & mut cfg) ;
49414967 headers ! {
49424968 cfg:
49434969 "linux/in6.h"
@@ -4969,6 +4995,7 @@ fn test_linux_like_apis(target: &str) {
49694995 // "resolve.h" defines a `p_type` macro that expands to `__p_type`
49704996 // making the tests for these fails when both are included.
49714997 let mut cfg = ctest_cfg ( ) ;
4998+ config_gnu_bits ( target, & mut cfg) ;
49724999 cfg. header ( "elf.h" ) ;
49735000 cfg. skip_fn ( |_| true )
49745001 . skip_static ( |_| true )
@@ -4988,6 +5015,7 @@ fn test_linux_like_apis(target: &str) {
49885015 if ( linux && !wali) || android {
49895016 // Test `ARPHRD_CAN`.
49905017 let mut cfg = ctest_cfg ( ) ;
5018+ config_gnu_bits ( target, & mut cfg) ;
49915019 cfg. header ( "linux/if_arp.h" ) ;
49925020 cfg. skip_fn ( |_| true )
49935021 . skip_static ( |_| true )
0 commit comments