stress: replace usleep with nanosleep 13163/head
authorRosen Penev <rosenp@gmail.com>
Sun, 16 Aug 2020 00:56:51 +0000 (17:56 -0700)
committerRosen Penev <rosenp@gmail.com>
Tue, 18 Aug 2020 21:56:24 +0000 (14:56 -0700)
The former is deprecated.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
utils/stress/Makefile
utils/stress/patches/010-usleep.patch [new file with mode: 0644]

index b7712e4db8b9675e204298b309728a1160b9ca30..3a66817ddfb7bbf26350b65f33a1733fe0d55d16 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=stress
 PKG_VERSION:=1.0.4
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=https://fossies.org/linux/privat
diff --git a/utils/stress/patches/010-usleep.patch b/utils/stress/patches/010-usleep.patch
new file mode 100644 (file)
index 0000000..6946726
--- /dev/null
@@ -0,0 +1,46 @@
+--- a/src/stress.c
++++ b/src/stress.c
+@@ -262,6 +262,7 @@ main (int argc, char **argv)
+       /* Calculate the backoff value so we get good fork throughput.  */
+       backoff = do_backoff * forks;
++      struct timespec b = {backoff / 1000000, (backoff % 1000000) * 1000};
+       dbg (stdout, "using backoff sleep of %llius\n", backoff);
+       /* If we are supposed to respect a timeout, calculate it.  */
+@@ -296,7 +297,7 @@ main (int argc, char **argv)
+             {
+             case 0:            /* child */
+               alarm (timeout);
+-              usleep (backoff);
++              nanosleep(&b, NULL);
+               if (do_dryrun)
+                 exit (0);
+               exit (hogcpu ());
+@@ -317,7 +318,7 @@ main (int argc, char **argv)
+             {
+             case 0:            /* child */
+               alarm (timeout);
+-              usleep (backoff);
++              nanosleep(&b,&b);
+               if (do_dryrun)
+                 exit (0);
+               exit (hogio ());
+@@ -337,7 +338,7 @@ main (int argc, char **argv)
+             {
+             case 0:            /* child */
+               alarm (timeout);
+-              usleep (backoff);
++              nanosleep(&b, &b);
+               if (do_dryrun)
+                 exit (0);
+               exit (hogvm
+@@ -358,7 +359,7 @@ main (int argc, char **argv)
+             {
+             case 0:            /* child */
+               alarm (timeout);
+-              usleep (backoff);
++              nanosleep(&b, &b);
+               if (do_dryrun)
+                 exit (0);
+               exit (hoghdd (do_hdd_bytes));