Skip to content

Commit 6e9fa92

Browse files
committed
libc-test: Set the gnu time64 preprocessor symbols for all ptr32
Set _TIME_BITS=64 and _FILE_OFFSET_BITS=64 preprocessor symbols for the C test code as for building the code.
1 parent ee04e86 commit 6e9fa92

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

libc-test/build.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3260,6 +3260,31 @@ fn test_vxworks(target: &str) {
32603260
cfg.generate("../src/lib.rs", "main.rs");
32613261
}
32623262

3263+
fn config_gnu_time64(target: &str, cfg: &mut ctest::TestGenerator) {
3264+
let gnu = target.contains("gnu");
3265+
let x32 = target.contains("x32");
3266+
let riscv = target.contains("riscv32");
3267+
3268+
if gnu && &env::var("CARGO_CFG_TARGET_POINTER_WIDTH").unwrap() == "32" && !riscv && !x32 {
3269+
match env::var("RUST_LIBC_TIME_BITS") {
3270+
Ok(time_bits) => {
3271+
if time_bits == "64" || time_bits == "default" {
3272+
cfg.define("_TIME_BITS", Some("64"));
3273+
cfg.define("_FILE_OFFSET_BITS", Some("64"));
3274+
cfg.cfg("gnu_time64_abi", None);
3275+
} else if time_bits != "32" {
3276+
panic!("Unsupported RUST_LIBC_TIME_BITS value {}", time_bits)
3277+
}
3278+
}
3279+
Err(_) => {
3280+
cfg.define("_TIME_BITS", Some("64"));
3281+
cfg.define("_FILE_OFFSET_BITS", Some("64"));
3282+
cfg.cfg("gnu_time64_abi", None);
3283+
}
3284+
}
3285+
}
3286+
}
3287+
32633288
fn test_linux(target: &str) {
32643289
assert!(target.contains("linux"));
32653290

@@ -3302,6 +3327,8 @@ fn test_linux(target: &str) {
33023327
// glibc versions older than 2.29.
33033328
cfg.define("__GLIBC_USE_DEPRECATED_SCANF", None);
33043329

3330+
config_gnu_time64(target, &mut cfg);
3331+
33053332
headers! { cfg:
33063333
"ctype.h",
33073334
"dirent.h",
@@ -4433,6 +4460,7 @@ fn test_linux_like_apis(target: &str) {
44334460
if linux || android || emscripten {
44344461
// test strerror_r from the `string.h` header
44354462
let mut cfg = ctest_cfg();
4463+
config_gnu_time64(target, &mut cfg);
44364464
cfg.skip_type(|_| true).skip_static(|_| true);
44374465

44384466
headers! { cfg: "string.h" }
@@ -4449,6 +4477,7 @@ fn test_linux_like_apis(target: &str) {
44494477
// test fcntl - see:
44504478
// http://man7.org/linux/man-pages/man2/fcntl.2.html
44514479
let mut cfg = ctest_cfg();
4480+
config_gnu_time64(target, &mut cfg);
44524481

44534482
if musl {
44544483
cfg.header("fcntl.h");
@@ -4478,6 +4507,7 @@ fn test_linux_like_apis(target: &str) {
44784507
if linux || android {
44794508
// test termios
44804509
let mut cfg = ctest_cfg();
4510+
config_gnu_time64(target, &mut cfg);
44814511
cfg.header("asm/termbits.h");
44824512
cfg.header("linux/termios.h");
44834513
cfg.skip_type(|_| true)
@@ -4502,6 +4532,7 @@ fn test_linux_like_apis(target: &str) {
45024532
if linux || android {
45034533
// test IPV6_ constants:
45044534
let mut cfg = ctest_cfg();
4535+
config_gnu_time64(target, &mut cfg);
45054536
headers! {
45064537
cfg:
45074538
"linux/in6.h"
@@ -4533,6 +4564,7 @@ fn test_linux_like_apis(target: &str) {
45334564
// "resolve.h" defines a `p_type` macro that expands to `__p_type`
45344565
// making the tests for these fails when both are included.
45354566
let mut cfg = ctest_cfg();
4567+
config_gnu_time64(target, &mut cfg);
45364568
cfg.header("elf.h");
45374569
cfg.skip_fn(|_| true)
45384570
.skip_static(|_| true)
@@ -4552,6 +4584,7 @@ fn test_linux_like_apis(target: &str) {
45524584
if linux || android {
45534585
// Test `ARPHRD_CAN`.
45544586
let mut cfg = ctest_cfg();
4587+
config_gnu_time64(target, &mut cfg);
45554588
cfg.header("linux/if_arp.h");
45564589
cfg.skip_fn(|_| true)
45574590
.skip_static(|_| true)

0 commit comments

Comments
 (0)