Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Harmonize timeval struct between 32-bit and 64-bit #43

Closed
derek-will opened this issue Sep 4, 2022 · 0 comments
Closed

Harmonize timeval struct between 32-bit and 64-bit #43

derek-will opened this issue Sep 4, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@derek-will
Copy link
Owner

The timeval struct references long type which is 4 bytes in 32-bit applications on Linux and 8 bytes in 64-bit applications on Linux.

struct timeval {
	__kernel_old_time_t	tv_sec;		/* seconds */
	__kernel_suseconds_t	tv_usec;	/* microseconds */
};

Currently as written in SocketCAN#, the structure will not work well when used in 32-bit applications.

[StructLayout(LayoutKind.Sequential)]
public class Timeval
{
    /// <summary>
    /// Number of seconds.
    /// </summary>
    public long Seconds { get; set; }
    /// <summary>
    /// Number of microseconds. This value is used in combination with the Seconds property to represent the full interval of time.
    /// </summary>
    public long Microseconds { get; set; }
    // ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant