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