Add is_erestart helper function

* defs.h (is_erestart): New prototype.
* syscall.c (is_erestart): New function.
* time.c (sys_nanosleep): Use is_erestart,
temporarily_clear_syserror, and restore_cleared_syserror.
diff --git a/syscall.c b/syscall.c
index aaa44ea..d4599e4 100644
--- a/syscall.c
+++ b/syscall.c
@@ -1131,6 +1131,20 @@
 		trace_syscall_exiting(tcp) : trace_syscall_entering(tcp);
 }
 
+bool
+is_erestart(struct tcb *tcp)
+{
+	switch (tcp->u_error) {
+		case ERESTARTSYS:
+		case ERESTARTNOINTR:
+		case ERESTARTNOHAND:
+		case ERESTART_RESTARTBLOCK:
+			return true;
+		default:
+			return false;
+	}
+}
+
 static int saved_u_error;
 
 void