]> sjero.net Git - wget/blobdiff - src/cmpt.c
[svn] Check for memmove and implement one if it's missing.
[wget] / src / cmpt.c
index bfc7b2c9ab06275ab043062187f5becd594fba43..81502d779d689988dd3f05640031ea306ff43bf1 100644 (file)
@@ -1206,3 +1206,43 @@ strptime (buf, format, tm)
   return strptime_internal (buf, format, tm, &decided);
 }
 #endif /* not HAVE_STRPTIME */
+
+
+#ifndef HAVE_USLEEP
+#ifndef WINDOWS
+
+/* A simple usleep implementation based on select().  For Unix and
+   Unix-like systems.  */
+
+int
+usleep (unsigned long usec)
+{
+  struct timeval tm;
+  tm.tv_sec = 0;
+  tm.tv_usec = usec;
+  select (0, NULL, NULL, NULL, &tm);
+  return 0;
+}
+
+#endif /* not WINDOWS */
+#endif /* not HAVE_USLEEP */
+
+
+#ifndef HAVE_MEMMOVE
+void *
+memmove (char *dest, const char *source, unsigned length)
+{
+  char *d0 = dest;
+  if (source < dest)
+    /* Moving from low mem to hi mem; start at end.  */
+    for (source += length, dest += length; length; --length)
+      *--dest = *--source;
+  else if (source != dest)
+    {
+      /* Moving from hi mem to low mem; start at beginning.  */
+      for (; length; --length)
+       *dest++ = *source++;
+    }
+  return (void *) d0;
+}
+#endif /* not HAVE_MEMMOVE */