This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Fix return value of use_address in host-darwin.c
- From: Ian Lance Taylor <ian at wasabisystems dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: 7 Apr 2004 19:33:14 -0400
- Subject: Fix return value of use_address in host-darwin.c
This has been bugging me for a little while now.
Currently darwin_rs6000_gt_pch_use_address in host-darwin.c returns 0
if it successfully maps the PCH into memory. That will cause the
caller to call fread to read the PCH. That will work, but is useless
extra work. The function should really return 1 in that case. It
should return 0 if the file could not be mapped, in which case we
really do want the caller to read the file into memory, although the
case is quite unlikely.
I think this patch should be applied. However, as I do not have a
Darwin system, I can not test it. Could somebody with a Darwin system
please test this patch? You can easily test it by running
make RUNTESTFLAGS=pch.exp check-gcc
in the gcc build subdirectory.
If it works, get it approved, and commit it.
Thanks.
Ian
2004-04-07 Ian Lance Taylor <ian@wasabisystems.com>
* config/rs6000/host-darwin.c (darwin_rs6000_gt_pch_use_address):
Return 1 if file was successfully mapped.
Index: config/rs6000/host-darwin.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/host-darwin.c,v
retrieving revision 1.11
diff -p -u -r1.11 host-darwin.c
--- config/rs6000/host-darwin.c 15 Mar 2004 22:47:57 -0000 1.11
+++ config/rs6000/host-darwin.c 7 Apr 2004 23:29:15 -0000
@@ -187,10 +187,10 @@ darwin_rs6000_gt_pch_use_address (void *
fd, off);
/* The file might not be mmap-able. */
- ret = mmap_result == (void *) MAP_FAILED;
+ ret = mmap_result != (void *) MAP_FAILED;
/* Sanity check for broken MAP_FIXED. */
- if (!ret && mmap_result != addr)
+ if (ret && mmap_result != addr)
abort ();
}