The unpac monorepo manager self-hosting as a monorepo using unpac
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Provide separate sec and nsec accessors for statx times

Converting to float loses some accuracy.

+41 -32
+9 -4
vendor/opam/uring/lib/uring/uring.ml
··· 153 153 external dio_mem_align : t -> (int64 [@unboxed]) = "ocaml_uring_statx_dio_mem_align_bytes" "ocaml_uring_statx_dio_mem_align_native" [@@noalloc] 154 154 external dio_offset_align : t -> (int64 [@unboxed]) = "ocaml_uring_statx_dio_offset_align_bytes" "ocaml_uring_statx_dio_offset_align_native" [@@noalloc] 155 155 156 - external atime : t -> (float [@unboxed]) = "ocaml_uring_statx_atime_bytes" "ocaml_uring_statx_atime_native" [@@noalloc] 157 - external btime : t -> (float [@unboxed]) = "ocaml_uring_statx_btime_bytes" "ocaml_uring_statx_btime_native" [@@noalloc] 158 - external ctime : t -> (float [@unboxed]) = "ocaml_uring_statx_ctime_bytes" "ocaml_uring_statx_ctime_native" [@@noalloc] 159 - external mtime : t -> (float [@unboxed]) = "ocaml_uring_statx_mtime_bytes" "ocaml_uring_statx_mtime_native" [@@noalloc] 156 + external atime_sec : t -> (int64 [@unboxed]) = "ocaml_uring_statx_atime_sec_bytes" "ocaml_uring_statx_atime_sec_native" [@@noalloc] 157 + external btime_sec : t -> (int64 [@unboxed]) = "ocaml_uring_statx_btime_sec_bytes" "ocaml_uring_statx_btime_sec_native" [@@noalloc] 158 + external ctime_sec : t -> (int64 [@unboxed]) = "ocaml_uring_statx_ctime_sec_bytes" "ocaml_uring_statx_ctime_sec_native" [@@noalloc] 159 + external mtime_sec : t -> (int64 [@unboxed]) = "ocaml_uring_statx_mtime_sec_bytes" "ocaml_uring_statx_mtime_sec_native" [@@noalloc] 160 + 161 + external atime_nsec : t -> int = "ocaml_uring_statx_atime_nsec" [@@noalloc] 162 + external btime_nsec : t -> int = "ocaml_uring_statx_btime_nsec" [@@noalloc] 163 + external ctime_nsec : t -> int = "ocaml_uring_statx_ctime_nsec" [@@noalloc] 164 + external mtime_nsec : t -> int = "ocaml_uring_statx_mtime_nsec" [@@noalloc] 160 165 161 166 external mode : t -> (int [@untagged]) = "ocaml_uring_statx_mode_bytes" "ocaml_uring_statx_mode_native" [@@noalloc] 162 167 external perm : t -> (int [@untagged]) = "ocaml_uring_statx_perm_bytes" "ocaml_uring_statx_perm_native" [@@noalloc]
+9 -4
vendor/opam/uring/lib/uring/uring.mli
··· 329 329 val dio_offset_align : t -> Int64.t 330 330 (** See {! Mask.dioalign}. *) 331 331 332 - val atime : t -> float 333 - val btime : t -> float 334 - val ctime : t -> float 335 - val mtime : t -> float 332 + val atime_sec : t -> int64 333 + val btime_sec : t -> int64 334 + val ctime_sec : t -> int64 335 + val mtime_sec : t -> int64 336 + 337 + val atime_nsec : t -> int 338 + val btime_nsec : t -> int 339 + val ctime_nsec : t -> int 340 + val mtime_nsec : t -> int 336 341 337 342 val mode : t -> int 338 343 val perm : t -> int
+14 -14
vendor/opam/uring/lib/uring/uring_stubs.c
··· 448 448 CAMLreturn(v); 449 449 } 450 450 451 - static double double_of_timespec(struct statx_timestamp *t) { 452 - return ((double) t->tv_sec) + (((double) t->tv_nsec) / 1e9); 453 - } 454 - 455 451 static value get_file_type_variant(struct statx *sb) { 456 452 int filetype = sb->stx_mode & S_IFMT; 457 453 switch (filetype) { ··· 585 581 return caml_copy_int64(ocaml_uring_statx_dio_offset_align_native(v_statx)); 586 582 } 587 583 588 - #define STATX_TIME_GETTER(field, return_type, ocaml_value_maker) \ 589 - return_type ocaml_uring_statx_##field##_native(value v_statx) { \ 584 + #define STATX_TIME_GETTER(field) \ 585 + int64_t ocaml_uring_statx_##field##_sec_native(value v_statx) { \ 590 586 struct statx *s = Statx_val(v_statx); \ 591 - return double_of_timespec(&s->stx_##field); \ 587 + return s->stx_##field.tv_sec; \ 592 588 } \ 593 - value ocaml_uring_statx_ ## field ## _bytes(value v_statx) { \ 594 - return ocaml_value_maker(ocaml_uring_statx_##field##_native(v_statx)); \ 589 + value ocaml_uring_statx_##field##_sec_bytes(value v_statx) { \ 590 + return caml_copy_int64(ocaml_uring_statx_##field##_sec_native(v_statx)); \ 591 + } \ 592 + value ocaml_uring_statx_##field##_nsec(value v_statx) { \ 593 + struct statx *s = Statx_val(v_statx); \ 594 + return Val_int(s->stx_##field.tv_nsec); \ 595 595 } 596 596 597 - // Float 598 - STATX_TIME_GETTER(atime, double, caml_copy_double); 599 - STATX_TIME_GETTER(btime, double, caml_copy_double); 600 - STATX_TIME_GETTER(ctime, double, caml_copy_double); 601 - STATX_TIME_GETTER(mtime, double, caml_copy_double); 597 + // Seconds and ns 598 + STATX_TIME_GETTER(atime); 599 + STATX_TIME_GETTER(btime); 600 + STATX_TIME_GETTER(ctime); 601 + STATX_TIME_GETTER(mtime); 602 602 603 603 // Int 604 604 STATX_GETTER(mode, intnat, Val_int);
+9 -10
vendor/opam/uring/tests/urstat.ml
··· 3 3 module S = Uring.Statx 4 4 5 5 (* TODO move into Uring.Statx? *) 6 - let pp_time f t = 7 - let nsec, sec = modf t in 8 - let tm = Unix.localtime sec in 9 - Format.fprintf f "%04d-%02d-%02d %02d:%02d:%02d.%9.0f +0000" 6 + let pp_time f (sec, nsec) = 7 + let tm = Unix.localtime (Int64.to_float sec) in 8 + Format.fprintf f "%04d-%02d-%02d %02d:%02d:%02d.%09d +0000" 10 9 (tm.Unix.tm_year + 1900) (tm.Unix.tm_mon + 1) tm.Unix.tm_mday 11 10 tm.Unix.tm_hour tm.Unix.tm_min tm.Unix.tm_sec 12 - (nsec *. 1e9) 11 + nsec 13 12 14 13 let get_completion_and_print uring = 15 14 let (fname, buf), _ = ··· 29 28 S.pp_kind (S.kind buf) 30 29 (S.dev buf) (* TODO expose makedev/major/minor *) (S.ino buf) (S.nlink buf) 31 30 (S.perm buf) (S.uid buf) (S.gid buf) 32 - pp_time (S.atime buf) 33 - pp_time (S.mtime buf) 34 - pp_time (S.ctime buf) 35 - pp_time (S.btime buf) 31 + pp_time (S.atime_sec buf, S.atime_nsec buf) 32 + pp_time (S.mtime_sec buf, S.mtime_nsec buf) 33 + pp_time (S.ctime_sec buf, S.ctime_nsec buf) 34 + pp_time (S.btime_sec buf, S.btime_nsec buf) 36 35 37 36 let submit_stat_request fname buf uring = 38 37 let mask = S.Mask.(basic_stats + btime) in ··· 47 46 let buf = S.create () in 48 47 let uring = Uring.create ~queue_depth:1 () in 49 48 submit_stat_request fname buf uring; 50 - get_completion_and_print uring 49 + get_completion_and_print uring