-
Notifications
You must be signed in to change notification settings - Fork 21
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
Use CApiFFI for syscalls that break with glibc's handling of 64-bit time_t #62
Comments
I don't have 32bit machines anymore. |
Hi @kazu-yamamoto, I can send a PR yes. Looking at the code, I also noticed that This means that unix-time is broken on big endian systems, and always sets One solutions would be to change Another solution is to peek the value as |
Nice catch! |
UnixTime defines 'utMicroSeconds' as 'Int32', but 'tv_usec' (in 'struct timeval') is of type 'suseconds_t'. The size of 'suseconds_t' is platform specific, and it is 8 bytes long on 64-bit platforms. This happens to give us the correct result on small endian architectures, but results in a value of 0 for 'utMicroSeconds' on 64-bit big-endian architectures. In order to avoid changing the type of 'utMicroSeconds' (which will result in an API change) we peek 'tv_usec' using the 'CSUSeconds' type and then convert it to 'Int32' (the type of 'utMicroSeconds'). We rely on the fact that 'tv_usec' is no bigger than '1000000' and hence we will not overflow during the above conversion. Refs kazu-yamamoto#62
As part of the effort to support 64-bit time_t on 32-bit platforms, glibc uses macros to define functions like
clock_gettime()
,gettimeofday()
,mktime()
,localtime()
etc. This breaksunix-time
which uses theccall
calling convention.As an example, the following code breaks on a 32-bit system with 64-bit time_t:
output:
Here are some related fixes on other Haskell libraries:
The text was updated successfully, but these errors were encountered: