adb: turn darwin/windows builds back on, hopefully fix them. am: a9c0ac0c46 am: e4e1ed0e5b am: ddf0740c08 am: 8b88eb368a  -s ours am: 5c81df2726 am: f55e22a7d3 am: df519a87fb am: 7f523007a1 am: 5a91535d1f am: d4b7250550 am: b71782888f am: 8dac33914a am: 2a201fff82
am: a198e406c8

Change-Id: Iaa94f991fc57b3541c70337bb84fb621412ac3f2
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;