@@ -3664,6 +3664,26 @@ fn test_vxworks(target: &str) {
3664
3664
cfg. generate ( src_hotfix_dir ( ) . join ( "lib.rs" ) , "main.rs" ) ;
3665
3665
}
3666
3666
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
+
3667
3687
fn test_linux ( target : & str ) {
3668
3688
assert ! ( target. contains( "linux" ) ) ;
3669
3689
@@ -3707,6 +3727,8 @@ fn test_linux(target: &str) {
3707
3727
// glibc versions older than 2.29.
3708
3728
cfg. define ( "__GLIBC_USE_DEPRECATED_SCANF" , None ) ;
3709
3729
3730
+ config_gnu_bits ( target, & mut cfg) ;
3731
+
3710
3732
headers ! { cfg:
3711
3733
"ctype.h" ,
3712
3734
"dirent.h" ,
@@ -4869,6 +4891,7 @@ fn test_linux_like_apis(target: &str) {
4869
4891
if linux || android || emscripten {
4870
4892
// test strerror_r from the `string.h` header
4871
4893
let mut cfg = ctest_cfg ( ) ;
4894
+ config_gnu_bits ( target, & mut cfg) ;
4872
4895
cfg. skip_type ( |_| true ) . skip_static ( |_| true ) ;
4873
4896
4874
4897
headers ! { cfg: "string.h" }
@@ -4885,6 +4908,7 @@ fn test_linux_like_apis(target: &str) {
4885
4908
// test fcntl - see:
4886
4909
// http://man7.org/linux/man-pages/man2/fcntl.2.html
4887
4910
let mut cfg = ctest_cfg ( ) ;
4911
+ config_gnu_bits ( target, & mut cfg) ;
4888
4912
4889
4913
if musl {
4890
4914
cfg. header ( "fcntl.h" ) ;
@@ -4914,6 +4938,7 @@ fn test_linux_like_apis(target: &str) {
4914
4938
if ( linux && !wali) || android {
4915
4939
// test termios
4916
4940
let mut cfg = ctest_cfg ( ) ;
4941
+ config_gnu_bits ( target, & mut cfg) ;
4917
4942
cfg. header ( "asm/termbits.h" ) ;
4918
4943
cfg. header ( "linux/termios.h" ) ;
4919
4944
cfg. skip_type ( |_| true )
@@ -4938,6 +4963,7 @@ fn test_linux_like_apis(target: &str) {
4938
4963
if linux || android {
4939
4964
// test IPV6_ constants:
4940
4965
let mut cfg = ctest_cfg ( ) ;
4966
+ config_gnu_bits ( target, & mut cfg) ;
4941
4967
headers ! {
4942
4968
cfg:
4943
4969
"linux/in6.h"
@@ -4969,6 +4995,7 @@ fn test_linux_like_apis(target: &str) {
4969
4995
// "resolve.h" defines a `p_type` macro that expands to `__p_type`
4970
4996
// making the tests for these fails when both are included.
4971
4997
let mut cfg = ctest_cfg ( ) ;
4998
+ config_gnu_bits ( target, & mut cfg) ;
4972
4999
cfg. header ( "elf.h" ) ;
4973
5000
cfg. skip_fn ( |_| true )
4974
5001
. skip_static ( |_| true )
@@ -4988,6 +5015,7 @@ fn test_linux_like_apis(target: &str) {
4988
5015
if ( linux && !wali) || android {
4989
5016
// Test `ARPHRD_CAN`.
4990
5017
let mut cfg = ctest_cfg ( ) ;
5018
+ config_gnu_bits ( target, & mut cfg) ;
4991
5019
cfg. header ( "linux/if_arp.h" ) ;
4992
5020
cfg. skip_fn ( |_| true )
4993
5021
. skip_static ( |_| true )
0 commit comments