]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/blob
56bcbb6ca12c3d5834ba9ed16393fc260139de8b
[thirdparty/openembedded/openembedded-core-contrib.git] /
1 From 028526149ee804617a302ccef22cc6adbda681b0 Mon Sep 17 00:00:00 2001
2 From: Paul Eggert <eggert@cs.ucla.edu>
3 Date: Wed, 10 May 2023 17:20:49 -0700
4 Subject: [PATCH 21/29] Port AC_FUNC_MMAP to more-modern systems
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 * lib/autoconf/functions.m4 (AC_FUNC_MMAP): Don’t call
10 getpagesize, as it’s tricky to configure, modern POSIX doesn’t
11 require it, and calling it without including <unistd.h> provokes a
12 compile-time error on modern systems. Instead, rework the test
13 to not need getpagesize. Add a FIXME comment for unnecessary
14 tests; I don't want to remove them now as we're too close to
15 a release. Remove long-obsolete comment about GNU grep.
16
17 Upstream-Status: Backport
18 Signed-off-by: Khem Raj <raj.khem@gmail.com>
19 ---
20 lib/autoconf/functions.m4 | 44 +++++----------------------------------
21 1 file changed, 5 insertions(+), 39 deletions(-)
22
23 diff --git a/lib/autoconf/functions.m4 b/lib/autoconf/functions.m4
24 index 499e4c024..5a0f01856 100644
25 --- a/lib/autoconf/functions.m4
26 +++ b/lib/autoconf/functions.m4
27 @@ -1283,6 +1283,7 @@ AU_ALIAS([AM_FUNC_MKTIME], [AC_FUNC_MKTIME])
28 AN_FUNCTION([mmap], [AC_FUNC_MMAP])
29 AC_DEFUN([AC_FUNC_MMAP],
30 [AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles
31 +dnl FIXME: Remove the unnecessary checks for unistd.h, sys/param.h, getpagesize.
32 AC_CHECK_HEADERS_ONCE([unistd.h sys/param.h])
33 AC_CHECK_FUNCS_ONCE([getpagesize])
34 AC_CACHE_CHECK([for working mmap], [ac_cv_func_mmap_fixed_mapped],
35 @@ -1305,48 +1306,11 @@ AC_CACHE_CHECK([for working mmap], [ac_cv_func_mmap_fixed_mapped],
36 VM page cache was not coherent with the file system buffer cache
37 like early versions of FreeBSD and possibly contemporary NetBSD.)
38 For shared mappings, we should conversely verify that changes get
39 - propagated back to all the places they're supposed to be.
40 -
41 - Grep wants private fixed already mapped.
42 - The main things grep needs to know about mmap are:
43 - * does it exist and is it safe to write into the mmap'd area
44 - * how to use it (BSD variants) */
45 + propagated back to all the places they're supposed to be. */
46
47 #include <fcntl.h>
48 #include <sys/mman.h>
49
50 -/* This mess was copied from the GNU getpagesize.h. */
51 -#ifndef HAVE_GETPAGESIZE
52 -# ifdef _SC_PAGESIZE
53 -# define getpagesize() sysconf(_SC_PAGESIZE)
54 -# else /* no _SC_PAGESIZE */
55 -# ifdef HAVE_SYS_PARAM_H
56 -# include <sys/param.h>
57 -# ifdef EXEC_PAGESIZE
58 -# define getpagesize() EXEC_PAGESIZE
59 -# else /* no EXEC_PAGESIZE */
60 -# ifdef NBPG
61 -# define getpagesize() NBPG * CLSIZE
62 -# ifndef CLSIZE
63 -# define CLSIZE 1
64 -# endif /* no CLSIZE */
65 -# else /* no NBPG */
66 -# ifdef NBPC
67 -# define getpagesize() NBPC
68 -# else /* no NBPC */
69 -# ifdef PAGESIZE
70 -# define getpagesize() PAGESIZE
71 -# endif /* PAGESIZE */
72 -# endif /* no NBPC */
73 -# endif /* no NBPG */
74 -# endif /* no EXEC_PAGESIZE */
75 -# else /* no HAVE_SYS_PARAM_H */
76 -# define getpagesize() 8192 /* punt totally */
77 -# endif /* no HAVE_SYS_PARAM_H */
78 -# endif /* no _SC_PAGESIZE */
79 -
80 -#endif /* no HAVE_GETPAGESIZE */
81 -
82 int
83 main (void)
84 {
85 @@ -1355,7 +1319,9 @@ main (void)
86 int i, pagesize;
87 int fd, fd2;
88
89 - pagesize = getpagesize ();
90 + /* The "page size" need not equal the system page size,
91 + and need not even be a power of 2. */
92 + pagesize = 8192;
93
94 /* First, make a file with some known garbage in it. */
95 data = (char *) malloc (pagesize);
96 --
97 2.41.0
98