@@ -3574,6 +3574,23 @@ 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_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
+
3577
3594
fn test_linux ( target : & str ) {
3578
3595
assert ! ( target. contains( "linux" ) ) ;
3579
3596
@@ -3617,6 +3634,8 @@ fn test_linux(target: &str) {
3617
3634
// glibc versions older than 2.29.
3618
3635
cfg. define ( "__GLIBC_USE_DEPRECATED_SCANF" , None ) ;
3619
3636
3637
+ config_gnu_bits ( target, & mut cfg) ;
3638
+
3620
3639
headers ! { cfg:
3621
3640
"ctype.h" ,
3622
3641
"dirent.h" ,
@@ -4064,8 +4083,7 @@ fn test_linux(target: &str) {
4064
4083
"epoll_params" => true ,
4065
4084
4066
4085
// FIXME(linux): Requires >= 6.12 kernel headers.
4067
- "dmabuf_cmsg" |
4068
- "dmabuf_token" => true ,
4086
+ "dmabuf_cmsg" | "dmabuf_token" => true ,
4069
4087
4070
4088
_ => false ,
4071
4089
}
@@ -4779,6 +4797,7 @@ fn test_linux_like_apis(target: &str) {
4779
4797
if linux || android || emscripten {
4780
4798
// test strerror_r from the `string.h` header
4781
4799
let mut cfg = ctest_cfg ( ) ;
4800
+ config_gnu_bits ( target, & mut cfg) ;
4782
4801
cfg. skip_type ( |_| true ) . skip_static ( |_| true ) ;
4783
4802
4784
4803
headers ! { cfg: "string.h" }
@@ -4795,6 +4814,7 @@ fn test_linux_like_apis(target: &str) {
4795
4814
// test fcntl - see:
4796
4815
// http://man7.org/linux/man-pages/man2/fcntl.2.html
4797
4816
let mut cfg = ctest_cfg ( ) ;
4817
+ config_gnu_bits ( target, & mut cfg) ;
4798
4818
4799
4819
if musl {
4800
4820
cfg. header ( "fcntl.h" ) ;
@@ -4824,6 +4844,7 @@ fn test_linux_like_apis(target: &str) {
4824
4844
if ( linux && !wali) || android {
4825
4845
// test termios
4826
4846
let mut cfg = ctest_cfg ( ) ;
4847
+ config_gnu_bits ( target, & mut cfg) ;
4827
4848
cfg. header ( "asm/termbits.h" ) ;
4828
4849
cfg. header ( "linux/termios.h" ) ;
4829
4850
cfg. skip_type ( |_| true )
@@ -4848,6 +4869,7 @@ fn test_linux_like_apis(target: &str) {
4848
4869
if linux || android {
4849
4870
// test IPV6_ constants:
4850
4871
let mut cfg = ctest_cfg ( ) ;
4872
+ config_gnu_bits ( target, & mut cfg) ;
4851
4873
headers ! {
4852
4874
cfg:
4853
4875
"linux/in6.h"
@@ -4879,6 +4901,7 @@ fn test_linux_like_apis(target: &str) {
4879
4901
// "resolve.h" defines a `p_type` macro that expands to `__p_type`
4880
4902
// making the tests for these fails when both are included.
4881
4903
let mut cfg = ctest_cfg ( ) ;
4904
+ config_gnu_bits ( target, & mut cfg) ;
4882
4905
cfg. header ( "elf.h" ) ;
4883
4906
cfg. skip_fn ( |_| true )
4884
4907
. skip_static ( |_| true )
@@ -4898,6 +4921,7 @@ fn test_linux_like_apis(target: &str) {
4898
4921
if ( linux && !wali) || android {
4899
4922
// Test `ARPHRD_CAN`.
4900
4923
let mut cfg = ctest_cfg ( ) ;
4924
+ config_gnu_bits ( target, & mut cfg) ;
4901
4925
cfg. header ( "linux/if_arp.h" ) ;
4902
4926
cfg. skip_fn ( |_| true )
4903
4927
. skip_static ( |_| true )
0 commit comments