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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 18C307F168 for ; Tue, 8 Sep 2015 11:02:45 +0200 (CEST) IronPort-PHdr: 9a23:qtxvERw5bA1gZabXCy+O+j09IxM/srCxBDY+r6Qd0e4eIJqq85mqBkHD//Il1AaPBtWHrasewLKG+4nbGkU+or+5+EgYd5JNUxJXwe43pCcHRPC/NEvgMfTxZDY7FskRHHVs/nW8LFQHUJ2mPw6anHS+4HYoFwnlMkItf6KuStKU1p78j7D60qaQSjsLrQL1Wal1IhSyoFeZnegtqqwmFJwMzADUqGBDYeVcyDAgD1uSmxHh+pX4p8Y7oGwD884moppLWKD+OqA5VqBwDTI8Mmlz6te95jfZSg7aw3IGUXgNpSVFAr/A5Rf8FsP0uzH5q/E7xySbJtbzRLYycTWkqbt2TVnkhXFUZHYC7GjLh5ko3+pgqxW7qkknzg== Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=markus.weissmann@in.tum.de; spf=None smtp.mailfrom=markus.weissmann@in.tum.de; spf=None smtp.helo=postmaster@mail-out1.informatik.tu-muenchen.de Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of markus.weissmann@in.tum.de) identity=pra; client-ip=131.159.0.8; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="markus.weissmann@in.tum.de"; x-sender="markus.weissmann@in.tum.de"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of markus.weissmann@in.tum.de) identity=mailfrom; client-ip=131.159.0.8; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="markus.weissmann@in.tum.de"; x-sender="markus.weissmann@in.tum.de"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-out1.informatik.tu-muenchen.de) identity=helo; client-ip=131.159.0.8; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="markus.weissmann@in.tum.de"; x-sender="postmaster@mail-out1.informatik.tu-muenchen.de"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0CrAgDlo+5VhwgAn4Ndg3dpgyS8BoJBgmxKAoE3OxEBAQEBAQEBARABAQEIDQkHIy6CHYIHAQEEIw8BBVEEBxgCAiYCAlcGGxOIEw21GJQiAQoBAQEBHYEiikyFExeCUoFDBZVVhQqKAoZmik2HMoQoPDMBAQGIRgEBAQ X-IPAS-Result: A0CrAgDlo+5VhwgAn4Ndg3dpgyS8BoJBgmxKAoE3OxEBAQEBAQEBARABAQEIDQkHIy6CHYIHAQEEIw8BBVEEBxgCAiYCAlcGGxOIEw21GJQiAQoBAQEBHYEiikyFExeCUoFDBZVVhQqKAoZmik2HMoQoPDMBAQGIRgEBAQ X-IronPort-AV: E=Sophos;i="5.17,489,1437429600"; d="scan'208";a="176474910" Received: from mail-out1.informatik.tu-muenchen.de ([131.159.0.8]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/ADH-AES256-SHA; 08 Sep 2015 11:02:25 +0200 Received: from webmail.in.tum.de (localhost [127.0.0.1]) by vmwebmail1.informatik.tu-muenchen.de (Postfix) with ESMTP id 3FF2A24028F for ; Tue, 8 Sep 2015 11:02:23 +0200 (CEST) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Tue, 08 Sep 2015 11:02:23 +0200 From: =?UTF-8?Q?Markus_Wei=C3=9Fmann?= To: In-Reply-To: <2CA44FB5-DDEF-48A6-8567-99DCE4A0BA66@in.tum.de> References: <2CA44FB5-DDEF-48A6-8567-99DCE4A0BA66@in.tum.de> Message-ID: X-Sender: markus.weissmann@in.tum.de User-Agent: Roundcube Webmail/0.8.1 Subject: Re: [Caml-list] POSIX time implementation For the record: I found another OCaml implementation of clock_gettime(2): oclock [7] (also available via opam). Unfortunately oclock implements 'struct timespec { time_t, long }' as int64, making some conversion necessary, too. regards -Markus [7] http://micdel.fr/oclock.html On 2015-09-05 13:52, Markus W. Weißmann wrote: > Hi, > > I was searching for an existing library implementing a > clock_gettime(2) function that would deliver a ‘struct timespec’ [1] > with the current time. > I want it for my POSIX message queue implementation [2] for the timed > functions that require an absolute ‘struct timespec’ for their > timeout. > So what a user of mqueue requires is a 1.) function to get the > current time as ‘struct timespec’ and 2.) to add seconds/nanoseconds > to such a value to create a timeout. > > The existing solutions I found: > * The Unix library [3] implements ‘struct timeval’ as float (only > microseconds, imho the float conversion is a bit of a hack — a clever > one though) > * Netsys.clock_gettime from ocamlnet [4] implements ’struct timespec’ > 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’d like my library to be a good OCaml citizen and _not_ implement my > own special purpose timing functions (which are incompatible to > everyone else’s). > Ptime looks like the ultimate solution for the datatype; ocamlnet > gets the closest to my requirements — while being a gigantic library > most of which has nothing to do with the domain of mqueue. > > I’m a bit stuck on this one and would like to get some advice — > 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/Netsys_posix.html > [5] http://erratique.ch/software/mtime > [6] http://erratique.ch/software/ptime > > -- > Markus Weißmann, M.Sc. > Technische Universität München > Institut für Informatik > Boltzmannstr. 3 > D-85748 Garching > Germany > http://wwwknoll.in.tum.de/