]> git.ipfire.org Git - thirdparty/newt.git/commitdiff
switch to nanosleep
authorRosen Penev <rosenp@gmail.com>
Mon, 7 Oct 2019 23:11:23 +0000 (23:11 +0000)
committerMiroslav Lichvar <mlichvar@redhat.com>
Tue, 8 Oct 2019 07:50:01 +0000 (09:50 +0200)
usleep was removed in POSIX 2008 and is optionally unavailable with
uClibc-ng.

[ ML: include <time.h> and improve indentation. ]

Signed-off-by: Rosen Penev <rosenp@gmail.com>
newt.c

diff --git a/newt.c b/newt.c
index c1dd916db1b4b56ea549aa947572daf7bd6d922a..da181a1377c9f8682ac63a87a20f7adb10224efb 100644 (file)
--- a/newt.c
+++ b/newt.c
@@ -8,6 +8,7 @@
 #include <sys/time.h>
 #include <sys/types.h>
 #include <termios.h>
+#include <time.h>
 #include <unistd.h>
 #include <wchar.h>
 
@@ -1031,7 +1032,9 @@ static void freeKeymap() {
  * @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,