@@ -3574,6 +3574,25 @@ fn test_vxworks(target: &str) {
3574
3574
cfg. generate ( src_hotfix_dir ( ) . join ( "lib.rs" ) , "main.rs" ) ;
3575
3575
}
3576
3576
3577
+ fn config_gnu_bits ( target : & str , cfg : & mut ctest:: TestGenerator ) {
3578
+ match env:: var ( "RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS64" ) {
3579
+ Ok ( val) => {
3580
+ if val == "1" {
3581
+ if target. contains ( "gnu" )
3582
+ && target. contains ( "linux" )
3583
+ && !target. ends_with ( "x32" )
3584
+ && !target. contains ( "riscv32" )
3585
+ && env:: var ( "CARGO_CFG_TARGET_POINTER_WIDTH" ) . unwrap ( ) == "32"
3586
+ {
3587
+ cfg. define ( "_FILE_OFFSET_BITS" , Some ( "64" ) ) ;
3588
+ cfg. cfg ( "gnu_file_offset_bits64" , None ) ;
3589
+ }
3590
+ }
3591
+ }
3592
+ Err ( _e) => { }
3593
+ }
3594
+ }
3595
+
3577
3596
fn test_linux ( target : & str ) {
3578
3597
assert ! ( target. contains( "linux" ) ) ;
3579
3598
@@ -3617,6 +3636,8 @@ fn test_linux(target: &str) {
3617
3636
// glibc versions older than 2.29.
3618
3637
cfg. define ( "__GLIBC_USE_DEPRECATED_SCANF" , None ) ;
3619
3638
3639
+ config_gnu_bits ( target, & mut cfg) ;
3640
+
3620
3641
headers ! { cfg:
3621
3642
"ctype.h" ,
3622
3643
"dirent.h" ,
@@ -4064,8 +4085,7 @@ fn test_linux(target: &str) {
4064
4085
"epoll_params" => true ,
4065
4086
4066
4087
// FIXME(linux): Requires >= 6.12 kernel headers.
4067
- "dmabuf_cmsg" |
4068
- "dmabuf_token" => true ,
4088
+ "dmabuf_cmsg" | "dmabuf_token" => true ,
4069
4089
4070
4090
_ => false ,
4071
4091
}
@@ -4779,6 +4799,7 @@ fn test_linux_like_apis(target: &str) {
4779
4799
if linux || android || emscripten {
4780
4800
// test strerror_r from the `string.h` header
4781
4801
let mut cfg = ctest_cfg ( ) ;
4802
+ config_gnu_bits ( target, & mut cfg) ;
4782
4803
cfg. skip_type ( |_| true ) . skip_static ( |_| true ) ;
4783
4804
4784
4805
headers ! { cfg: "string.h" }
@@ -4795,6 +4816,7 @@ fn test_linux_like_apis(target: &str) {
4795
4816
// test fcntl - see:
4796
4817
// http://man7.org/linux/man-pages/man2/fcntl.2.html
4797
4818
let mut cfg = ctest_cfg ( ) ;
4819
+ config_gnu_bits ( target, & mut cfg) ;
4798
4820
4799
4821
if musl {
4800
4822
cfg. header ( "fcntl.h" ) ;
@@ -4824,6 +4846,7 @@ fn test_linux_like_apis(target: &str) {
4824
4846
if ( linux && !wali) || android {
4825
4847
// test termios
4826
4848
let mut cfg = ctest_cfg ( ) ;
4849
+ config_gnu_bits ( target, & mut cfg) ;
4827
4850
cfg. header ( "asm/termbits.h" ) ;
4828
4851
cfg. header ( "linux/termios.h" ) ;
4829
4852
cfg. skip_type ( |_| true )
@@ -4848,6 +4871,7 @@ fn test_linux_like_apis(target: &str) {
4848
4871
if linux || android {
4849
4872
// test IPV6_ constants:
4850
4873
let mut cfg = ctest_cfg ( ) ;
4874
+ config_gnu_bits ( target, & mut cfg) ;
4851
4875
headers ! {
4852
4876
cfg:
4853
4877
"linux/in6.h"
@@ -4879,6 +4903,7 @@ fn test_linux_like_apis(target: &str) {
4879
4903
// "resolve.h" defines a `p_type` macro that expands to `__p_type`
4880
4904
// making the tests for these fails when both are included.
4881
4905
let mut cfg = ctest_cfg ( ) ;
4906
+ config_gnu_bits ( target, & mut cfg) ;
4882
4907
cfg. header ( "elf.h" ) ;
4883
4908
cfg. skip_fn ( |_| true )
4884
4909
. skip_static ( |_| true )
@@ -4898,6 +4923,7 @@ fn test_linux_like_apis(target: &str) {
4898
4923
if ( linux && !wali) || android {
4899
4924
// Test `ARPHRD_CAN`.
4900
4925
let mut cfg = ctest_cfg ( ) ;
4926
+ config_gnu_bits ( target, & mut cfg) ;
4901
4927
cfg. header ( "linux/if_arp.h" ) ;
4902
4928
cfg. skip_fn ( |_| true )
4903
4929
. skip_static ( |_| true )
0 commit comments