@@ -3230,6 +3230,31 @@ fn test_vxworks(target: &str) {
32303230 cfg. generate ( "../src/lib.rs" , "main.rs" ) ;
32313231}
32323232
3233+ fn config_gnu_time64 ( target : & str , cfg : & mut ctest:: TestGenerator ) {
3234+ let gnu = target. contains ( "gnu" ) ;
3235+ let x32 = target. contains ( "x32" ) ;
3236+ let riscv = target. contains ( "riscv32" ) ;
3237+
3238+ if gnu && & env:: var ( "CARGO_CFG_TARGET_POINTER_WIDTH" ) . unwrap ( ) == "32" && !riscv && !x32 {
3239+ match env:: var ( "RUST_LIBC_TIME_BITS" ) {
3240+ Ok ( time_bits) => {
3241+ if time_bits == "64" || time_bits == "default" {
3242+ cfg. define ( "_TIME_BITS" , Some ( "64" ) ) ;
3243+ cfg. define ( "_FILE_OFFSET_BITS" , Some ( "64" ) ) ;
3244+ cfg. cfg ( "gnu_time64_abi" , None ) ;
3245+ } else if time_bits != "32" {
3246+ panic ! ( "Unsupported RUST_LIBC_TIME_BITS value {}" , time_bits)
3247+ }
3248+ }
3249+ Err ( _) => {
3250+ cfg. define ( "_TIME_BITS" , Some ( "64" ) ) ;
3251+ cfg. define ( "_FILE_OFFSET_BITS" , Some ( "64" ) ) ;
3252+ cfg. cfg ( "gnu_time64_abi" , None ) ;
3253+ }
3254+ }
3255+ }
3256+ }
3257+
32333258fn test_linux ( target : & str ) {
32343259 assert ! ( target. contains( "linux" ) ) ;
32353260
@@ -3272,6 +3297,8 @@ fn test_linux(target: &str) {
32723297 // glibc versions older than 2.29.
32733298 cfg. define ( "__GLIBC_USE_DEPRECATED_SCANF" , None ) ;
32743299
3300+ config_gnu_time64 ( target, & mut cfg) ;
3301+
32753302 headers ! { cfg:
32763303 "ctype.h" ,
32773304 "dirent.h" ,
@@ -4394,6 +4421,7 @@ fn test_linux_like_apis(target: &str) {
43944421 if linux || android || emscripten {
43954422 // test strerror_r from the `string.h` header
43964423 let mut cfg = ctest_cfg ( ) ;
4424+ config_gnu_time64 ( target, & mut cfg) ;
43974425 cfg. skip_type ( |_| true ) . skip_static ( |_| true ) ;
43984426
43994427 headers ! { cfg: "string.h" }
@@ -4410,6 +4438,7 @@ fn test_linux_like_apis(target: &str) {
44104438 // test fcntl - see:
44114439 // http://man7.org/linux/man-pages/man2/fcntl.2.html
44124440 let mut cfg = ctest_cfg ( ) ;
4441+ config_gnu_time64 ( target, & mut cfg) ;
44134442
44144443 if musl {
44154444 cfg. header ( "fcntl.h" ) ;
@@ -4439,6 +4468,7 @@ fn test_linux_like_apis(target: &str) {
44394468 if linux || android {
44404469 // test termios
44414470 let mut cfg = ctest_cfg ( ) ;
4471+ config_gnu_time64 ( target, & mut cfg) ;
44424472 cfg. header ( "asm/termbits.h" ) ;
44434473 cfg. header ( "linux/termios.h" ) ;
44444474 cfg. skip_type ( |_| true )
@@ -4463,6 +4493,7 @@ fn test_linux_like_apis(target: &str) {
44634493 if linux || android {
44644494 // test IPV6_ constants:
44654495 let mut cfg = ctest_cfg ( ) ;
4496+ config_gnu_time64 ( target, & mut cfg) ;
44664497 headers ! {
44674498 cfg:
44684499 "linux/in6.h"
@@ -4494,6 +4525,7 @@ fn test_linux_like_apis(target: &str) {
44944525 // "resolve.h" defines a `p_type` macro that expands to `__p_type`
44954526 // making the tests for these fails when both are included.
44964527 let mut cfg = ctest_cfg ( ) ;
4528+ config_gnu_time64 ( target, & mut cfg) ;
44974529 cfg. header ( "elf.h" ) ;
44984530 cfg. skip_fn ( |_| true )
44994531 . skip_static ( |_| true )
@@ -4513,6 +4545,7 @@ fn test_linux_like_apis(target: &str) {
45134545 if linux || android {
45144546 // Test `ARPHRD_CAN`.
45154547 let mut cfg = ctest_cfg ( ) ;
4548+ config_gnu_time64 ( target, & mut cfg) ;
45164549 cfg. header ( "linux/if_arp.h" ) ;
45174550 cfg. skip_fn ( |_| true )
45184551 . skip_static ( |_| true )
0 commit comments