From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id A5B507F0A3 for ; Sun, 6 Sep 2015 02:04:31 +0200 (CEST) IronPort-PHdr: 9a23:lliT8BdcJdTDvSO6oQ8qu7rBlGMj4u6mDksu8pMizoh2WeGdxc+6Zh7h7PlgxGXEQZ/co6odzbGG7+a4ASQp2tWojjMrSNR0TRgLiMEbzUQLIfWuLgnFFsPsdDEwB89YVVVorDmROElRH9viNRWJ+iXhpQAbFhi3DwdpPOO9QteU1JTrkbjqs7ToICx2xxOFKYtoKxu3qQiD/uI3uqBFbpgL9x3Sv3FTcP5Xz247bXianhL7+9vitMU7q3cYk7sb+sVBSaT3ebgjBfwdVWx+cjMD39DwrRTIUSeI43IdVC1WzksJUED560TfV43yrzDNiaxK5ySbisj/S7Z8DTGr9aR2U1n3hSYcLDsw9mf/i8o2kL9e5h6s8U9R2YnRNaSUMPN4SZjBdNUdR2dfX80ZAylABoq6dJcnAO8IPOIepI748Qhd5SCiDBWhUbu8ggRDgWX7iOhniuk= Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=milanst@gmail.com; spf=Pass smtp.mailfrom=milanst@gmail.com; spf=None smtp.helo=postmaster@mail-oi0-f48.google.com Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of milanst@gmail.com) identity=pra; client-ip=209.85.218.48; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="milanst@gmail.com"; x-sender="milanst@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of milanst@gmail.com designates 209.85.218.48 as permitted sender) identity=mailfrom; client-ip=209.85.218.48; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="milanst@gmail.com"; x-sender="milanst@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-oi0-f48.google.com) identity=helo; client-ip=209.85.218.48; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="milanst@gmail.com"; x-sender="postmaster@mail-oi0-f48.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0BYAQANgutVmzDaVdFeg0I1aQaDHqlrK4QtLotaAQmBeYJBgmxKAoEbBzgUAQEBAQEBAQEQAQEBAQEGCwsJIS6CHYIHAQEEEhEdARsSCwEDDAYFCxodAgIiAREBBQEKEgYbCgkHh3YBAxINpxmBLz4xi0CBbIJ5iT0KGScDClaEMgEBAQEBAQEBAQEBAQEBAQEBAQEBAREBBQ6GZYR7hQgEB4JpgUMFhXsMj06FCodwgUxGlHmCIBIjgRcRghiCGSIzAQEBiUcBAQE X-IPAS-Result: A0BYAQANgutVmzDaVdFeg0I1aQaDHqlrK4QtLotaAQmBeYJBgmxKAoEbBzgUAQEBAQEBAQEQAQEBAQEGCwsJIS6CHYIHAQEEEhEdARsSCwEDDAYFCxodAgIiAREBBQEKEgYbCgkHh3YBAxINpxmBLz4xi0CBbIJ5iT0KGScDClaEMgEBAQEBAQEBAQEBAQEBAQEBAQEBAREBBQ6GZYR7hQgEB4JpgUMFhXsMj06FCodwgUxGlHmCIBIjgRcRghiCGSIzAQEBiUcBAQE X-IronPort-AV: E=Sophos;i="5.17,476,1437429600"; d="scan'208";a="144858217" Received: from mail-oi0-f48.google.com ([209.85.218.48]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 06 Sep 2015 02:04:30 +0200 Received: by oiev17 with SMTP id v17so28980675oie.1 for ; Sat, 05 Sep 2015 17:04:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=dKTqiWsVAFnnxb08fOoWGzFEcyWZKp4Y6bEdLr8prsg=; b=pKZxWYxG+ASdZx+kpZRHObnaVlSeW6UYGlFKnlIkGwAgLlkYDj8rWkBIHTCjzDQt8n N6PKbp8eXNg6ZPiwKX3NxV9QJE9NZuDjgjfPKN6d4Bys+FWncaW3JGpvjyxxt+xSsBwK riurEkROW1eIpwiel79axnXsIQxeI25HDjPZsscj8V7Lh/5yLucx3PeKOUpW8h3vd/Gm z3EctCDiSPnR43dOgjZ/G6HVwy6dhF0rdkDUFYon6zAJ2ytX9dnpxwyn6EH4m7YyUnpp CnJMgf62PdG3bAgAzLbNE311DQT2EwF3P2W823TftZwcNSuIL5P2D2VVDX65xYjYauJm QtMg== MIME-Version: 1.0 X-Received: by 10.202.193.215 with SMTP id r206mr416875oif.1.1441497869134; Sat, 05 Sep 2015 17:04:29 -0700 (PDT) Received: by 10.202.175.198 with HTTP; Sat, 5 Sep 2015 17:04:28 -0700 (PDT) Received: by 10.202.175.198 with HTTP; Sat, 5 Sep 2015 17:04:28 -0700 (PDT) In-Reply-To: <2CA44FB5-DDEF-48A6-8567-99DCE4A0BA66@in.tum.de> References: <2CA44FB5-DDEF-48A6-8567-99DCE4A0BA66@in.tum.de> Date: Sat, 5 Sep 2015 20:04:28 -0400 Message-ID: From: =?UTF-8?Q?Milan_Stanojevi=C4=87?= To: =?UTF-8?Q?Markus_W=2E_Wei=C3=9Fmann?= Cc: Caml List Content-Type: multipart/alternative; boundary=001a113dc61c6f30af051f08e043 Subject: Re: [Caml-list] POSIX time implementation --001a113dc61c6f30af051f08e043 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Jane Street's Core_kernel has Time_ns module. Time is represented as an int, number of nanoseconds since unix epoch. Time_ns.now uses clock_gettime(CLOCK_REALTIME) There are also usual functions for operating on time and time spans. Not sure if Core_kernel is too big for your project. Hi, I was searching for an existing library implementing a clock_gettime(2) function that would deliver a =E2=80=98struct timespec=E2=80=99 [1] with th= e current time. I want it for my POSIX message queue implementation [2] for the timed functions that require an absolute =E2=80=98struct timespec=E2=80=99 for th= eir timeout. So what a user of mqueue requires is a 1.) function to get the current time as =E2=80=98struct timespec=E2=80=99 and 2.) to add seconds/nanoseconds to = such a value to create a timeout. The existing solutions I found: * The Unix library [3] implements =E2=80=98struct timeval=E2=80=99 as float= (only microseconds, imho the float conversion is a bit of a hack =E2=80=94 a clev= er one though) * Netsys.clock_gettime from ocamlnet [4] implements =E2=80=99struct timespe= c=E2=80=99 but has it as float/int for seconds/nanoseconds (whats with the float? All systems I found use either in32 or int64 for time_t) * Mtime [5] implements clock_gettime(2) but seems to only offers relative values * Ptime [6] appears to be the uber-POSIX time implementation but lacks clock_gettime (and probably always will) I=E2=80=99d like my library to be a good OCaml citizen and _not_ implement = my own special purpose timing functions (which are incompatible to everyone else=E2=80=99s). Ptime looks like the ultimate solution for the datatype; ocamlnet gets the closest to my requirements =E2=80=94 while being a gigantic library most of= which has nothing to do with the domain of mqueue. I=E2=80=99m a bit stuck on this one and would like to get some advice =E2= =80=94 and/or corrections if I misinterpreted one of the above solutions. regards -Markus [1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/time.h.html [2] http://mqueue.forge.ocamlcore.org/ [3] http://caml.inria.fr/pub/docs/manual-ocaml/libref/Unix.html [4] http://projects.camlcity.org/projects/dl/ocamlnet-4.0.4/doc/html-main/Netsy= s_posix.html [5] http://erratique.ch/software/mtime [6] http://erratique.ch/software/ptime -- Markus Wei=C3=9Fmann, M.Sc. Technische Universit=C3=A4t M=C3=BCnchen Institut f=C3=BCr Informatik Boltzmannstr. 3 D-85748 Garching Germany http://wwwknoll.in.tum.de/ -- Caml-list mailing list. Subscription management and archives: https://sympa.inria.fr/sympa/arc/caml-list Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs --001a113dc61c6f30af051f08e043 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

Jane Street's Core_kernel has Time_ns module. Time is re= presented as an int, number of nanoseconds since unix epoch. Time_ns.now us= es clock_gettime(CLOCK_REALTIME)
There are also usual functions for operating on time and time spans.
Not sure if Core_kernel is too big for your project.

Hi,

I was searching for an existing library implementing a clock_gettime(2) fun= ction that would deliver a =E2=80=98struct timespec=E2=80=99 [1] with the c= urrent time.
I want it for my POSIX message queue implementation [2] for the timed funct= ions that require an absolute =E2=80=98struct timespec=E2=80=99 for their t= imeout.
So what a user of mqueue requires is a 1.) function to get the current time= as =E2=80=98struct timespec=E2=80=99 and 2.) to add seconds/nanoseconds to= such a value to create a timeout.

The existing solutions I found:
* The Unix library [3] implements =E2=80=98struct timeval=E2=80=99 as float= (only microseconds, imho the float conversion is a bit of a hack =E2=80=94= a clever one though)
* Netsys.clock_gettime from ocamlnet [4] implements =E2=80=99struct timespe= c=E2=80=99 but has it as float/int for seconds/nanoseconds (whats with the = float? All systems I found use either in32 or int64 for time_t)
* Mtime [5] implements clock_gettime(2) but seems to only offers relative v= alues
* Ptime [6] appears to be the uber-POSIX time implementation but lacks cloc= k_gettime (and probably always will)

I=E2=80=99d like my library to be a good OCaml citizen and _not_ implement = my own special purpose timing functions (which are incompatible to everyone= else=E2=80=99s).
Ptime looks like the ultimate solution for the datatype; ocamlnet gets the = closest to my requirements =E2=80=94 while being a gigantic library most of= which has nothing to do with the domain of mqueue.

I=E2=80=99m a bit stuck on this one and would like to get some advice =E2= =80=94 and/or corrections if I misinterpreted one of the above solutions.
regards
-Markus

[1] http://pubs.opengroup.org/on= linepubs/9699919799/basedefs/time.h.html
[2] http://mqueue.forge.ocamlcore.org/
[3] http://caml.inria.fr/pub/docs/manual-= ocaml/libref/Unix.html
[4] http://pr= ojects.camlcity.org/projects/dl/ocamlnet-4.0.4/doc/html-main/Netsys_posix.h= tml
[5] http://erratique.ch/software/mtime
[6] http://erratique.ch/software/ptime

--
Markus Wei=C3=9Fmann, M.Sc.
Technische Universit=C3=A4t M=C3=BCnchen
Institut f=C3=BCr Informatik
Boltzmannstr. 3
D-85748 Garching
Germany
http://wwwknoll.in.tum.de/


--
Caml-list mailing list.=C2=A0 Subscription management and archives:
https://sympa.inria.fr/sympa/arc/caml-list
Beginner's list: http://groups.yahoo.com/group/ocam= l_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs
--001a113dc61c6f30af051f08e043--