attn: Add wait for power fault handling

Added a 10 second delay between checkstop detection and call to analyzer
so that power fault handler logic can intervene before analyzer begins
logging  events.

Signed-off-by: Ben Tyner <ben.tyner@ibm.com>
Change-Id: I13d36e9fed35ff8af690a5f38bf4476027a4fea2
diff --git a/attn/attn_common.cpp b/attn/attn_common.cpp
index d387b4f..d3bb6ba 100644
--- a/attn/attn_common.cpp
+++ b/attn/attn_common.cpp
@@ -157,4 +157,40 @@
     return recoverableErrors;
 }
 
+/** @brief timesec less-than-equal-to compare */
+bool operator<=(const timespec& lhs, const timespec& rhs)
+{
+    if (lhs.tv_sec == rhs.tv_sec)
+        return lhs.tv_nsec <= rhs.tv_nsec;
+    else
+        return lhs.tv_sec <= rhs.tv_sec;
+}
+
+/** @brief sleep for n-seconds */
+void sleepSeconds(const unsigned int seconds)
+{
+    auto count = seconds;
+    struct timespec requested, remaining;
+
+    while (0 < count)
+    {
+        requested.tv_sec  = 1;
+        requested.tv_nsec = 0;
+        remaining         = requested;
+
+        while (-1 == nanosleep(&requested, &remaining))
+        {
+            // if not changing or implausible then abort
+            if (requested <= remaining)
+            {
+                break;
+            }
+
+            // back to sleep
+            requested = remaining;
+        }
+        count--;
+    }
+}
+
 } // namespace attn