Skip to content

Conversation

@glaubitz
Copy link

On sparc64, suseconds_t is of type i32 while tv_sec is of type time_t which itself is of type i64 which causes the build on sparc64 to fail:

error[E0308]: mismatched types
--> src/lib.rs:210:30
|
210 | tv_sec: tv_sec + tv_usec / MICROS_PER_SEC,
| ^^^^^^^^^^^^^^^^^^^^^^^^ expected i64, found i32

error[E0277]: cannot add i32 to i64
--> src/lib.rs:210:28
|
210 | tv_sec: tv_sec + tv_usec / MICROS_PER_SEC,
| ^ no implementation for i64 + i32
|
= help: the trait Add<i32> is not implemented for i64
= help: the following other types implement trait Add<Rhs>:
&i64 implements Add<i64>
&i64 implements Add
i64 implements Add<&i64>
i64 implements Add

The type mismatch for suseconds_t is a result of binary compatibility with Solaris and cannot be changed as it's part of the ABI. Since the values for suseconds_t never exceed 32-bit boundaries, it's not really a problem and we can safely cast tv_usec / MICROS_PER_SEC to time_t to fix the build on sparc64.

On sparc64, suseconds_t is of type i32 while tv_sec is of type time_t
which itself is of type i64 which causes the build on sparc64 to fail:

error[E0308]: mismatched types
   --> src/lib.rs:210:30
    |
210 |             tv_sec: tv_sec + tv_usec / MICROS_PER_SEC,
    |                              ^^^^^^^^^^^^^^^^^^^^^^^^ expected `i64`, found `i32`

error[E0277]: cannot add `i32` to `i64`
   --> src/lib.rs:210:28
    |
210 |             tv_sec: tv_sec + tv_usec / MICROS_PER_SEC,
    |                            ^ no implementation for `i64 + i32`
    |
    = help: the trait `Add<i32>` is not implemented for `i64`
    = help: the following other types implement trait `Add<Rhs>`:
              `&i64` implements `Add<i64>`
              `&i64` implements `Add`
              `i64` implements `Add<&i64>`
              `i64` implements `Add`

The type mismatch for suseconds_t is a result of binary compatibility
with Solaris and cannot be changed as it's part of the ABI. Since the
values for suseconds_t never exceed 32-bit boundaries, it's not really
a problem and we can safely cast tv_usec / MICROS_PER_SEC to time_t to
fix the build on sparc64.

Signed-off-by: John Paul Adrian Glaubitz <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant