@@ -3574,6 +3574,23 @@ fn test_vxworks(target: &str) {
35743574 cfg. generate ( src_hotfix_dir ( ) . join ( "lib.rs" ) , "main.rs" ) ;
35753575}
35763576
3577+ fn config_gnu_bits ( target : & str , cfg : & mut ctest:: TestGenerator ) {
3578+ match env:: var ( "RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS" ) {
3579+ Ok ( val) if val == "64" => {
3580+ if target. contains ( "gnu" )
3581+ && target. contains ( "linux" )
3582+ && !target. ends_with ( "x32" )
3583+ && !target. contains ( "riscv32" )
3584+ && env:: var ( "CARGO_CFG_TARGET_POINTER_WIDTH" ) . unwrap ( ) == "32"
3585+ {
3586+ cfg. define ( "_FILE_OFFSET_BITS" , Some ( "64" ) ) ;
3587+ cfg. cfg ( "gnu_file_offset_bits64" , None ) ;
3588+ }
3589+ }
3590+ _ => { }
3591+ }
3592+ }
3593+
35773594fn test_linux ( target : & str ) {
35783595 assert ! ( target. contains( "linux" ) ) ;
35793596
@@ -3617,6 +3634,8 @@ fn test_linux(target: &str) {
36173634 // glibc versions older than 2.29.
36183635 cfg. define ( "__GLIBC_USE_DEPRECATED_SCANF" , None ) ;
36193636
3637+ config_gnu_bits ( target, & mut cfg) ;
3638+
36203639 headers ! { cfg:
36213640 "ctype.h" ,
36223641 "dirent.h" ,
@@ -4064,8 +4083,7 @@ fn test_linux(target: &str) {
40644083 "epoll_params" => true ,
40654084
40664085 // FIXME(linux): Requires >= 6.12 kernel headers.
4067- "dmabuf_cmsg" |
4068- "dmabuf_token" => true ,
4086+ "dmabuf_cmsg" | "dmabuf_token" => true ,
40694087
40704088 _ => false ,
40714089 }
@@ -4779,6 +4797,7 @@ fn test_linux_like_apis(target: &str) {
47794797 if linux || android || emscripten {
47804798 // test strerror_r from the `string.h` header
47814799 let mut cfg = ctest_cfg ( ) ;
4800+ config_gnu_bits ( target, & mut cfg) ;
47824801 cfg. skip_type ( |_| true ) . skip_static ( |_| true ) ;
47834802
47844803 headers ! { cfg: "string.h" }
@@ -4795,6 +4814,7 @@ fn test_linux_like_apis(target: &str) {
47954814 // test fcntl - see:
47964815 // http://man7.org/linux/man-pages/man2/fcntl.2.html
47974816 let mut cfg = ctest_cfg ( ) ;
4817+ config_gnu_bits ( target, & mut cfg) ;
47984818
47994819 if musl {
48004820 cfg. header ( "fcntl.h" ) ;
@@ -4824,6 +4844,7 @@ fn test_linux_like_apis(target: &str) {
48244844 if ( linux && !wali) || android {
48254845 // test termios
48264846 let mut cfg = ctest_cfg ( ) ;
4847+ config_gnu_bits ( target, & mut cfg) ;
48274848 cfg. header ( "asm/termbits.h" ) ;
48284849 cfg. header ( "linux/termios.h" ) ;
48294850 cfg. skip_type ( |_| true )
@@ -4848,6 +4869,7 @@ fn test_linux_like_apis(target: &str) {
48484869 if linux || android {
48494870 // test IPV6_ constants:
48504871 let mut cfg = ctest_cfg ( ) ;
4872+ config_gnu_bits ( target, & mut cfg) ;
48514873 headers ! {
48524874 cfg:
48534875 "linux/in6.h"
@@ -4879,6 +4901,7 @@ fn test_linux_like_apis(target: &str) {
48794901 // "resolve.h" defines a `p_type` macro that expands to `__p_type`
48804902 // making the tests for these fails when both are included.
48814903 let mut cfg = ctest_cfg ( ) ;
4904+ config_gnu_bits ( target, & mut cfg) ;
48824905 cfg. header ( "elf.h" ) ;
48834906 cfg. skip_fn ( |_| true )
48844907 . skip_static ( |_| true )
@@ -4898,6 +4921,7 @@ fn test_linux_like_apis(target: &str) {
48984921 if ( linux && !wali) || android {
48994922 // Test `ARPHRD_CAN`.
49004923 let mut cfg = ctest_cfg ( ) ;
4924+ config_gnu_bits ( target, & mut cfg) ;
49014925 cfg. header ( "linux/if_arp.h" ) ;
49024926 cfg. skip_fn ( |_| true )
49034927 . skip_static ( |_| true )
0 commit comments