rem: if (clock_get_realtime (&ts_start) == NULL)
add: if (gettime (&ts_start) != 0)
context: xnanosleep (double seconds){  int overflow;  double ns;  struct timespec ts_start;  struct timespec ts_sleep;  struct timespec ts_stop;  assert (0 <= seconds);  if (clock_get_realtime (&ts_start) == NULL)    return -1;  /* Separate whole seconds from nanoseconds.     Be careful to detect any overflow.  */  ts_sleep.tv_sec = seconds;  ns = 1e9 * (seconds - ts_sleep.tv_sec);  overflow = ! (ts_sleep.tv_sec <= seconds && 0 <= ns && ns <= 1e9);  ts_sleep.tv_nsec = ns;  /* Round up to the next whole number, if necessary, so that we     always sleep for at least the requested amount of time.  Assuming     the default rounding mode, we don't have to worry about the     rounding error when computing 'ns' above, since the error won't     cause 'ns' to drop below an integer boundary.  */  ts_sleep.tv_nsec += (ts_sleep.tv_nsec < ns);  /* Normalize the interval length.  nanosleep requires this.  */  if (1000000000 <= ts_sleep.tv_nsec)    {      time_t t = ts_sleep.tv_sec + 1;      /* Detect integer overflow.  */      overflow |= (t < ts_sleep.tv_sec);      ts_sleep.tv_sec = t;      ts_sleep.tv_nsec -= 1000000000;    }  /* Compute the time until which we should sleep.  */  ts_stop.tv_sec = ts_start.tv_sec + ts_sleep.tv_sec;  ts_stop.tv_nsec = ts_start.tv_nsec + ts_sleep.tv_nsec;  if (1000000000 <= ts_stop.tv_nsec)    {      ++ts_stop.tv_sec;      ts_stop.tv_nsec -= 1000000000;    }  /* Detect integer overflow.  */  overflow |= (ts_stop.tv_sec < ts_start.tv_sec	       || (ts_stop.tv_sec == ts_start.tv_sec		   && ts_stop.tv_nsec < ts_start.tv_nsec));  if (overflow)    {      /* Fix ts_sleep and ts_stop, which may be garbage due to overflow.  */      ts_sleep.tv_sec = ts_stop.tv_sec = TIME_T_MAX;      ts_sleep.tv_nsec = ts_stop.tv_nsec = 999999999;    }  while (nanosleep (&ts_sleep, NULL) != 0)    {      if (errno != EINTR)	return -1;      /* POSIX.1-2001 requires that when a process is suspended, then	 resumed, nanosleep (A, B) returns -1, sets errno to EINTR,	 and sets *B to the time remaining at the point of resumption.	 However, some versions of the Linux kernel incorrectly return	 the time remaining at the point of suspension.  Work around	 this bug by computing the remaining time here, rather than by	 relying on nanosleep's computation.  */      if (! timespec_subtract (&ts_sleep, &ts_stop,			       clock_get_realtime (&ts_start)))	break;    }  return 0;}