diff --git a/configure.in b/configure.in
index 0ed629bf..19f4423a 100644
--- a/configure.in
+++ b/configure.in
@@ -172,7 +172,7 @@ dnl Checks for library functions.
 dnl
 AC_FUNC_ALLOCA
 AC_FUNC_MMAP
-AC_CHECK_FUNCS(strdup strstr strcasecmp strncasecmp strpbrk)
+AC_CHECK_FUNCS(strdup strstr strcasecmp strncasecmp strpbrk memmove)
 AC_CHECK_FUNCS(gettimeofday mktime strptime)
 AC_CHECK_FUNCS(strerror snprintf vsnprintf select signal symlink access isatty)
 AC_CHECK_FUNCS(uname gethostname usleep)
diff --git a/src/ChangeLog b/src/ChangeLog
index fc445bc3..defa970e 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+2001-11-29  Hrvoje Niksic  <hniksic@arsdigita.com>
+
+	* cmpt.c (memmove): Include a simple memmove implementation.
+
 2001-11-29  Hrvoje Niksic  <hniksic@arsdigita.com>
 
 	* headers: Guard against header files being included twice.
diff --git a/src/cmpt.c b/src/cmpt.c
index 6fb7fc04..81502d77 100644
--- a/src/cmpt.c
+++ b/src/cmpt.c
@@ -1226,3 +1226,23 @@ usleep (unsigned long usec)
 
 #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 */
diff --git a/src/config.h.in b/src/config.h.in
index c6413d60..8eaa4b61 100644
--- a/src/config.h.in
+++ b/src/config.h.in
@@ -144,6 +144,9 @@ char *alloca ();
 /* Define if you have the strpbrk function.  */
 #undef HAVE_STRPBRK
 
+/* Define if you have the memmove function.  */
+#undef HAVE_MEMMOVE
+
 /* Define if you have the strptime function.  */
 #undef HAVE_STRPTIME
 
diff --git a/src/sysdep.h b/src/sysdep.h
index 7ac88bc5..226a8c54 100644
--- a/src/sysdep.h
+++ b/src/sysdep.h
@@ -166,6 +166,9 @@ int vsnprintf ();
 #ifndef HAVE_USLEEP
 int usleep ();
 #endif
+#ifndef HAVE_MEMMOVE
+void *memmove ();
+#endif
 
 /* SunOS brain damage -- for some reason, SunOS header files fail to
    declare the functions below, which causes all kinds of problems