Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(336)

Side by Side Diff: gdb/gnulib/m4/memchr.m4

Issue 11969036: Merge GDB 7.5.1 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@master
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gdb/gnulib/m4/longlong.m4 ('k') | gdb/gnulib/m4/memmem.m4 » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # memchr.m4 serial 8
2 dnl Copyright (C) 2002-2004, 2009-2011 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
6
7 AC_DEFUN_ONCE([gl_FUNC_MEMCHR],
8 [
9 dnl Check for prerequisites for memory fence checks.
10 gl_FUNC_MMAP_ANON
11 AC_CHECK_HEADERS_ONCE([sys/mman.h])
12 AC_CHECK_FUNCS_ONCE([mprotect])
13
14 dnl These days, we assume memchr is present. But just in case...
15 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
16 AC_CHECK_FUNCS_ONCE([memchr])
17 if test $ac_cv_func_memchr = yes; then
18 # Detect platform-specific bugs in some versions of glibc:
19 # memchr should not dereference anything with length 0
20 # http://bugzilla.redhat.com/499689
21 # memchr should not dereference overestimated length after a match
22 # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=521737
23 # http://sourceware.org/bugzilla/show_bug.cgi?id=10162
24 # Assume that memchr works on platforms that lack mprotect.
25 AC_CACHE_CHECK([whether memchr works], [gl_cv_func_memchr_works],
26 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
27 #include <string.h>
28 #if HAVE_SYS_MMAN_H
29 # include <fcntl.h>
30 # include <unistd.h>
31 # include <sys/types.h>
32 # include <sys/mman.h>
33 # ifndef MAP_FILE
34 # define MAP_FILE 0
35 # endif
36 #endif
37 ]], [[
38 char *fence = NULL;
39 #if HAVE_SYS_MMAN_H && HAVE_MPROTECT
40 # if HAVE_MAP_ANONYMOUS
41 const int flags = MAP_ANONYMOUS | MAP_PRIVATE;
42 const int fd = -1;
43 # else /* !HAVE_MAP_ANONYMOUS */
44 const int flags = MAP_FILE | MAP_PRIVATE;
45 int fd = open ("/dev/zero", O_RDONLY, 0666);
46 if (fd >= 0)
47 # endif
48 {
49 int pagesize = getpagesize ();
50 char *two_pages =
51 (char *) mmap (NULL, 2 * pagesize, PROT_READ | PROT_WRITE,
52 flags, fd, 0);
53 if (two_pages != (char *)(-1)
54 && mprotect (two_pages + pagesize, pagesize, PROT_NONE) == 0)
55 fence = two_pages + pagesize;
56 }
57 #endif
58 if (fence)
59 {
60 if (memchr (fence, 0, 0))
61 return 1;
62 strcpy (fence - 9, "12345678");
63 if (memchr (fence - 9, 0, 79) != fence - 1)
64 return 2;
65 }
66 return 0;
67 ]])], [gl_cv_func_memchr_works=yes], [gl_cv_func_memchr_works=no],
68 [dnl Be pessimistic for now.
69 gl_cv_func_memchr_works="guessing no"])])
70 if test "$gl_cv_func_memchr_works" != yes; then
71 REPLACE_MEMCHR=1
72 fi
73 else
74 HAVE_MEMCHR=0
75 fi
76 if test $HAVE_MEMCHR = 0 || test $REPLACE_MEMCHR = 1; then
77 AC_LIBOBJ([memchr])
78 gl_PREREQ_MEMCHR
79 fi
80 ])
81
82 # Prerequisites of lib/memchr.c.
83 AC_DEFUN([gl_PREREQ_MEMCHR], [
84 AC_CHECK_HEADERS([bp-sym.h])
85 ])
OLDNEW
« no previous file with comments | « gdb/gnulib/m4/longlong.m4 ('k') | gdb/gnulib/m4/memmem.m4 » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698