#11 newt: Switch to nanosleep
Closed a year ago by mlichvar. Opened a year ago by mangix.
mangix/newt h  into  master

file modified
+2 -1
@@ -1031,7 +1031,8 @@ 

   * @param int - number of usecs to wait for.

   */

  void newtDelay(unsigned int usecs) {

-     usleep(usecs);

+     struct timespec t = { usecs/1000000, (usecs % 1000000) * 1000 };

+     nanosleep(&t, NULL);

  }

  

  struct eventResult newtDefaultEventHandler(newtComponent c,

uslep was removed in POSIX 2008 and is optionally unavailable with
uClibc-ng.

Signed-off-by: Rosen Penev rosenp@gmail.com

I suspect this wouldn't work with long delays. The tv_sec field should to be set to seconds and tv_nsec to the remainder.

rebased onto 9c12261

a year ago

Fixed. Please review.

Applied with some minor changes (added <time.h>). Thanks.

Pull-Request has been closed by mlichvar

a year ago
Metadata
Changes Summary 1