diff options
author | John David Anglin <dave.anglin@nrc-cnrc.gc.ca> | 2004-12-14 22:48:53 +0000 |
---|---|---|
committer | John David Anglin <danglin@gcc.gnu.org> | 2004-12-14 22:48:53 +0000 |
commit | b3e30ec04348f3c87f13a33918971cc5cbb20860 (patch) | |
tree | fd05124d869bb15a8059922c0a71dcd3ee38bfb6 /gcc/config/pa | |
parent | 7cacf53e505b9143b7ae0e646dc83a4e5cf9f643 (diff) | |
download | gcc-b3e30ec04348f3c87f13a33918971cc5cbb20860.zip gcc-b3e30ec04348f3c87f13a33918971cc5cbb20860.tar.gz gcc-b3e30ec04348f3c87f13a33918971cc5cbb20860.tar.bz2 |
pa-host.c (MAP_FAILED): Define if not defined.
* pa-host.c (MAP_FAILED): Define if not defined.
(pa_gt_pch_use_address): Handle short reads.
From-SVN: r92166
Diffstat (limited to 'gcc/config/pa')
-rw-r--r-- | gcc/config/pa/pa-host.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/gcc/config/pa/pa-host.c b/gcc/config/pa/pa-host.c index fed18f9..0d86e58 100644 --- a/gcc/config/pa/pa-host.c +++ b/gcc/config/pa/pa-host.c @@ -26,6 +26,10 @@ #include "hosthooks.h" #include "hosthooks-def.h" +#ifndef MAP_FAILED +#define MAP_FAILED (void *)-1L +#endif + static void *pa_gt_pch_get_address (size_t, int); static int pa_gt_pch_use_address (void *, size_t, int, size_t); @@ -114,8 +118,16 @@ pa_gt_pch_use_address (void *base, size_t size, int fd, size_t offset) if (lseek (fd, offset, SEEK_SET) == (off_t)-1) return -1; - if (read (fd, base, size) == -1) - return -1; + while (size) + { + ssize_t nbytes; + + nbytes = read (fd, base, MIN (size, SSIZE_MAX)); + if (nbytes <= 0) + return -1; + base = (char *) base + nbytes; + size -= nbytes; + } return 1; } |