From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 22836 invoked from network); 15 Oct 2021 11:15:24 -0000 Received: from tb-ob1.topicbox.com (64.147.108.173) by inbox.vuxu.org with ESMTPUTF8; 15 Oct 2021 11:15:24 -0000 Received: from tb-mx0.topicbox.com (tb-mx0.nyi.icgroup.com [10.90.30.73]) by tb-ob1.topicbox.com (Postfix) with ESMTP id D89B532FFE for ; Fri, 15 Oct 2021 07:15:22 -0400 (EDT) (envelope-from bounce.mMe0d4b6affdd5977cbe6d2c8b.r522be890-2105-11eb-b15e-8d699134e1fa@9fans.bounce.topicbox.com) Received: by tb-mx0.topicbox.com (Postfix, from userid 1132) id D688C970DF; Fri, 15 Oct 2021 07:15:22 -0400 (EDT) ARC-Authentication-Results: i=2; topicbox.com; arc=pass; dkim=invalid (public key: not available, 0-bit key sha256) header.d=polynum.com header.i=@polynum.com header.b=djzSZFUY header.a=-sha256 header.s=202006 x-bits=0; dmarc=none policy.published-domain-policy=none policy.applied-disposition=none policy.evaluated-disposition=none (p=none,d=none,d.eval=none) policy.policy-from=p header.from=polynum.com; spf=pass smtp.mailfrom=thierry.laronde@sfr.fr smtp.helo=smtp26.services.sfr.fr; x-internal-arc=fail (as.1.topicbox.com=pass, ams.1.topicbox.com=fail (message has been altered)) (Message modified while forwarding at Topicbox) ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d= topicbox.com; h=date:from:to:subject:message-id:references :mime-version:content-type:content-transfer-encoding:in-reply-to :list-help:list-id:list-post:list-subscribe:reply-to :list-unsubscribe; s=sysmsg-1; t=1634296522; bh=o1fhMleJ7z/w7oR4 yI+n8Kr+pbR+aVFx+wb/2lwToEQ=; b=tq/T6THUpOnhG8+zF0BbVbvimhQsnFRO vPCKtgxYnFVG7S6IwAstE6rO8/VSoXXwdf0iIFVnRsvARnftZnuYo6jiJT7qcFt9 X/mjsQaMxg/zM4YqAga/Qt50apVkPY6+hpCH/xEl/yZvoxTF7aDINEVA9e9yl6Qh o1iYdxXXBRY= ARC-Seal: i=2; a=rsa-sha256; cv=pass; d=topicbox.com; s=sysmsg-1; t= 1634296522; b=cgQG4Zh6x+4QMnIpt5du0mr0bLnD7i9b6Af/YXcB60yeaKEUOi hnnKNjxkoG33+3UmMJef2W2LlWxItZnf+2Pzt2Sl1bp7o7R5hU88urC+ec+RX7gA SYwmMBiMoUvC9h0mza8F2m6fhoeFh/iDh9JI3uzYDOQd+S0pfsepFxioU= Authentication-Results: topicbox.com; arc=pass; dkim=invalid (public key: not available, 0-bit key sha256) header.d=polynum.com header.i=@polynum.com header.b=djzSZFUY header.a=-sha256 header.s=202006 x-bits=0; dmarc=none policy.published-domain-policy=none policy.applied-disposition=none policy.evaluated-disposition=none (p=none,d=none,d.eval=none) policy.policy-from=p header.from=polynum.com; spf=pass smtp.mailfrom=thierry.laronde@sfr.fr smtp.helo=smtp26.services.sfr.fr; x-internal-arc=fail (as.1.topicbox.com=pass, ams.1.topicbox.com=fail (message has been altered)) (Message modified while forwarding at Topicbox) X-Received-Authentication-Results: tb-mx1.topicbox.com; arc=none (no signatures found); bimi=skipped (DMARC did not pass); dkim=invalid (public key: not available, 0-bit key sha256) header.d=polynum.com header.i=@polynum.com header.b=djzSZFUY header.a=-sha256 header.s=202006 x-bits=0; dmarc=none policy.published-domain-policy=none policy.applied-disposition=none policy.evaluated-disposition=none (p=none,d=none,d.eval=none) policy.policy-from=p header.from=polynum.com; iprev=pass smtp.remote-ip=93.17.128.204 (smtp26.services.sfr.fr); spf=pass smtp.mailfrom=thierry.laronde@sfr.fr smtp.helo=smtp26.services.sfr.fr; x-aligned-from=fail; x-me-sender=none; x-ptr=pass smtp.helo=smtp26.services.sfr.fr policy.ptr=smtp26.services.sfr.fr; x-return-mx=pass header.domain=polynum.com policy.is_org=yes (MX Records found: spool.mail.gandi.net,fb.mail.gandi.net); x-return-mx=pass smtp.domain=sfr.fr policy.is_org=yes (MX Records found: smtp-in.sfr.fr); x-tls=pass smtp.version=TLSv1.2 smtp.cipher=ECDHE-RSA-AES256-GCM-SHA384 smtp.bits=256/256; x-vs=clean score=0 state=0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=9fans.net; h=date:from :to:subject:message-id:references:mime-version:content-type :content-transfer-encoding:in-reply-to:list-help:list-id :list-post:list-subscribe:reply-to:list-unsubscribe; s=dkim-1; bh=Pd4B5Mgbz3r4lFbStRgvkuTD7vHJLtkGpFeb71xK+bQ=; b=qBXgANvCTwl9 2J6jOAGp5lIR8sqKMPrGSENxzOwa0nlvcriy6lZIGFIkf7MR+NOlXu243Qk1w61F gyGwqq9xzhXEyQom/cthx0FXoo791CoSrH7lvuqBvF65fpwjZEPF0/sSgvLrlJD2 Px/KsDSXtfsLAZvlsoz+Nl0xjp0sq54= Received: from tb-mx1.topicbox.com (localhost.local [127.0.0.1]) by tb-mx1.topicbox.com (Postfix) with ESMTP id 18F5B264383 for <9fans@9fans.net>; Fri, 15 Oct 2021 07:15:12 -0400 (EDT) (envelope-from thierry.laronde@sfr.fr) Received: from tb-mx1.topicbox.com (localhost [127.0.0.1]) by tb-mx1.topicbox.com (Authentication Milter) with ESMTP id B76CD4BFD93; Fri, 15 Oct 2021 07:15:12 -0400 ARC-Seal: i=1; a=rsa-sha256; cv=none; d=topicbox.com; s=arcseal; t= 1634296512; b=XannvU2sskrPONVy9+jIwunxLgWsRS+Ck/22/B282oJ9DjgkwE Di5ESlLTYJNFjuczR0AgU/fadLV1O+bJWqVdPbrpN2TGD4+Xl3/jVmv15hE7clz1 L+u25y3j0XJl5LtV7Pj9zdNtCbXAB42BijsU0YrhWHNNxu7NdW1+D8OnPg9reAf+ Bqo7pod8r4zvqENj8KeNcqgK7lSmrOcYRqrLhjrAq2AbNcmRjE4JkuAxWuI+XgPq IAMsUwB5uHoHBVgudO4mTZBMJkSQIFRoh8vribgEdPEEVwm4zFoEtCwBqHdXJGX2 czhqv9S4ArwW69VR5OhYIplyhYXoAJz/jB6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d= topicbox.com; h=date:from:to:subject:message-id:references :mime-version:content-type:content-transfer-encoding :in-reply-to; s=arcseal; t=1634296512; bh=0UtbPC/IU23fSOV35gECNH eS2rLCfj9rRGWKD1N6IGg=; b=HNVjOtD26peFregmbEcEBTLgngGgVEQqUTMBc8 b7vC/Psl4rppxCjF+h+AgJ184vOd/dKhQMkx4GzGHaFhf50qKgWcjcdfTYS0GGvI 5ae+26aln90dsTg+MqSv+um0Gl+SaplZbOKYxkrkMDr1DIC62iHlk1dVldYLy6nv AaaVqMTFV94vm7WhTdlw8V6aJo9ncY+QF1d/geeth8vyq5UvxvkBMIh9FwpdIeV3 /vVd8fNbOsHlCliZc0mEjP58pbXSZgyRQXdN4pX5zzMcyDeHWpDvCGQrkjvdTFqP xX/iEMIIfckWx9dbAV2yXeSyKPXsXKa7I6MaJHEhM9GDnOEw== ARC-Authentication-Results: i=1; tb-mx1.topicbox.com; arc=none (no signatures found); bimi=skipped (DMARC did not pass); dkim=invalid (public key: not available, 0-bit key sha256) header.d=polynum.com header.i=@polynum.com header.b=djzSZFUY header.a=-sha256 header.s=202006 x-bits=0; dmarc=none policy.published-domain-policy=none policy.applied-disposition=none policy.evaluated-disposition=none (p=none,d=none,d.eval=none) policy.policy-from=p header.from=polynum.com; iprev=pass smtp.remote-ip=93.17.128.204 (smtp26.services.sfr.fr); spf=pass smtp.mailfrom=thierry.laronde@sfr.fr smtp.helo=smtp26.services.sfr.fr; x-aligned-from=fail; x-me-sender=none; x-ptr=pass smtp.helo=smtp26.services.sfr.fr policy.ptr=smtp26.services.sfr.fr; x-return-mx=pass header.domain=polynum.com policy.is_org=yes (MX Records found: spool.mail.gandi.net,fb.mail.gandi.net); x-return-mx=pass smtp.domain=sfr.fr policy.is_org=yes (MX Records found: smtp-in.sfr.fr); x-tls=pass smtp.version=TLSv1.2 smtp.cipher=ECDHE-RSA-AES256-GCM-SHA384 smtp.bits=256/256; x-vs=clean score=0 state=0 X-ME-VSCause: gggruggvucftvghtrhhoucdtuddrgedvtddrvddugedgfeeiucdltddurdegudelrddttd dmucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgf nhhsuhgsshgtrhhisggvpdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttd enucenucfjughrpeffhffvuffkfhggtggugfgjsehtkeertddttddunecuhfhrohhmpeht lhgrrhhonhguvgesphholhihnhhumhdrtghomhenucggtffrrghtthgvrhhnpeffudejje eijeekffeuvdelleefffffvdfgheevvefhhfeihefgieetffektdfgjeenucffohhmrghi nhepkhgvrhhgihhsrdgtohhmpdhssghfrgdrfhhrnecukfhppeelfedrudejrdduvdekrd dvtdegpdejjedrudelkedruddvuddrkeelnecuvehluhhsthgvrhfuihiivgeptdenucfr rghrrghmpehinhgvthepleefrddujedruddvkedrvddtgedphhgvlhhopehsmhhtphdvie drshgvrhhvihgtvghsrdhsfhhrrdhfrhdpmhgrihhlfhhrohhmpeeothhhihgvrhhrhidr lhgrrhhonhguvgesshhfrhdrfhhrqe X-ME-VSScore: 0 X-ME-VSCategory: clean Received-SPF: pass (sfr.fr: 93.17.128.204 is authorized to use 'thierry.laronde@sfr.fr' in 'mfrom' identity (mechanism 'ip4:93.17.128.0/24' matched)) receiver=tb-mx1.topicbox.com; identity=mailfrom; envelope-from="thierry.laronde@sfr.fr"; helo=smtp26.services.sfr.fr; client-ip=93.17.128.204 Received: from smtp26.services.sfr.fr (smtp26.services.sfr.fr [93.17.128.204]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by tb-mx1.topicbox.com (Postfix) with ESMTPS for <9fans@9fans.net>; Fri, 15 Oct 2021 07:15:10 -0400 (EDT) (envelope-from thierry.laronde@sfr.fr) X-mail-filterd: {"version":"1.3.4","queueID":"6713D1C00385B","contextId":"40d64c03-461c-4fa9-a6be-57dac1dc861d"} Received: from cauchy.polynum.local (89.121.198.77.rev.sfr.net [77.198.121.89]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by msfrf2624.sfr.fr (SMTP Server) with ESMTPS id 6713D1C00385B for <9fans@9fans.net>; Fri, 15 Oct 2021 13:15:09 +0200 (CEST) X-mail-filterd: {"version":"1.3.4","queueID":"486221C042824","contextId":"9a8bce76-b399-47ce-8c18-a84820dc02cd"} X-sfr-mailing: LEGIT X-sfr-spamrating: 40 X-sfr-spam: not-spam Received: from cauchy.polynum.local (89.121.198.77.rev.sfr.net [77.198.121.89]) by msfrf2624.sfr.fr (SMTP Server) with ESMTP id 486221C042824 for <9fans@9fans.net>; Fri, 15 Oct 2021 13:15:09 +0200 (CEST) Received: from cauchy.polynum.local (89.121.198.77.rev.sfr.net [77.198.121.89]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by msfrf2624.sfr.fr (SMTP Server) with ESMTPS for <9fans@9fans.net>; Fri, 15 Oct 2021 13:15:09 +0200 (CEST) Received: from cauchy.polynum.local (localhost [127.0.0.1]) by cauchy.polynum.local (8.15.2/8.15.2) with ESMTPS id 19FBF8Sn001669 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO) for <9fans@9fans.net>; Fri, 15 Oct 2021 13:15:08 +0200 (CEST) Received: (from tlaronde@localhost) by cauchy.polynum.local (8.15.2/8.14.9/Submit) id 19FBF8sH001531 for 9fans@9fans.net; Fri, 15 Oct 2021 13:15:08 +0200 (CEST) X-Authentication-Warning: cauchy.polynum.local: tlaronde set sender to thierry.laronde@sfr.fr using -f Date: Fri, 15 Oct 2021 13:15:08 +0200 From: tlaronde@polynum.com To: 9fans <9fans@9fans.net> Subject: Re: [9fans] Is POSIX:clock_gettime(2) in APE somewhere/anywhere? Message-ID: References: <555AC0ACE5AB14D2940B742B6C01BE5A@eigenstate.org> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <555AC0ACE5AB14D2940B742B6C01BE5A@eigenstate.org> Topicbox-Policy-Reasoning: allow: sender is a member Topicbox-Message-UUID: 2c9278a4-2da9-11ec-b30c-82d5de298fee Archived-At: =?UTF-8?B?PGh0dHBzOi8vOWZhbnMudG9waWNib3guY29tL2dyb3Vwcy85?= =?UTF-8?B?ZmFucy9UMTk5MmQ4OWZkOGIzODJjNy1NZTBkNGI2YWZmZGQ1OTc3Y2JlNmQy?= =?UTF-8?B?YzhiPg==?= List-Help: List-Id: "9fans" <9fans.9fans.net> List-Post: List-Software: Topicbox v0 List-Subscribe: Precedence: list Reply-To: 9fans <9fans@9fans.net> List-Unsubscribe: , Topicbox-Delivery-ID: 2:9fans:437d30aa-c441-11e9-8a57-d036212d11b0:522be890-2105-11eb-b15e-8d699134e1fa:Me0d4b6affdd5977cbe6d2c8b:1:JyCHF0Ff8WNnyjlRwgw3P76G_QZ8oHLHhkayFmldy2I Le Thu, Oct 14, 2021 at 05:54:44PM -0400, ori@eigenstate.org a =C3=A9crit : > Quoth tlaronde@polynum.com: > > But is clock_gettime(2) available in APE in any instance of Plan9 or is > > there a routine achieving the same purpose? >=20 > Here's a quick sketch of something that we could add; note > that the implemented monotonicity is really crude. >=20 > diff 03d870e0283299404b0eb46689d13f8538e83a2f uncommitted > --- a//sys/include/ape/time.h > +++ b//sys/include/ape/time.h > @@ -53,15 +53,20 @@ > #ifdef _POSIX_SOURCE > extern void tzset(void); >=20=20 > +#define CLOCK_REALTIME 1 > +#define CLOCK_MONOTONIC 2 > + > +typedef int clockid_t; > + > struct timespec { > time_t tv_sec; > long tv_nsec; > }; > extern int nanosleep(const struct timespec *req, struct timespec *rem); > -#endif >=20=20 > -#ifdef __cplusplus > -} > +extern int clock_getres(clockid_t, struct timespec*); > +extern int clock_gettime(clockid_t, struct timespec*); > +extern int clock_settime(clockid_t, struct timespec*); > #endif >=20=20 > #ifdef _POSIX_SOURCE > @@ -69,6 +74,10 @@ > extern long timezone; > extern long altzone; > extern int daylight; > +#endif > + > +#ifdef __cplusplus > +} > #endif >=20=20 > #endif /* __TIME_H */ > --- /tmp/diff100001791256 > +++ b/sys/src/ape/lib/bsd/clock.c > @@ -1,0 +1,60 @@ > +#include > +#include > +#include > +#include > + > +/* ap/plan9/9nsec.c */ > +extern long long _NSEC(void); > + > +#define Ns2sec (1000*1000*1000) > + > +int > +clock_getres(clockid_t id, struct timespec *ts) > +{ > + if(id !=3D CLOCK_REALTIME && id !=3D CLOCK_MONOTONIC){ > + errno =3D EINVAL; > + return -1; > + } > + ts->tv_sec =3D 0; > + ts->tv_nsec =3D 1; > + return 0; > +} > + > +int > +clock_settime(clockid_t, struct timespec *) > +{ > + errno =3D EPERM; > + return -1; > +} > + > +int > +clock_gettime(clockid_t clk, struct timespec *ts) > +{ > + static Lock maxlk; > + static long long max; > + long long t; > + > + t =3D _NSEC(); > + switch(clk){ > + case CLOCK_REALTIME: > + /* nothing */ > + break; > + case CLOCK_MONOTONIC: > + /* Bug: we should support a real monotonic clock */ > + lock(&maxlk); > + if(t < max) > + t =3D max; > + else > + max =3D t; > + unlock(&maxlk); > + break; > + default: > + errno =3D EINVAL; > + return -1; > + } > + > + ts->tv_sec =3D t/Ns2sec; > + ts->tv_nsec =3D t%Ns2sec; > + > + return 0; > +} Since only CLOCK_REALTIME is mandatory (up to current POSIX 7), you could d= rop the MONOTONIC variant. And nsec(2) is good enough for REALTIME. Thanks for working on this! Best, --=20 Thierry Laronde http://www.kergis.com/ http://kertex.kergis.com/ http://www.sbfa.fr/ Key fingerprint =3D 0FF7 E906 FBAF FE95 FD89 250D 52B1 AE95 6006 F40C ------------------------------------------ 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T1992d89fd8b382c7-Me0d4b= 6affdd5977cbe6d2c8b Delivery options: https://9fans.topicbox.com/groups/9fans/subscription