1234567891011121314151617181920212223242526272829303132333435363738(*
* Copyright (c) 2015 Matt Gray <matthew.thomas.gray@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*)externaltime:unit->int64="caml_get_wall_clock"letnsec_per_day=Int64.mul86_400L1_000_000_000Lletps_per_ns=1_000Lletnow_d_ps()=letnsec=time()inletdays=Int64.divnsecnsec_per_dayinletrem_ns=Int64.remnsecnsec_per_dayinletrem_ps=Int64.mulrem_nsps_per_nsin(Int64.to_intdays,rem_ps)letnow()=Ptime.v(now_d_ps())letcurrent_tz_offset_s()=None(* According to
* https://github.com/mirage/mini-os/blob/edfd5aae6ec5ba7d0a8834a3e9dfe5e69424150a/arch/x86/time.c#L194
* the clock period is 1 microsecond
*)letperiod=(0,1_000_000L)letperiod_d_ps()=Someperiodletperiod()=Some(Ptime.Span.vperiod)