OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-7.1/] [gdb/] [gnulib/] [m4/] [memmem.m4] - Blame information for rev 227

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 227 jeremybenn
# memmem.m4 serial 9
2
dnl Copyright (C) 2002, 2003, 2004, 2007, 2008, 2009, 2010
3
Free Software Foundation, Inc.
4
dnl This file is free software; the Free Software Foundation
5
dnl gives unlimited permission to copy and/or distribute it,
6
dnl with or without modifications, as long as this notice is preserved.
7
 
8
dnl Check that memmem is present.
9
AC_DEFUN([gl_FUNC_MEMMEM_SIMPLE],
10
[
11
  dnl Persuade glibc <string.h> to declare memmem().
12
  AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
13
 
14
  AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
15
  AC_REPLACE_FUNCS(memmem)
16
  AC_CHECK_DECLS_ONCE(memmem)
17
  if test $ac_cv_have_decl_memmem = no; then
18
    HAVE_DECL_MEMMEM=0
19
  fi
20
  gl_PREREQ_MEMMEM
21
]) # gl_FUNC_MEMMEM_SIMPLE
22
 
23
dnl Additionally, check that memmem is efficient and handles empty needles.
24
AC_DEFUN([gl_FUNC_MEMMEM],
25
[
26
  AC_REQUIRE([gl_FUNC_MEMMEM_SIMPLE])
27
  if test $ac_cv_have_decl_memmem = yes; then
28
    AC_CACHE_CHECK([whether memmem works in linear time],
29
      [gl_cv_func_memmem_works],
30
      [AC_RUN_IFELSE([AC_LANG_PROGRAM([
31
#include <string.h> /* for memmem */
32
#include <stdlib.h> /* for malloc */
33
#include <unistd.h> /* for alarm */
34
], [[size_t m = 1000000;
35
    char *haystack = (char *) malloc (2 * m + 1);
36
    char *needle = (char *) malloc (m + 1);
37
    void *result = 0;
38
    /* Failure to compile this test due to missing alarm is okay,
39
       since all such platforms (mingw) also lack memmem.  */
40
    alarm (5);
41
    /* Check for quadratic performance.  */
42
    if (haystack && needle)
43
      {
44
        memset (haystack, 'A', 2 * m);
45
        haystack[2 * m] = 'B';
46
        memset (needle, 'A', m);
47
        needle[m] = 'B';
48
        result = memmem (haystack, 2 * m + 1, needle, m + 1);
49
      }
50
    /* Check for empty needle behavior.  */
51
    return !result || !memmem ("a", 1, 0, 0);]])],
52
        [gl_cv_func_memmem_works=yes], [gl_cv_func_memmem_works=no],
53
        [dnl pessimistically assume the worst, since even glibc 2.6.1
54
         dnl has quadratic complexity in its memmem
55
         gl_cv_func_memmem_works="guessing no"])])
56
    if test "$gl_cv_func_memmem_works" != yes; then
57
      REPLACE_MEMMEM=1
58
      AC_LIBOBJ([memmem])
59
    fi
60
  fi
61
]) # gl_FUNC_MEMMEM
62
 
63
# Prerequisites of lib/memmem.c.
64
AC_DEFUN([gl_PREREQ_MEMMEM], [:])

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.