diff options
Diffstat (limited to 'gl/m4/memchr.m4')
-rw-r--r-- | gl/m4/memchr.m4 | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/gl/m4/memchr.m4 b/gl/m4/memchr.m4 index ab773b81..2d8abe75 100644 --- a/gl/m4/memchr.m4 +++ b/gl/m4/memchr.m4 | |||
@@ -1,5 +1,5 @@ | |||
1 | # memchr.m4 serial 8 | 1 | # memchr.m4 serial 12 |
2 | dnl Copyright (C) 2002-2004, 2009-2010 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2002-2004, 2009-2013 Free Software Foundation, Inc. |
3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
5 | dnl with or without modifications, as long as this notice is preserved. | 5 | dnl with or without modifications, as long as this notice is preserved. |
@@ -11,10 +11,16 @@ AC_DEFUN_ONCE([gl_FUNC_MEMCHR], | |||
11 | AC_CHECK_HEADERS_ONCE([sys/mman.h]) | 11 | AC_CHECK_HEADERS_ONCE([sys/mman.h]) |
12 | AC_CHECK_FUNCS_ONCE([mprotect]) | 12 | AC_CHECK_FUNCS_ONCE([mprotect]) |
13 | 13 | ||
14 | dnl These days, we assume memchr is present. But just in case... | ||
15 | AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) | 14 | AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) |
16 | AC_CHECK_FUNCS_ONCE([memchr]) | 15 | m4_ifdef([gl_FUNC_MEMCHR_OBSOLETE], [ |
17 | if test $ac_cv_func_memchr = yes; then | 16 | dnl These days, we assume memchr is present. But if support for old |
17 | dnl platforms is desired: | ||
18 | AC_CHECK_FUNCS_ONCE([memchr]) | ||
19 | if test $ac_cv_func_memchr = no; then | ||
20 | HAVE_MEMCHR=0 | ||
21 | fi | ||
22 | ]) | ||
23 | if test $HAVE_MEMCHR = 1; then | ||
18 | # Detect platform-specific bugs in some versions of glibc: | 24 | # Detect platform-specific bugs in some versions of glibc: |
19 | # memchr should not dereference anything with length 0 | 25 | # memchr should not dereference anything with length 0 |
20 | # http://bugzilla.redhat.com/499689 | 26 | # http://bugzilla.redhat.com/499689 |
@@ -35,6 +41,7 @@ AC_DEFUN_ONCE([gl_FUNC_MEMCHR], | |||
35 | # endif | 41 | # endif |
36 | #endif | 42 | #endif |
37 | ]], [[ | 43 | ]], [[ |
44 | int result = 0; | ||
38 | char *fence = NULL; | 45 | char *fence = NULL; |
39 | #if HAVE_SYS_MMAN_H && HAVE_MPROTECT | 46 | #if HAVE_SYS_MMAN_H && HAVE_MPROTECT |
40 | # if HAVE_MAP_ANONYMOUS | 47 | # if HAVE_MAP_ANONYMOUS |
@@ -58,24 +65,20 @@ AC_DEFUN_ONCE([gl_FUNC_MEMCHR], | |||
58 | if (fence) | 65 | if (fence) |
59 | { | 66 | { |
60 | if (memchr (fence, 0, 0)) | 67 | if (memchr (fence, 0, 0)) |
61 | return 1; | 68 | result |= 1; |
62 | strcpy (fence - 9, "12345678"); | 69 | strcpy (fence - 9, "12345678"); |
63 | if (memchr (fence - 9, 0, 79) != fence - 1) | 70 | if (memchr (fence - 9, 0, 79) != fence - 1) |
64 | return 2; | 71 | result |= 2; |
72 | if (memchr (fence - 1, 0, 3) != fence - 1) | ||
73 | result |= 4; | ||
65 | } | 74 | } |
66 | return 0; | 75 | return result; |
67 | ]])], [gl_cv_func_memchr_works=yes], [gl_cv_func_memchr_works=no], | 76 | ]])], [gl_cv_func_memchr_works=yes], [gl_cv_func_memchr_works=no], |
68 | [dnl Be pessimistic for now. | 77 | [dnl Be pessimistic for now. |
69 | gl_cv_func_memchr_works="guessing no"])]) | 78 | gl_cv_func_memchr_works="guessing no"])]) |
70 | if test "$gl_cv_func_memchr_works" != yes; then | 79 | if test "$gl_cv_func_memchr_works" != yes; then |
71 | REPLACE_MEMCHR=1 | 80 | REPLACE_MEMCHR=1 |
72 | fi | 81 | 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 | 82 | fi |
80 | ]) | 83 | ]) |
81 | 84 | ||