Commit | Line | Data |
---|---|---|
8e82f0c2 | 1 | dnl The following are from prerelease autoconf 2.14a. When 2.14 is |
4487f86d | 2 | dnl released, we should be able to zap them and just use AC_PREREQ(2.14). |
8e82f0c2 | 3 | |
b15a393b GM |
4 | % Copyright (C) 2000, 2001 Free Software Foundation, Inc. |
5 | % | |
6 | % This file is part of GNU Emacs. | |
7 | % | |
8 | % GNU Emacs is free software; you can redistribute it and/or modify | |
9 | % it under the terms of the GNU General Public License as published by | |
10 | % the Free Software Foundation; either version 2, or (at your option) | |
11 | % any later version. | |
12 | % | |
13 | % GNU Emacs is distributed in the hope that it will be useful, | |
14 | % but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | % GNU General Public License for more details. | |
17 | % | |
18 | % You should have received a copy of the GNU General Public License | |
19 | % along with GNU Emacs; see the file COPYING. If not, write to the | |
20 | % Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
21 | % Boston, MA 02111-1307, USA. | |
22 | ||
6a465756 | 23 | ifelse(_AC_VERSION_COMPARE(AC_ACVERSION, [2.14]), -1, |
8e82f0c2 DL |
24 | |
25 | # AC_PROG_CC_STDC | |
26 | # --------------- | |
27 | # If the C compiler in not in ANSI C mode by default, try to add an | |
28 | # option to output variable @code{CC} to make it so. This macro tries | |
29 | # various options that select ANSI C on some system or another. It | |
30 | # considers the compiler to be in ANSI C mode if it handles function | |
31 | # prototypes correctly. | |
32 | AC_DEFUN(AC_PROG_CC_STDC, | |
33 | [AC_REQUIRE([AC_PROG_CC])dnl | |
34 | AC_BEFORE([$0], [AC_C_INLINE])dnl | |
35 | AC_BEFORE([$0], [AC_C_CONST])dnl | |
36 | dnl Force this before AC_PROG_CPP. Some cpp's, eg on HPUX, require | |
37 | dnl a magic option to avoid problems with ANSI preprocessor commands | |
38 | dnl like #elif. | |
39 | dnl FIXME: can't do this because then AC_AIX won't work due to a | |
40 | dnl circular dependency. | |
41 | dnl AC_BEFORE([$0], [AC_PROG_CPP]) | |
42 | AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C) | |
43 | AC_CACHE_VAL(ac_cv_prog_cc_stdc, | |
44 | [ac_cv_prog_cc_stdc=no | |
45 | ac_save_CC="$CC" | |
46 | # Don't try gcc -ansi; that turns off useful extensions and | |
47 | # breaks some systems' header files. | |
48 | # AIX -qlanglvl=ansi | |
49 | # Ultrix and OSF/1 -std1 | |
50 | # HP-UX 10.20 and later -Ae | |
51 | # HP-UX older versions -Aa -D_HPUX_SOURCE | |
52 | # SVR4 -Xc -D__EXTENSIONS__ | |
53 | for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" | |
54 | do | |
55 | CC="$ac_save_CC $ac_arg" | |
56 | AC_TRY_COMPILE( | |
57 | [#include <stdarg.h> | |
58 | #include <stdio.h> | |
59 | #include <sys/types.h> | |
60 | #include <sys/stat.h> | |
61 | /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ | |
62 | struct buf { int x; }; | |
63 | FILE * (*rcsopen) (struct buf *, struct stat *, int); | |
64 | static char *e (p, i) | |
65 | char **p; | |
66 | int i; | |
67 | { | |
68 | return p[i]; | |
69 | } | |
70 | static char *f (char * (*g) (char **, int), char **p, ...) | |
71 | { | |
72 | char *s; | |
73 | va_list v; | |
74 | va_start (v,p); | |
75 | s = g (p, va_arg (v,int)); | |
76 | va_end (v); | |
77 | return s; | |
78 | } | |
79 | int test (int i, double x); | |
80 | struct s1 {int (*f) (int a);}; | |
81 | struct s2 {int (*f) (double a);}; | |
82 | int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); | |
83 | int argc; | |
84 | char **argv;], | |
85 | [return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];], | |
86 | [ac_cv_prog_cc_stdc="$ac_arg"; break]) | |
87 | done | |
88 | CC="$ac_save_CC" | |
89 | ]) | |
90 | case "x$ac_cv_prog_cc_stdc" in | |
91 | x|xno) | |
92 | AC_MSG_RESULT([none needed]) ;; | |
93 | *) | |
94 | AC_MSG_RESULT($ac_cv_prog_cc_stdc) | |
95 | CC="$CC $ac_cv_prog_cc_stdc" ;; | |
96 | esac | |
97 | ])# AC_PROG_CC_STDC | |
98 | ||
4487f86d DL |
99 | # AC_FUNC_MKTIME |
100 | # -------------- | |
101 | AC_DEFUN(AC_FUNC_MKTIME, | |
102 | [AC_REQUIRE([AC_HEADER_TIME])dnl | |
103 | AC_CHECK_HEADERS(sys/time.h unistd.h) | |
104 | AC_CHECK_FUNCS(alarm) | |
105 | AC_CACHE_CHECK([for working mktime], ac_cv_func_working_mktime, | |
106 | [AC_TRY_RUN( | |
107 | [/* Test program from Paul Eggert (eggert@twinsun.com) | |
108 | and Tony Leneis (tony@plaza.ds.adp.com). */ | |
109 | #if TIME_WITH_SYS_TIME | |
110 | # include <sys/time.h> | |
111 | # include <time.h> | |
112 | #else | |
113 | # if HAVE_SYS_TIME_H | |
114 | # include <sys/time.h> | |
115 | # else | |
116 | # include <time.h> | |
117 | # endif | |
118 | #endif | |
119 | ||
120 | #if HAVE_UNISTD_H | |
121 | # include <unistd.h> | |
122 | #endif | |
123 | ||
124 | #if !HAVE_ALARM | |
125 | # define alarm(X) /* empty */ | |
126 | #endif | |
127 | ||
128 | /* Work around redefinition to rpl_putenv by other config tests. */ | |
129 | #undef putenv | |
130 | ||
131 | static time_t time_t_max; | |
132 | ||
133 | /* Values we'll use to set the TZ environment variable. */ | |
134 | static const char *const tz_strings[] = { | |
135 | (const char *) 0, "TZ=GMT0", "TZ=JST-9", | |
136 | "TZ=EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00" | |
137 | }; | |
138 | #define N_STRINGS (sizeof (tz_strings) / sizeof (tz_strings[0])) | |
139 | ||
140 | /* Fail if mktime fails to convert a date in the spring-forward gap. | |
141 | Based on a problem report from Andreas Jaeger. */ | |
142 | static void | |
143 | spring_forward_gap () | |
144 | { | |
145 | /* glibc (up to about 1998-10-07) failed this test) */ | |
146 | struct tm tm; | |
147 | ||
148 | /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0" | |
149 | instead of "TZ=America/Vancouver" in order to detect the bug even | |
150 | on systems that don't support the Olson extension, or don't have the | |
151 | full zoneinfo tables installed. */ | |
152 | putenv ("TZ=PST8PDT,M4.1.0,M10.5.0"); | |
153 | ||
154 | tm.tm_year = 98; | |
155 | tm.tm_mon = 3; | |
156 | tm.tm_mday = 5; | |
157 | tm.tm_hour = 2; | |
158 | tm.tm_min = 0; | |
159 | tm.tm_sec = 0; | |
160 | tm.tm_isdst = -1; | |
161 | if (mktime (&tm) == (time_t)-1) | |
162 | exit (1); | |
163 | } | |
164 | ||
165 | static void | |
166 | mktime_test (now) | |
167 | time_t now; | |
168 | { | |
169 | struct tm *lt; | |
170 | if ((lt = localtime (&now)) && mktime (lt) != now) | |
171 | exit (1); | |
172 | now = time_t_max - now; | |
173 | if ((lt = localtime (&now)) && mktime (lt) != now) | |
174 | exit (1); | |
175 | } | |
176 | ||
177 | static void | |
178 | irix_6_4_bug () | |
179 | { | |
180 | /* Based on code from Ariel Faigon. */ | |
181 | struct tm tm; | |
182 | tm.tm_year = 96; | |
183 | tm.tm_mon = 3; | |
184 | tm.tm_mday = 0; | |
185 | tm.tm_hour = 0; | |
186 | tm.tm_min = 0; | |
187 | tm.tm_sec = 0; | |
188 | tm.tm_isdst = -1; | |
189 | mktime (&tm); | |
190 | if (tm.tm_mon != 2 || tm.tm_mday != 31) | |
191 | exit (1); | |
192 | } | |
193 | ||
194 | static void | |
195 | bigtime_test (j) | |
196 | int j; | |
197 | { | |
198 | struct tm tm; | |
199 | time_t now; | |
200 | tm.tm_year = tm.tm_mon = tm.tm_mday = tm.tm_hour = tm.tm_min = tm.tm_sec = j; | |
201 | now = mktime (&tm); | |
202 | if (now != (time_t) -1) | |
203 | { | |
204 | struct tm *lt = localtime (&now); | |
205 | if (! (lt | |
206 | && lt->tm_year == tm.tm_year | |
207 | && lt->tm_mon == tm.tm_mon | |
208 | && lt->tm_mday == tm.tm_mday | |
209 | && lt->tm_hour == tm.tm_hour | |
210 | && lt->tm_min == tm.tm_min | |
211 | && lt->tm_sec == tm.tm_sec | |
212 | && lt->tm_yday == tm.tm_yday | |
213 | && lt->tm_wday == tm.tm_wday | |
214 | && ((lt->tm_isdst < 0 ? -1 : 0 < lt->tm_isdst) | |
215 | == (tm.tm_isdst < 0 ? -1 : 0 < tm.tm_isdst)))) | |
216 | exit (1); | |
217 | } | |
218 | } | |
219 | ||
220 | int | |
221 | main () | |
222 | { | |
223 | time_t t, delta; | |
224 | int i, j; | |
225 | ||
226 | /* This test makes some buggy mktime implementations loop. | |
227 | Give up after 60 seconds; a mktime slower than that | |
228 | isn't worth using anyway. */ | |
229 | alarm (60); | |
230 | ||
231 | for (time_t_max = 1; 0 < time_t_max; time_t_max *= 2) | |
232 | continue; | |
233 | time_t_max--; | |
234 | delta = time_t_max / 997; /* a suitable prime number */ | |
235 | for (i = 0; i < N_STRINGS; i++) | |
236 | { | |
237 | if (tz_strings[i]) | |
238 | putenv (tz_strings[i]); | |
239 | ||
240 | for (t = 0; t <= time_t_max - delta; t += delta) | |
241 | mktime_test (t); | |
242 | mktime_test ((time_t) 60 * 60); | |
243 | mktime_test ((time_t) 60 * 60 * 24); | |
244 | ||
245 | for (j = 1; 0 < j; j *= 2) | |
246 | bigtime_test (j); | |
247 | bigtime_test (j - 1); | |
248 | } | |
249 | irix_6_4_bug (); | |
250 | spring_forward_gap (); | |
251 | exit (0); | |
252 | }], | |
253 | ac_cv_func_working_mktime=yes, ac_cv_func_working_mktime=no, | |
254 | ac_cv_func_working_mktime=no)]) | |
255 | if test $ac_cv_func_working_mktime = no; then | |
256 | LIBOBJS="$LIBOBJS mktime.${ac_objext}" | |
257 | fi | |
0b8f263e | 258 | AC_SUBST(LIBOBJS)dnl |
4487f86d DL |
259 | ])# AC_FUNC_MKTIME |
260 | ||
8e82f0c2 DL |
261 | # AC_C_VOLATILE |
262 | # ------------- | |
263 | # Note that, unlike const, #defining volatile to be the empty string can | |
264 | # actually turn a correct program into an incorrect one, since removing | |
265 | # uses of volatile actually grants the compiler permission to perform | |
266 | # optimizations that could break the user's code. So, do not #define | |
267 | # volatile away unless it is really necessary to allow the user's code | |
268 | # to compile cleanly. Benign compiler failures should be tolerated. | |
269 | AC_DEFUN(AC_C_VOLATILE, | |
270 | [AC_REQUIRE([AC_PROG_CC_STDC])dnl | |
271 | AC_CACHE_CHECK([for working volatile], ac_cv_c_volatile, | |
272 | [AC_TRY_COMPILE(,[ | |
273 | volatile int x; | |
274 | int * volatile y;], | |
275 | ac_cv_c_volatile=yes, ac_cv_c_volatile=no)]) | |
276 | if test $ac_cv_c_volatile = no; then | |
277 | AC_DEFINE(volatile,, | |
278 | [Define to empty if the keyword `volatile' does not work. | |
279 | Warning: valid code using `volatile' can become incorrect | |
280 | without. Disable with care.]) | |
281 | fi | |
282 | ]) | |
283 | ||
284 | # AC_C_PROTOTYPES | |
285 | # --------------- | |
286 | # Check if the C compiler supports prototypes, included if it needs | |
287 | # options. | |
288 | AC_DEFUN(AC_C_PROTOTYPES, | |
289 | [AC_REQUIRE([AC_PROG_CC_STDC])dnl | |
290 | AC_REQUIRE([AC_PROG_CPP])dnl | |
291 | AC_MSG_CHECKING([for function prototypes]) | |
292 | if test "$ac_cv_prog_cc_stdc" != no; then | |
293 | AC_MSG_RESULT(yes) | |
294 | AC_DEFINE(PROTOTYPES, 1, | |
295 | [Define if the compiler supports function prototypes.]) | |
296 | else | |
297 | AC_MSG_RESULT(no) | |
298 | fi | |
299 | ])# AC_C_PROTOTYPES | |
7101aecf | 300 | |
6a465756 DL |
301 | dnl The following is a bit different from the prerelease autoconf at |
302 | dnl this time since that requires extra definitions. | |
edcc1067 | 303 | |
7101aecf DL |
304 | dnl By default, many hosts won't let programs access large files; |
305 | dnl one must use special compiler options to get large-file access to work. | |
306 | dnl For more details about this brain damage please see: | |
307 | dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html | |
308 | ||
309 | dnl Written by Paul Eggert <eggert@twinsun.com>. | |
310 | ||
311 | dnl Internal subroutine of AC_SYS_LARGEFILE. | |
312 | dnl AC_SYS_LARGEFILE_TEST_INCLUDES | |
313 | AC_DEFUN(AC_SYS_LARGEFILE_TEST_INCLUDES, | |
314 | [[#include <sys/types.h> | |
315 | int a[(off_t) 9223372036854775807 == 9223372036854775807 ? 1 : -1]; | |
316 | ]]) | |
317 | ||
318 | dnl Internal subroutine of AC_SYS_LARGEFILE. | |
319 | dnl AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, CACHE-VAR, COMMENT, INCLUDES, FUNCTION-BODY) | |
320 | AC_DEFUN(AC_SYS_LARGEFILE_MACRO_VALUE, | |
321 | [AC_CACHE_CHECK([for $1 value needed for large files], $3, | |
322 | [$3=no | |
00d04b72 | 323 | AC_TRY_COMPILE([$5], |
7101aecf DL |
324 | [$6], |
325 | , | |
326 | [AC_TRY_COMPILE([#define $1 $2] | |
00d04b72 | 327 | [$5] |
7101aecf DL |
328 | , |
329 | [$6], | |
330 | [$3=$2])])]) | |
331 | if test "[$]$3" != no; then | |
332 | AC_DEFINE_UNQUOTED([$1], [$]$3, [$4]) | |
333 | fi]) | |
334 | ||
335 | AC_DEFUN(AC_SYS_LARGEFILE, | |
00d04b72 GM |
336 | [AC_REQUIRE([AC_PROG_CC]) |
337 | AC_ARG_ENABLE(largefile, | |
7101aecf DL |
338 | [ --disable-largefile omit support for large files]) |
339 | if test "$enable_largefile" != no; then | |
340 | ||
341 | AC_CACHE_CHECK([for special C compiler options needed for large files], | |
342 | ac_cv_sys_largefile_CC, | |
343 | [ac_cv_sys_largefile_CC=no | |
344 | if test "$GCC" != yes; then | |
345 | # IRIX 6.2 and later do not support large files by default, | |
346 | # so use the C compiler's -n32 option if that helps. | |
347 | AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES, , , | |
348 | [ac_save_CC="$CC" | |
349 | CC="$CC -n32" | |
350 | AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES, , | |
351 | ac_cv_sys_largefile_CC=' -n32') | |
352 | CC="$ac_save_CC"]) | |
353 | fi]) | |
354 | if test "$ac_cv_sys_largefile_CC" != no; then | |
355 | CC="$CC$ac_cv_sys_largefile_CC" | |
356 | fi | |
357 | ||
358 | AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64, | |
359 | ac_cv_sys_file_offset_bits, | |
00d04b72 GM |
360 | [Number of bits in a file offset, on hosts where this is settable.], |
361 | AC_SYS_LARGEFILE_TEST_INCLUDES) | |
7101aecf DL |
362 | AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1, |
363 | ac_cv_sys_large_files, | |
00d04b72 GM |
364 | [Define for large files, on AIX-style hosts.] |
365 | AC_SYS_LARGEFILE_TEST_INCLUDES) | |
7101aecf DL |
366 | fi |
367 | ]) | |
6a465756 | 368 | |
00d04b72 GM |
369 | AC_DEFUN(AC_FUNC_FSEEKO, |
370 | [AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE, 1, | |
371 | ac_cv_sys_largefile_source, | |
372 | [Define to make fseeko visible on some hosts (e.g. glibc 2.2).], | |
373 | [#include <stdio.h>], [return !fseeko;]) | |
374 | # We used to try defining _XOPEN_SOURCE=500 too, to work around a bug | |
375 | # in glibc 2.1.3, but that breaks too many other things. | |
376 | # If you want fseeko and ftello with glibc, upgrade to a fixed glibc. | |
377 | ||
378 | AC_CACHE_CHECK([for fseeko], ac_cv_func_fseeko, | |
379 | [ac_cv_func_fseeko=no | |
380 | AC_TRY_LINK([#include <stdio.h>], | |
381 | [return fseeko && fseeko (stdin, 0, 0);], | |
382 | [ac_cv_func_fseeko=yes])]) | |
383 | if test $ac_cv_func_fseeko != no; then | |
384 | AC_DEFINE(HAVE_FSEEKO, 1, | |
385 | [Define if fseeko (and presumably ftello) exists and is declared.]) | |
386 | fi]) | |
387 | ||
8b05edb3 DL |
388 | undefine([AC_FUNC_MMAP])dnl |
389 | dnl The autoconf 2.13 version loses on OSF, at least, | |
390 | dnl by messing up the declaration of malloc. | |
391 | AC_DEFUN([AC_FUNC_MMAP], | |
392 | [AC_CHECK_HEADERS(stdlib.h unistd.h sys/stat.h) | |
393 | AC_CHECK_FUNCS(getpagesize) | |
394 | AC_CACHE_CHECK(for working mmap, ac_cv_func_mmap_fixed_mapped, | |
395 | [AC_TRY_RUN( | |
396 | [/* Thanks to Mike Haertel and Jim Avera for this test. | |
397 | Here is a matrix of mmap possibilities: | |
398 | mmap private not fixed | |
399 | mmap private fixed at somewhere currently unmapped | |
400 | mmap private fixed at somewhere already mapped | |
401 | mmap shared not fixed | |
402 | mmap shared fixed at somewhere currently unmapped | |
403 | mmap shared fixed at somewhere already mapped | |
404 | For private mappings, we should verify that changes cannot be read() | |
405 | back from the file, nor mmap's back from the file at a different | |
406 | address. (There have been systems where private was not correctly | |
407 | implemented like the infamous i386 svr4.0, and systems where the | |
408 | VM page cache was not coherent with the file system buffer cache | |
409 | like early versions of FreeBSD and possibly contemporary NetBSD.) | |
410 | For shared mappings, we should conversely verify that changes get | |
411 | propogated back to all the places they're supposed to be. | |
412 | ||
413 | Grep wants private fixed already mapped. | |
414 | The main things grep needs to know about mmap are: | |
415 | * does it exist and is it safe to write into the mmap'd area | |
416 | * how to use it (BSD variants) */ | |
417 | #include <sys/types.h> | |
418 | #include <fcntl.h> | |
419 | #include <sys/mman.h> | |
420 | ||
421 | #if STDC_HEADERS || HAVE_STDLIB_H | |
422 | # include <stdlib.h> | |
423 | #else | |
424 | char *malloc (); | |
425 | #endif | |
426 | #if HAVE_UNISTD_H | |
427 | # include <unistd.h> | |
428 | #endif | |
429 | #if HAVE_SYS_STAT_H | |
430 | # include <sys/stat.h> | |
431 | #endif | |
432 | ||
433 | /* This mess was copied from the GNU getpagesize.h. */ | |
434 | #if !HAVE_GETPAGESIZE | |
435 | /* Assume that all systems that can run configure have sys/param.h. */ | |
436 | # if !HAVE_SYS_PARAM_H | |
437 | # define HAVE_SYS_PARAM_H 1 | |
438 | # endif | |
439 | ||
440 | # ifdef _SC_PAGESIZE | |
441 | # define getpagesize() sysconf(_SC_PAGESIZE) | |
442 | # else /* no _SC_PAGESIZE */ | |
443 | # if HAVE_SYS_PARAM_H | |
444 | # include <sys/param.h> | |
445 | # ifdef EXEC_PAGESIZE | |
446 | # define getpagesize() EXEC_PAGESIZE | |
447 | # else /* no EXEC_PAGESIZE */ | |
448 | # ifdef NBPG | |
449 | # define getpagesize() NBPG * CLSIZE | |
450 | # ifndef CLSIZE | |
451 | # define CLSIZE 1 | |
452 | # endif /* no CLSIZE */ | |
453 | # else /* no NBPG */ | |
454 | # ifdef NBPC | |
455 | # define getpagesize() NBPC | |
456 | # else /* no NBPC */ | |
457 | # ifdef PAGESIZE | |
458 | # define getpagesize() PAGESIZE | |
459 | # endif /* PAGESIZE */ | |
460 | # endif /* no NBPC */ | |
461 | # endif /* no NBPG */ | |
462 | # endif /* no EXEC_PAGESIZE */ | |
463 | # else /* no HAVE_SYS_PARAM_H */ | |
464 | # define getpagesize() 8192 /* punt totally */ | |
465 | # endif /* no HAVE_SYS_PARAM_H */ | |
466 | # endif /* no _SC_PAGESIZE */ | |
467 | ||
468 | #endif /* no HAVE_GETPAGESIZE */ | |
469 | ||
470 | int | |
471 | main () | |
472 | { | |
473 | char *data, *data2, *data3; | |
474 | int i, pagesize; | |
475 | int fd; | |
476 | ||
477 | pagesize = getpagesize (); | |
478 | ||
479 | /* First, make a file with some known garbage in it. */ | |
480 | data = (char *) malloc (pagesize); | |
481 | if (!data) | |
482 | exit (1); | |
483 | for (i = 0; i < pagesize; ++i) | |
484 | *(data + i) = rand (); | |
485 | umask (0); | |
486 | fd = creat ("conftestmmap", 0600); | |
487 | if (fd < 0) | |
488 | exit (1); | |
489 | if (write (fd, data, pagesize) != pagesize) | |
490 | exit (1); | |
491 | close (fd); | |
492 | ||
493 | /* Next, try to mmap the file at a fixed address which already has | |
494 | something else allocated at it. If we can, also make sure that | |
495 | we see the same garbage. */ | |
496 | fd = open ("conftestmmap", O_RDWR); | |
497 | if (fd < 0) | |
498 | exit (1); | |
499 | data2 = (char *) malloc (2 * pagesize); | |
500 | if (!data2) | |
501 | exit (1); | |
502 | data2 += (pagesize - ((int) data2 & (pagesize - 1))) & (pagesize - 1); | |
503 | if (data2 != mmap (data2, pagesize, PROT_READ | PROT_WRITE, | |
504 | MAP_PRIVATE | MAP_FIXED, fd, 0L)) | |
505 | exit (1); | |
506 | for (i = 0; i < pagesize; ++i) | |
507 | if (*(data + i) != *(data2 + i)) | |
508 | exit (1); | |
509 | ||
510 | /* Finally, make sure that changes to the mapped area do not | |
511 | percolate back to the file as seen by read(). (This is a bug on | |
512 | some variants of i386 svr4.0.) */ | |
513 | for (i = 0; i < pagesize; ++i) | |
514 | *(data2 + i) = *(data2 + i) + 1; | |
515 | data3 = (char *) malloc (pagesize); | |
516 | if (!data3) | |
517 | exit (1); | |
518 | if (read (fd, data3, pagesize) != pagesize) | |
519 | exit (1); | |
520 | for (i = 0; i < pagesize; ++i) | |
521 | if (*(data + i) != *(data3 + i)) | |
522 | exit (1); | |
523 | close (fd); | |
524 | unlink ("conftestmmap"); | |
525 | exit (0); | |
526 | }], ac_cv_func_mmap_fixed_mapped=yes, ac_cv_func_mmap_fixed_mapped=no, | |
527 | ac_cv_func_mmap_fixed_mapped=no)]) | |
528 | if test $ac_cv_func_mmap_fixed_mapped = yes; then | |
529 | AC_DEFINE(HAVE_MMAP, 1, | |
530 | [Define if you have a working `mmap' system call.]) | |
531 | fi | |
532 | ])# AC_FUNC_MMAP | |
533 | ||
6a465756 | 534 | ) dnl ifelse |