From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from alt2.a-painless.mh.aa.net.uk ([90.155.4.51]) by ewsd; Tue May 12 11:35:28 EDT 2020 Received: from 132.198.187.81.in-addr.arpa ([81.187.198.132] helo=quintile.net) by a-painless.mh.aa.net.uk with esmtp (Exim 4.92) (envelope-from ) id 1jYWvs-0003jx-5B for 9front@9front.org; Tue, 12 May 2020 16:35:00 +0100 Received: from [192.168.1.37] ([81.187.198.132]) by quintile.net; Tue May 12 16:34:58 BST 2020 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Steve Simon Mime-Version: 1.0 (1.0) Subject: Re: [9front] etimer() assumes seconds together with APE Date: Tue, 12 May 2020 16:34:57 +0100 Message-Id: References: In-Reply-To: To: 9front@9front.org X-Mailer: iPhone Mail (17E262) List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: self-signing standard this brings back memories of the libplot on v7 unix, which had a close() ent= rypoint. you had to link your app in two stages. the graphics stuff got bound to libp= lot with -r to keep the relocation data, then the result linked with the rem= ainder of the app. history just keeps repeating. -Steve > On 12 May 2020, at 5:10 pm, jamos@oboj.net wrote: >=20 > =EF=BB=BFDear list, >=20 > The function etimer(ulong key, int n) is used in libevent to get a timer e= vent every 'n' milliseconds. However, if APE is used, etimer() delivers an e= vent every 'n' second instead. The reason is that sleep() assumes seconds in= APE and milliseconds in Plan 9. >=20 > I am aware that combining Plan 9 libraries with APE is a bit risky. When I= earlier wanted to use etimer() in the netsurf framebuffer driver, I assumed= it didn't work under APE, but I was not patient enough to wait 1000 seconds= , when I thought it would fire after one second. >=20 > Would this be considered a bug? It would be more consistent if etimer() wo= uld take milliseconds as well under APE, and it would also be more handy if o= ne would like to sleep less than a second. I tried to find APE programs that= might depend on the current behaviour, but I don't think there are many. >=20 > The following test program prints a string every 10 seconds (in APE) and e= very 10ms (if it can manage) under native Plan9. Stop by killing the process= es. >=20 > /* Compile under native plan9: > * 8c ev.c; 8l -o native ev.8 > * > * Compile under APE: > * pcc -D_POSIX_SOURCE -D_PLAN9_SOURCE -o posix ev.c > */ >=20 > #include > #ifdef _POSIX_SOURCE > #include > #else > #include > #endif > #include > #include >=20 > void > eresized(int) {} >=20 > void > main() > { > int tim; /* timer ticket */ > int e; /* type of event */ > Event ev; /* event struct */ >=20 > initdraw(0, 0, "timer test"); > einit(Ekeyboard|Emouse); > tim =3D etimer(0, 10); /* 10ms or 10s?*/ > for(;;){ > e =3D event(&ev); > if(e =3D=3D tim) > print("Timer!\n"); >=20 > } > }