summaryrefslogtreecommitdiff
path: root/src/unexec.c
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1995-10-08 19:29:57 +0000
committerRichard M. Stallman <rms@gnu.org>1995-10-08 19:29:57 +0000
commit5a31e1d01c89b9c4d0487f341415e88341182c32 (patch)
treed9e6de95f1304dd1afe00911f374059099368898 /src/unexec.c
parenta96621c61ee69b401aa824e35d38348b949da615 (diff)
downloademacs-5a31e1d01c89b9c4d0487f341415e88341182c32.tar.gz
emacs-5a31e1d01c89b9c4d0487f341415e88341182c32.tar.bz2
emacs-5a31e1d01c89b9c4d0487f341415e88341182c32.zip
(write_segment): Write valid data in units of 1<<13,
but write zeros only a page at a time.
Diffstat (limited to 'src/unexec.c')
-rw-r--r--src/unexec.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/unexec.c b/src/unexec.c
index 3be336a9a77..8387fd044e9 100644
--- a/src/unexec.c
+++ b/src/unexec.c
@@ -1014,15 +1014,18 @@ write_segment (new, ptr, end)
register int i, nwrite, ret;
char buf[80];
extern int errno;
+ /* This is the normal amount to write at once.
+ It is the size of block that NFS uses. */
+ int writesize = 1 << 13;
int pagesize = getpagesize ();
- char *zeros = (char *) alloca (pagesize);
+ char zeros[1 << 13];
- bzero (zeros, pagesize);
+ bzero (zeros, sizeof (zeros));
for (i = 0; ptr < end;)
{
- /* distance to next multiple of pagesize. */
- nwrite = (((int) ptr + pagesize) & -pagesize) - (int) ptr;
+ /* Distance to next multiple of writesize. */
+ nwrite = (((int) ptr + writesize) & -writesize) - (int) ptr;
/* But not beyond specified end. */
if (nwrite > end - ptr) nwrite = end - ptr;
ret = write (new, ptr, nwrite);
@@ -1035,7 +1038,16 @@ write_segment (new, ptr, end)
&& errno == EFAULT
#endif
)
- write (new, zeros, nwrite);
+ {
+ /* Write only a page of zeros at once,
+ so that we we don't overshoot the start
+ of the valid memory in the old data segment. */
+ if (nwrite > pagesize)
+ nwrite = pagesize;
+ write (new, zeros, nwrite);
+ }
+#if 0 /* Now that we have can ask `write' to write more than a page,
+ it is legit for write do less than the whole amount specified. */
else if (nwrite != ret)
{
sprintf (buf,
@@ -1043,6 +1055,7 @@ write_segment (new, ptr, end)
ptr, new, nwrite, ret, errno);
PERROR (buf);
}
+#endif
i += nwrite;
ptr += nwrite;
}