[Nut-upsdev] patch: Replace many usleep and some sleep calls with nanosleep

Regid Ichira regid23 at yahoo.com
Mon Oct 3 17:52:59 UTC 2011


--- On Mon, 10/3/11, Stuart D Gathman <stuart at bmsi.com> wrote:

> From: Stuart D Gathman <stuart at bmsi.com>
> Subject: Re: [Nut-upsdev] patch: Replace many usleep and some sleep calls with nanosleep
> To: nut-upsdev at lists.alioth.debian.org
> Date: Monday, October 3, 2011, 5:24 PM
> On 10/03/2011 01:02 PM, Regid Ichira
> wrote:
> > -       
> usleep(250000);
> > +        struct timespec
> delay = {0, 250e6}; nanosleep(&delay, NULL);
> >
> Would it be better to define a local version of usleep in
> terms of
> nanosleep?  I suspect the library version already does
> that, but if the
> library version is going away, a local version is much more
> concise and
> readable than calling nanosleep directly.  If there
> are concerns about
> linking, the local version could be, e.g, u_sleep, since
> all the calls
> are getting touched anyway.
> 


  I am not sure I understood:
1. Are you saying that usleep is already defined in terms of nanosleep? 
   Where?
  Or
2. Are you suggesting to keep the current code, and use something like
   u_sleep(time) { return nanosleep(time) }?
In any case, I think that using nanosleep directly, without any intermediate functions, is more readable.



More information about the Nut-upsdev mailing list