annotate m4/memchr.m4 @ 443:a8934dfba400 3.0 3.0.1

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