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

Subversion Repositories openrisc_me

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 330 jeremybenn
# memmem.m4 serial 14
2
dnl Copyright (C) 2002, 2003, 2004, 2007, 2008, 2009, 2010 Free Software
3
dnl 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 <signal.h> /* for signal */
32
#include <string.h> /* for memmem */
33
#include <stdlib.h> /* for malloc */
34
#include <unistd.h> /* for alarm */
35
]], [[size_t m = 1000000;
36
    char *haystack = (char *) malloc (2 * m + 1);
37
    char *needle = (char *) malloc (m + 1);
38
    void *result = 0;
39
    /* Failure to compile this test due to missing alarm is okay,
40
       since all such platforms (mingw) also lack memmem.  */
41
    signal (SIGALRM, SIG_DFL);
42
    alarm (5);
43
    /* Check for quadratic performance.  */
44
    if (haystack && needle)
45
      {
46
        memset (haystack, 'A', 2 * m);
47
        haystack[2 * m] = 'B';
48
        memset (needle, 'A', m);
49
        needle[m] = 'B';
50
        result = memmem (haystack, 2 * m + 1, needle, m + 1);
51
      }
52
    /* Check for empty needle behavior.  */
53
    return !result || !memmem ("a", 1, 0, 0);]])],
54
        [gl_cv_func_memmem_works=yes], [gl_cv_func_memmem_works=no],
55
        [dnl Only glibc >= 2.9 and cygwin >= 1.7.0 are known to have a
56
         dnl memmem that works in linear time.
57
         AC_EGREP_CPP([Lucky user],
58
           [
59
#include <features.h>
60
#ifdef __GNU_LIBRARY__
61
 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 9) || (__GLIBC__ > 2)
62
  Lucky user
63
 #endif
64
#endif
65
#ifdef __CYGWIN__
66
 #include <cygwin/version.h>
67
 #if CYGWIN_VERSION_DLL_MAJOR >= 1007
68
  Lucky user
69
 #endif
70
#endif
71
           ],
72
           [gl_cv_func_memmem_works=yes],
73
           [gl_cv_func_memmem_works="guessing no"])
74
        ])
75
      ])
76
    if test "$gl_cv_func_memmem_works" != yes; then
77
      REPLACE_MEMMEM=1
78
      AC_LIBOBJ([memmem])
79
    fi
80
  fi
81
]) # gl_FUNC_MEMMEM
82
 
83
# Prerequisites of lib/memmem.c.
84
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.