@@ -3587,6 +3587,26 @@ fn test_vxworks(target: &str) {
3587
3587
cfg. generate ( src_hotfix_dir ( ) . join ( "lib.rs" ) , "main.rs" ) ;
3588
3588
}
3589
3589
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
+
3590
3610
fn test_linux ( target : & str ) {
3591
3611
assert ! ( target. contains( "linux" ) ) ;
3592
3612
@@ -3630,6 +3650,8 @@ fn test_linux(target: &str) {
3630
3650
// glibc versions older than 2.29.
3631
3651
cfg. define ( "__GLIBC_USE_DEPRECATED_SCANF" , None ) ;
3632
3652
3653
+ config_gnu_bits ( target, & mut cfg) ;
3654
+
3633
3655
headers ! { cfg:
3634
3656
"ctype.h" ,
3635
3657
"dirent.h" ,
@@ -4791,6 +4813,7 @@ fn test_linux_like_apis(target: &str) {
4791
4813
if linux || android || emscripten {
4792
4814
// test strerror_r from the `string.h` header
4793
4815
let mut cfg = ctest_cfg ( ) ;
4816
+ config_gnu_bits ( target, & mut cfg) ;
4794
4817
cfg. skip_type ( |_| true ) . skip_static ( |_| true ) ;
4795
4818
4796
4819
headers ! { cfg: "string.h" }
@@ -4807,6 +4830,7 @@ fn test_linux_like_apis(target: &str) {
4807
4830
// test fcntl - see:
4808
4831
// http://man7.org/linux/man-pages/man2/fcntl.2.html
4809
4832
let mut cfg = ctest_cfg ( ) ;
4833
+ config_gnu_bits ( target, & mut cfg) ;
4810
4834
4811
4835
if musl {
4812
4836
cfg. header ( "fcntl.h" ) ;
@@ -4836,6 +4860,7 @@ fn test_linux_like_apis(target: &str) {
4836
4860
if ( linux && !wali) || android {
4837
4861
// test termios
4838
4862
let mut cfg = ctest_cfg ( ) ;
4863
+ config_gnu_bits ( target, & mut cfg) ;
4839
4864
cfg. header ( "asm/termbits.h" ) ;
4840
4865
cfg. header ( "linux/termios.h" ) ;
4841
4866
cfg. skip_type ( |_| true )
@@ -4860,6 +4885,7 @@ fn test_linux_like_apis(target: &str) {
4860
4885
if linux || android {
4861
4886
// test IPV6_ constants:
4862
4887
let mut cfg = ctest_cfg ( ) ;
4888
+ config_gnu_bits ( target, & mut cfg) ;
4863
4889
headers ! {
4864
4890
cfg:
4865
4891
"linux/in6.h"
@@ -4891,6 +4917,7 @@ fn test_linux_like_apis(target: &str) {
4891
4917
// "resolve.h" defines a `p_type` macro that expands to `__p_type`
4892
4918
// making the tests for these fails when both are included.
4893
4919
let mut cfg = ctest_cfg ( ) ;
4920
+ config_gnu_bits ( target, & mut cfg) ;
4894
4921
cfg. header ( "elf.h" ) ;
4895
4922
cfg. skip_fn ( |_| true )
4896
4923
. skip_static ( |_| true )
@@ -4910,6 +4937,7 @@ fn test_linux_like_apis(target: &str) {
4910
4937
if ( linux && !wali) || android {
4911
4938
// Test `ARPHRD_CAN`.
4912
4939
let mut cfg = ctest_cfg ( ) ;
4940
+ config_gnu_bits ( target, & mut cfg) ;
4913
4941
cfg. header ( "linux/if_arp.h" ) ;
4914
4942
cfg. skip_fn ( |_| true )
4915
4943
. skip_static ( |_| true )
0 commit comments