adb: actually fix the windows build. am: 58eda35ace am: bbd6d7b3e7 am: 1ceca95f8e am: 0d5c1a7745  -s ours am: 8621700765 am: d0b35e9e1d am: 08420b5826 am: c80cd472c7 am: 257ae8c6b9 am: 6cac5c9815 am: d1a9747589 am: a97e943936 am: 77837ee280
am: 8dab84a673

Change-Id: Ibc6f501754c79feaeb4f96594e74e0cdf0e25276
diff --git a/toolbox/top.c b/toolbox/top.c
index 6fda132..e70ea31 100644
--- a/toolbox/top.c
+++ b/toolbox/top.c
@@ -31,6 +31,7 @@
 
 #include <ctype.h>
 #include <dirent.h>
+#include <errno.h>
 #include <grp.h>
 #include <inttypes.h>
 #include <pwd.h>
@@ -38,6 +39,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <sys/types.h>
+#include <time.h>
 #include <unistd.h>
 
 #include <cutils/sched_policy.h>
@@ -180,6 +182,11 @@
     new_procs = old_procs = NULL;
 
     read_procs();
+
+    // Pause 250ms to get better data and avoid divide by zero later (http://b/32478213).
+    struct timespec ts = { .tv_sec = 0, .tv_nsec = 250000000 };
+    TEMP_FAILURE_RETRY(nanosleep(&ts, &ts));
+
     while ((iterations == -1) || (iterations-- > 0)) {
         old_procs = new_procs;
         num_old_procs = num_new_procs;