You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following script always prints a whole number for mtime, despite other programs on the same machine/OS accessing sub-second resolution for mtime (e.g python):
I'm putting this as a feature wish, because it is.
Yes, it would be a nice touch to support subsecond resolution here. I am concerned about the three different ways to access the nanosecond parts: a solid configure-time test is needed here, because Jane Street's code seems to assume either Linux, MacOS X, or BSD, but nothing else.
I am also surprised at the "1000000000.0f" constant in their code. By forcing computation to single precision, rounding errors become much larger (up to 1.1 ns instead of 6e-8 ns for double precision). Not that it matters much, but as a floating-point nit-picker I had to point it out.
Original bug ID: 6285
Reporter: gfxmonk
Assigned to: @diml
Status: closed (set by @xavierleroy on 2016-12-07T10:47:19Z)
Resolution: fixed
Priority: normal
Severity: feature
Platform: x86_64
OS: Linux
Version: 4.01.0
Fixed in version: 4.03.0+dev / +beta1
Category: standard library
Monitored by: @gasche @diml @hcarty
Bug description
stat.c (in the
unix
module) uses the old second-level precision data attributes of linuxstat
results:https://github.com/ocaml/ocaml/blob/trunk/otherlibs/unix/stat.c#L46
It should use the newer, subsecond-precision attributes where available. Jane Street Core does this:
https://github.com/janestreet/core/blob/master/lib/unix_stubs.c#L426
Steps to reproduce
The following script always prints a whole number for
mtime
, despite other programs on the same machine/OS accessing sub-second resolution formtime
(e.g python):#!/usr/bin/env ocamlscript
Ocaml.packs := ["unix"]
open Unix
open Printf
let () =
let this_file = Array.get Sys.argv 0 in
let stats = Unix.stat this_file in
printf "mtime: %f" stats.st_mtime
The text was updated successfully, but these errors were encountered: