9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] APE:sys/time.h: long instead of suseconds_t
@ 2021-10-14 17:56 tlaronde
  2021-10-14 18:02 ` [9fans] " tlaronde
  0 siblings, 1 reply; 5+ messages in thread
From: tlaronde @ 2021-10-14 17:56 UTC (permalink / raw)
  To: 9fans

As suggested by ori@eigenstate.org, I have used gettimeofday(2) to
achieve what I needed.

But I had to change suseconds_t (in POSIX) to long (in Plan9
ape/include/sys/time.h).

But are all the compilers in Plan9 making long an octabytes, whatever
the arch and the machine? Because a long, if it is a tetra, will never
hold the value...

Furthermore, for portability, there should be a typedef associating
suseconds_t to long (or vlong, if long is not guaranteed to be an
octa).

I'm puzzled by this...

Meanwhile, with this, kerTeX compiles on Plan9 for the dev version...
-- 
        Thierry Laronde <tlaronde +AT+ polynum +dot+ com>
                     http://www.kergis.com/
                    http://kertex.kergis.com/
                       http://www.sbfa.fr/
Key fingerprint = 0FF7 E906 FBAF FE95 FD89  250D 52B1 AE95 6006 F40C

------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/T232b7176352c012b-Mb2d8a8973e450a39ea8bca6a
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [9fans] Re: APE:sys/time.h: long instead of suseconds_t
  2021-10-14 17:56 [9fans] APE:sys/time.h: long instead of suseconds_t tlaronde
@ 2021-10-14 18:02 ` tlaronde
  2021-10-14 18:11   ` Conor Williams
  0 siblings, 1 reply; 5+ messages in thread
From: tlaronde @ 2021-10-14 18:02 UTC (permalink / raw)
  To: 9fans

Le Thu, Oct 14, 2021 at 07:56:37PM +0200, tlaronde a écrit :
> As suggested by ori@eigenstate.org, I have used gettimeofday(2) to
> achieve what I needed.
> 
> But I had to change suseconds_t (in POSIX) to long (in Plan9
> ape/include/sys/time.h).
> 
> But are all the compilers in Plan9 making long an octabytes, whatever
> the arch and the machine? Because a long, if it is a tetra, will never
> hold the value...

I misread: the microseconds are for the fractional part. I was still
focusing on nsec() and taking the one for the other.

But the following still holds:

> 
> Furthermore, for portability, there should be a typedef associating
> suseconds_t to long (or vlong, if long is not guaranteed to be an
> octa).
> 
-- 
        Thierry Laronde <tlaronde +AT+ polynum +dot+ com>
                     http://www.kergis.com/
                    http://kertex.kergis.com/
                       http://www.sbfa.fr/
Key fingerprint = 0FF7 E906 FBAF FE95 FD89  250D 52B1 AE95 6006 F40C

------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/T232b7176352c012b-M25528c1fccfb87e2a5f36584
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [9fans] Re: APE:sys/time.h: long instead of suseconds_t
  2021-10-14 18:02 ` [9fans] " tlaronde
@ 2021-10-14 18:11   ` Conor Williams
  2021-10-14 18:30     ` tlaronde
  0 siblings, 1 reply; 5+ messages in thread
From: Conor Williams @ 2021-10-14 18:11 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 1363 bytes --]

surely you can shift a 64 bit long?

On Thu, Oct 14, 2021 at 6:04 PM <tlaronde@polynum.com> wrote:

> Le Thu, Oct 14, 2021 at 07:56:37PM +0200, tlaronde a écrit :
> > As suggested by ori@eigenstate.org, I have used gettimeofday(2) to
> > achieve what I needed.
> >
> > But I had to change suseconds_t (in POSIX) to long (in Plan9
> > ape/include/sys/time.h).
> >
> > But are all the compilers in Plan9 making long an octabytes, whatever
> > the arch and the machine? Because a long, if it is a tetra, will never
> > hold the value...
>
> I misread: the microseconds are for the fractional part. I was still
> focusing on nsec() and taking the one for the other.
>
> But the following still holds:
>
> >
> > Furthermore, for portability, there should be a typedef associating
> > suseconds_t to long (or vlong, if long is not guaranteed to be an
> > octa).
> >
> --
> Thierry Laronde <tlaronde +AT+ polynum +dot+ com>
>              http://www.kergis.com/
>             http://kertex.kergis.com/
>                http://www.sbfa.fr/
> Key fingerprint = 0FF7 E906 FBAF FE95 FD89  250D 52B1 AE95 6006 F40C

------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/T232b7176352c012b-Mf1f6b24803e829b411b0691d
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

[-- Attachment #2: Type: text/html, Size: 3218 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [9fans] Re: APE:sys/time.h: long instead of suseconds_t
  2021-10-14 18:11   ` Conor Williams
@ 2021-10-14 18:30     ` tlaronde
  2021-10-14 18:48       ` Conor Williams
  0 siblings, 1 reply; 5+ messages in thread
From: tlaronde @ 2021-10-14 18:30 UTC (permalink / raw)
  To: 9fans

Le Thu, Oct 14, 2021 at 06:11:54PM +0000, Conor Williams a écrit :
> surely you can shift a 64 bit long?
> 

In fact, I have read cursorily the man page and misread "the time is
expressed in seconds and microseconds since EPOCH" to mean "expressed
in seconds AND expressed in microseconds" while there is a structure
because there is the integer (seconds) part and the fractional
(microseconds) part. Hum...

So, yes, the result (in microseconds) can be hold in a long long.

And for long instead of suseconds_t, I'm probably the only one who will
ever directly use suseconds_t in the code for a variable thinking it is
like the result of nsec(2) and it is probably a type that will never
appear in real user code.

So let this RIP.

> On Thu, Oct 14, 2021 at 6:04 PM <tlaronde@polynum.com> wrote:
> 
> > Le Thu, Oct 14, 2021 at 07:56:37PM +0200, tlaronde a écrit :
> > > As suggested by ori@eigenstate.org, I have used gettimeofday(2) to
> > > achieve what I needed.
> > >
> > > But I had to change suseconds_t (in POSIX) to long (in Plan9
> > > ape/include/sys/time.h).
> > >
> > > But are all the compilers in Plan9 making long an octabytes, whatever
> > > the arch and the machine? Because a long, if it is a tetra, will never
> > > hold the value...
> >
> > I misread: the microseconds are for the fractional part. I was still
> > focusing on nsec() and taking the one for the other.
> >
> > But the following still holds:
> >
> > >
> > > Furthermore, for portability, there should be a typedef associating
> > > suseconds_t to long (or vlong, if long is not guaranteed to be an
> > > octa).
> > >
> > --
> > Thierry Laronde <tlaronde +AT+ polynum +dot+ com>
> >              http://www.kergis.com/
> >             http://kertex.kergis.com/
> >                http://www.sbfa.fr/
> > Key fingerprint = 0FF7 E906 FBAF FE95 FD89  250D 52B1 AE95 6006 F40C

-- 
        Thierry Laronde <tlaronde +AT+ polynum +dot+ com>
                     http://www.kergis.com/
                    http://kertex.kergis.com/
                       http://www.sbfa.fr/
Key fingerprint = 0FF7 E906 FBAF FE95 FD89  250D 52B1 AE95 6006 F40C

------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/T232b7176352c012b-M86b19184ee7cf17b00f55809
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [9fans] Re: APE:sys/time.h: long instead of suseconds_t
  2021-10-14 18:30     ` tlaronde
@ 2021-10-14 18:48       ` Conor Williams
  0 siblings, 0 replies; 5+ messages in thread
From: Conor Williams @ 2021-10-14 18:48 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 2645 bytes --]

yeah, that's exactly it... well done man... good stuff ta failte roimhat...

/c:20211410:1900

On Thu, Oct 14, 2021 at 6:31 PM <tlaronde@polynum.com> wrote:

> Le Thu, Oct 14, 2021 at 06:11:54PM +0000, Conor Williams a écrit :
> > surely you can shift a 64 bit long?
> >
>
> In fact, I have read cursorily the man page and misread "the time is
> expressed in seconds and microseconds since EPOCH" to mean "expressed
> in seconds AND expressed in microseconds" while there is a structure
> because there is the integer (seconds) part and the fractional
> (microseconds) part. Hum...
>
> So, yes, the result (in microseconds) can be hold in a long long.
>
> And for long instead of suseconds_t, I'm probably the only one who will
> ever directly use suseconds_t in the code for a variable thinking it is
> like the result of nsec(2) and it is probably a type that will never
> appear in real user code.
>
> So let this RIP.
>
> > On Thu, Oct 14, 2021 at 6:04 PM <tlaronde@polynum.com> wrote:
> >
> > > Le Thu, Oct 14, 2021 at 07:56:37PM +0200, tlaronde a écrit :
> > > > As suggested by ori@eigenstate.org, I have used gettimeofday(2) to
> > > > achieve what I needed.
> > > >
> > > > But I had to change suseconds_t (in POSIX) to long (in Plan9
> > > > ape/include/sys/time.h).
> > > >
> > > > But are all the compilers in Plan9 making long an octabytes, whatever
> > > > the arch and the machine? Because a long, if it is a tetra, will
> never
> > > > hold the value...
> > >
> > > I misread: the microseconds are for the fractional part. I was still
> > > focusing on nsec() and taking the one for the other.
> > >
> > > But the following still holds:
> > >
> > > >
> > > > Furthermore, for portability, there should be a typedef associating
> > > > suseconds_t to long (or vlong, if long is not guaranteed to be an
> > > > octa).
> > > >
> > > --
> > > Thierry Laronde <tlaronde +AT+ polynum +dot+ com>
> > >              http://www.kergis.com/
> > >             http://kertex.kergis.com/
> > >                http://www.sbfa.fr/
> > > Key fingerprint = 0FF7 E906 FBAF FE95 FD89  250D 52B1 AE95 6006 F40C
> 
> --
> Thierry Laronde <tlaronde +AT+ polynum +dot+ com>
>              http://www.kergis.com/
>             http://kertex.kergis.com/
>                http://www.sbfa.fr/
> Key fingerprint = 0FF7 E906 FBAF FE95 FD89  250D 52B1 AE95 6006 F40C

------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/T232b7176352c012b-Mf72f1806b8d3aa8b52f6e895
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

[-- Attachment #2: Type: text/html, Size: 5241 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-10-14 18:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-14 17:56 [9fans] APE:sys/time.h: long instead of suseconds_t tlaronde
2021-10-14 18:02 ` [9fans] " tlaronde
2021-10-14 18:11   ` Conor Williams
2021-10-14 18:30     ` tlaronde
2021-10-14 18:48       ` Conor Williams

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).