annotate m4/memchr.m4 @ 398:7987ee447833 3.0-beta1

Added generated files for release
author lost@l-w.ca
date Fri, 23 Jul 2010 17:18:52 -0600
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
398
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
1 # memchr.m4 serial 7
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
2 dnl Copyright (C) 2002-2004, 2009-2010 Free Software Foundation, Inc.
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
3 dnl This file is free software; the Free Software Foundation
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
4 dnl gives unlimited permission to copy and/or distribute it,
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
5 dnl with or without modifications, as long as this notice is preserved.
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
6
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
7 AC_DEFUN_ONCE([gl_FUNC_MEMCHR],
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
8 [
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
9 dnl Check for prerequisites for memory fence checks.
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
10 gl_FUNC_MMAP_ANON
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
11 AC_CHECK_HEADERS_ONCE([sys/mman.h])
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
12 AC_CHECK_FUNCS_ONCE([mprotect])
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
13
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
14 dnl These days, we assume memchr is present. But just in case...
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
15 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
16 AC_REPLACE_FUNCS([memchr])
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
17 if test $ac_cv_func_memchr = no; then
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
18 gl_PREREQ_MEMCHR
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
19 REPLACE_MEMCHR=1
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
20 fi
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
21
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
22 if test $ac_cv_func_memchr = yes; then
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
23 # Detect platform-specific bugs in some versions of glibc:
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
24 # memchr should not dereference anything with length 0
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
25 # http://bugzilla.redhat.com/499689
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
26 # memchr should not dereference overestimated length after a match
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
27 # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=521737
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
28 # http://sourceware.org/bugzilla/show_bug.cgi?id=10162
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
29 # Assume that memchr works on platforms that lack mprotect.
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
30 AC_CACHE_CHECK([whether memchr works], [gl_cv_func_memchr_works],
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
31 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
32 #include <string.h>
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
33 #if HAVE_SYS_MMAN_H
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
34 # include <fcntl.h>
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
35 # include <unistd.h>
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
36 # include <sys/types.h>
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
37 # include <sys/mman.h>
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
38 # ifndef MAP_FILE
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
39 # define MAP_FILE 0
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
40 # endif
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
41 #endif
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
42 ]], [[
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
43 char *fence = NULL;
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
44 #if HAVE_SYS_MMAN_H && HAVE_MPROTECT
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
45 # if HAVE_MAP_ANONYMOUS
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
46 const int flags = MAP_ANONYMOUS | MAP_PRIVATE;
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
47 const int fd = -1;
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
48 # else /* !HAVE_MAP_ANONYMOUS */
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
49 const int flags = MAP_FILE | MAP_PRIVATE;
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
50 int fd = open ("/dev/zero", O_RDONLY, 0666);
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
51 if (fd >= 0)
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
52 # endif
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
53 {
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
54 int pagesize = getpagesize ();
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
55 char *two_pages =
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
56 (char *) mmap (NULL, 2 * pagesize, PROT_READ | PROT_WRITE,
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
57 flags, fd, 0);
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
58 if (two_pages != (char *)(-1)
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
59 && mprotect (two_pages + pagesize, pagesize, PROT_NONE) == 0)
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
60 fence = two_pages + pagesize;
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
61 }
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
62 #endif
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
63 if (fence)
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
64 {
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
65 if (memchr (fence, 0, 0))
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
66 return 1;
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
67 strcpy (fence - 9, "12345678");
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
68 if (memchr (fence - 9, 0, 79) != fence - 1)
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
69 return 2;
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
70 }
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
71 return 0;
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
72 ]])], [gl_cv_func_memchr_works=yes], [gl_cv_func_memchr_works=no],
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
73 [dnl Be pessimistic for now.
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
74 gl_cv_func_memchr_works="guessing no"])])
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
75 if test "$gl_cv_func_memchr_works" != yes; then
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
76 gl_PREREQ_MEMCHR
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
77 REPLACE_MEMCHR=1
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
78 AC_LIBOBJ([memchr])
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
79 fi
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
80 fi
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
81 ])
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
82
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
83 # Prerequisites of lib/memchr.c.
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
84 AC_DEFUN([gl_PREREQ_MEMCHR], [
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
85 AC_CHECK_HEADERS([bp-sym.h])
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
86 ])