summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos <nmav@crystal.(none)>2008-01-14 21:20:21 +0200
committerNikos <nmav@crystal.(none)>2008-01-14 21:20:21 +0200
commit53cf4d59ccc0195cd169ea9e028d3de06c1e9e2d (patch)
treeca67e7a21c09dfab9151b7d588f80faa1abcade2
parent45b71ebbd79544da83cebfc648edcb6b551caadd (diff)
downloadgnutls-53cf4d59ccc0195cd169ea9e028d3de06c1e9e2d.tar.gz
updated from master
-rw-r--r--lgl/m4/memchr.m418
-rw-r--r--lgl/m4/memcmp.m419
-rw-r--r--lgl/m4/memmem.m435
3 files changed, 70 insertions, 2 deletions
diff --git a/lgl/m4/memchr.m4 b/lgl/m4/memchr.m4
new file mode 100644
index 0000000000..91b8636eb8
--- /dev/null
+++ b/lgl/m4/memchr.m4
@@ -0,0 +1,18 @@
+# memchr.m4 serial 4
+dnl Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_MEMCHR],
+[
+ AC_REPLACE_FUNCS(memchr)
+ if test $ac_cv_func_memchr = no; then
+ gl_PREREQ_MEMCHR
+ fi
+])
+
+# Prerequisites of lib/memchr.c.
+AC_DEFUN([gl_PREREQ_MEMCHR], [
+ AC_CHECK_HEADERS(bp-sym.h)
+])
diff --git a/lgl/m4/memcmp.m4 b/lgl/m4/memcmp.m4
new file mode 100644
index 0000000000..099b141b2c
--- /dev/null
+++ b/lgl/m4/memcmp.m4
@@ -0,0 +1,19 @@
+# memcmp.m4 serial 12
+dnl Copyright (C) 2002, 2003, 2004, 2007 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_MEMCMP],
+[
+ AC_FUNC_MEMCMP
+ dnl Note: AC_FUNC_MEMCMP does AC_LIBOBJ(memcmp).
+ if test $ac_cv_func_memcmp_working = no; then
+ AC_DEFINE(memcmp, rpl_memcmp,
+ [Define to rpl_memcmp if the replacement function should be used.])
+ gl_PREREQ_MEMCMP
+ fi
+])
+
+# Prerequisites of lib/memcmp.c.
+AC_DEFUN([gl_PREREQ_MEMCMP], [:])
diff --git a/lgl/m4/memmem.m4 b/lgl/m4/memmem.m4
index e6a3da193c..9767354ad2 100644
--- a/lgl/m4/memmem.m4
+++ b/lgl/m4/memmem.m4
@@ -1,5 +1,5 @@
-# memmem.m4 serial 5
-dnl Copyright (C) 2002, 2003, 2004, 2007 Free Software Foundation, Inc.
+# memmem.m4 serial 7
+dnl Copyright (C) 2002, 2003, 2004, 2007, 2008 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@@ -14,6 +14,37 @@ AC_DEFUN([gl_FUNC_MEMMEM],
AC_CHECK_DECLS_ONCE(memmem)
if test $ac_cv_have_decl_memmem = no; then
HAVE_DECL_MEMMEM=0
+ else
+ AC_CACHE_CHECK([whether memmem works in linear time],
+ [gl_cv_func_memmem_works],
+ [AC_RUN_IFELSE([AC_LANG_PROGRAM([
+#include <string.h> /* for memmem */
+#include <stdlib.h> /* for malloc */
+#include <unistd.h> /* for alarm */
+], [[size_t m = 1000000;
+ char *haystack = (char *) malloc (2 * m + 1);
+ char *needle = (char *) malloc (m + 1);
+ void *result = 0;
+ /* Failure to compile this test due to missing alarm is okay,
+ since all such platforms (mingw) also lack memmem. */
+ alarm (5);
+ if (haystack && needle)
+ {
+ memset (haystack, 'A', 2 * m);
+ haystack[2 * m] = 'B';
+ memset (needle, 'A', m);
+ needle[m] = 'B';
+ result = memmem (haystack, 2 * m + 1, needle, m + 1);
+ }
+ return !result || !memmem ("a", 1, 0, 0);]])],
+ [gl_cv_func_memmem_works=yes], [gl_cv_func_memmem_works=no],
+ [dnl pessimistically assume the worst, since even glibc 2.6.1
+ dnl has quadratic complexity in its memmem
+ gl_cv_func_memmem_works=no])])
+ if test $gl_cv_func_memmem_works = no; then
+ REPLACE_MEMMEM=1
+ AC_LIBOBJ([memmem])
+ fi
fi
gl_PREREQ_MEMMEM
])