Skip to content

Commit 8c448c4

Browse files
committed
Declare field 'tv_nsec' of structure 'timespec' as 'i32' in both 32-bit and 64-bit modes for AIX.
1 parent b54769a commit 8c448c4

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

libc-test/build.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5587,6 +5587,12 @@ fn test_aix(target: &str) {
55875587
// The field 'data' is actually a unnamed union in the AIX header.
55885588
"pollfd_ext" if field.ident() == "data" => true,
55895589

5590+
// On AIX, <stat.h> declares 'tv_nsec' as 'long', but the
5591+
// underlying system calls return a 32-bit value in both 32-bit
5592+
// and 64-bit modes. In the 'libc' crate it is declared as 'i32'
5593+
// to match the system call. Skip this field.
5594+
"timespec" if field.ident() == "tv_nsec" => true,
5595+
55905596
_ => false,
55915597
}
55925598
});

src/unix/aix/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,15 @@ s! {
264264
pub tv_nsec: c_int,
265265
}
266266

267+
// On AIX, <stat.h> declares 'tv_nsec' as 'long', but the underlying
268+
// system calls return a 4-byte value in both 32-bit and 64-bit modes.
269+
// It is declared as 'c_int' here to avoid using the other undefined 4
270+
// bytes in the 64-bit mode.
271+
pub struct timespec {
272+
pub tv_sec: time_t,
273+
pub tv_nsec: c_int,
274+
}
275+
267276
pub struct statfs64 {
268277
pub f_version: c_int,
269278
pub f_type: c_int,

src/unix/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ s! {
6868

6969
// linux x32 compatibility
7070
// See https://sourceware.org/bugzilla/show_bug.cgi?id=16437
71-
#[cfg(not(target_env = "gnu"))]
71+
#[cfg(all(not(target_env = "gnu"), not(target_os = "aix")))]
7272
pub struct timespec {
7373
pub tv_sec: time_t,
7474
#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]

0 commit comments

Comments
 (0)