* configure.ac: Check for sys/mman.h and mmap. Check for mremap

with MREMAP_MAYMOVE.
	* output.h (class Output_file): Add map_is_allocated_ field.
	* output.cc: Only #include <sys/mman.h> if it exists.  If mmap is
	not available, provide stubs.  If mremap is not available, #define
	it to gold_mremap.
	(MREMAP_MAYMOVE): Define if not defined.
	(Output_file::Output_file): Initialize map_is_allocated_.
	(Output_file::resize): Check map_is_allocated_.
	(Output_file::map_anonymous): If mmap fails, use malloc.
	(Output_file::unmap): Don't do anything for an anonymous map.
	* fileread.cc: Only #include <sys/mman.h> if it exists.  If mmap
	is not available, provide stubs.
	(File_read::View::~View): Use free rather than delete[].
	(File_read::make_view): Use malloc rather than new[].  If mmap
	fails, use malloc.
	(File_read::find_or_make_view): Use malloc rather than new[].
	* gold.h: Remove HAVE_REMAP code.
	* mremap.c: #include <errno.h>.  Only #include <sys/mman.h> if it
	exists.  Rename mremap to gold_mremap.  If mmap is not available
	don't do anything.
	* configure, config.in: Rebuild.
This commit is contained in:
Ian Lance Taylor
2011-04-12 18:06:16 +00:00
parent 32a946987b
commit 88597d3422
9 changed files with 317 additions and 54 deletions

67
gold/configure vendored
View File

@@ -6486,18 +6486,32 @@ WARN_CXXFLAGS=`echo ${WARN_CFLAGS} | sed -e 's/-Wstrict-prototypes//' -e 's/-Wmi
LFS_CFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
for ac_func in chsize
for ac_header in sys/mman.h
do :
ac_fn_c_check_func "$LINENO" "chsize" "ac_cv_func_chsize"
if test "x$ac_cv_func_chsize" = x""yes; then :
ac_fn_c_check_header_mongrel "$LINENO" "sys/mman.h" "ac_cv_header_sys_mman_h" "$ac_includes_default"
if test "x$ac_cv_header_sys_mman_h" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_CHSIZE 1
#define HAVE_SYS_MMAN_H 1
_ACEOF
fi
done
for ac_func in chsize mmap
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
eval as_val=\$$as_ac_var
if test "x$as_val" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
fi
done
for ac_func in pread ftruncate mremap ffsll
for ac_func in pread ftruncate ffsll
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
@@ -6519,6 +6533,49 @@ done
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking mremap with MREMAP_MAYMOVE" >&5
$as_echo_n "checking mremap with MREMAP_MAYMOVE... " >&6; }
if test "${gold_cv_lib_mremap_maymove+set}" = set; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <sys/mman.h>
void f() { mremap (0, 0, 0, MREMAP_MAYMOVE); }
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
gold_cv_lib_mremap_maymove=yes
else
gold_cv_lib_mremap_maymove=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gold_cv_lib_mremap_maymove" >&5
$as_echo "$gold_cv_lib_mremap_maymove" >&6; }
if test "$gold_cv_lib_mremap_maymove" = "yes"; then
$as_echo "#define HAVE_MREMAP 1" >>confdefs.h
else
case " $LIBOBJS " in
*" mremap.$ac_objext "* ) ;;
*) LIBOBJS="$LIBOBJS mremap.$ac_objext"
;;
esac
fi
# Link in zlib if we can. This allows us to write compressed sections.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing zlibVersion" >&5
$as_echo_n "checking for library containing zlibVersion... " >&6; }