On 2017-07-27 09:48:18 -0700, Kevin J. McCarthy wrote:
> On Thu, Jul 27, 2017 at 12:56:01PM +0200, Vincent Lefevre wrote:
> > And shouldn't gettimeofday be replaced by this method in curs_lib.c
> > for consistency?
> 
> I apologize for being an idiot.  :-) I looked around for other uses to
> try and figure out what function to use, and missed the invocation in
> curs_lib.c.
> 
> Would it be better to simply change the new mutt_socket.c code to use
> gettimeofday() instead?

I was wondering, but the gettimeofday(2) man page says in the
"CONFORMING TO" section:

  POSIX.1-2008 marks gettimeofday() as obsolete, recommending the
  use of clock_gettime(2) instead.

Now, I don't know whether there are old systems that have gettimeofday
but not clock_gettime with CLOCK_MONOTONIC... It seems so:

  https://github.com/exdev/exsdk/wiki/gettimeofday-vs-clock_gettime

"My conclusion is, the mac-osx doesn't support clock_gettime() so you
don't have too much choice but use gettimeofday(), and it is not that
bad in my experience." (March 2014)

https://stackoverflow.com/questions/12392278/measure-time-in-linux-time-vs-clock-vs-getrusage-vs-clock-gettime-vs-gettimeof

says that "POSIX 7 describes CLOCK_MONOTONIC as an optional extension."
and "for OS X, clock_gettime has been implemented as of 10.12 (Sierra)."

So, as long as gettimeofday() is still supported in practice, I'd
say that it should be used instead of clock_gettime.

-- 
Vincent Lefèvre <vinc...@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)

Reply via email to