X-Git-Url: http://git.hcoop.net/bpt/emacs.git/blobdiff_plain/e61d39cddfd015032a6419ce75c36ecdf1e9fe9f..8ec49c53c67cfaee550f275c1a8b68d65b9b606f:/src/unexcoff.c
diff --git a/src/unexcoff.c b/src/unexcoff.c
index 966dd58cb6..5710ac0457 100644
--- a/src/unexcoff.c
+++ b/src/unexcoff.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 1985-1988, 1992-1994, 2001-2012 Free Software Foundation, Inc.
+/* Copyright (C) 1985-1988, 1992-1994, 2001-2014 Free Software
+ * Foundation, Inc.
This file is part of GNU Emacs.
@@ -51,6 +52,7 @@ along with GNU Emacs. If not, see . */
#include
#include "unexec.h"
+#include "lisp.h"
#define PERROR(file) report_error (file, new)
@@ -98,7 +100,7 @@ struct aouthdr
#include
-#include "mem-limits.h"
+extern int etext;
static long block_copy_start; /* Old executable start point */
static struct filehdr f_hdr; /* File header */
@@ -125,9 +127,10 @@ static int pagemask;
static void
report_error (const char *file, int fd)
{
+ int err = errno;
if (fd)
- close (fd);
- report_file_error ("Cannot unexec", Fcons (build_string (file), Qnil));
+ emacs_close (fd);
+ report_file_errno ("Cannot unexec", build_string (file), err);
}
#define ERROR0(msg) report_error_1 (new, msg, 0, 0); return -1
@@ -137,7 +140,7 @@ report_error (const char *file, int fd)
static void
report_error_1 (int fd, const char *msg, int a1, int a2)
{
- close (fd);
+ emacs_close (fd);
error (msg, a1, a2);
}
@@ -167,7 +170,7 @@ make_hdr (int new, int a_out,
pagemask = getpagesize () - 1;
/* Adjust text/data boundary. */
- data_start = (int) start_of_data ();
+ data_start = (int) DATA_START;
data_start = ADDR_CORRECT (data_start);
data_start = data_start & ~pagemask; /* (Down) to page boundary. */
@@ -332,11 +335,7 @@ write_segment (int new, const char *ptr, const char *end)
a gap between the old text segment and the old data segment.
This gap has probably been remapped into part of the text segment.
So write zeros for it. */
- if (ret == -1
-#ifdef EFAULT
- && errno == EFAULT
-#endif
- )
+ if (ret == -1 && errno == EFAULT)
{
/* Write only a page of zeros at once,
so that we don't overshoot the start
@@ -489,7 +488,7 @@ adjust_lnnoptrs (int writedesc, int readdesc, const char *new_name)
#ifdef MSDOS
if ((new = writedesc) < 0)
#else
- if ((new = open (new_name, O_RDWR)) < 0)
+ if ((new = emacs_open (new_name, O_RDWR, 0)) < 0)
#endif
{
PERROR (new_name);
@@ -513,7 +512,7 @@ adjust_lnnoptrs (int writedesc, int readdesc, const char *new_name)
}
}
#ifndef MSDOS
- close (new);
+ emacs_close (new);
#endif
return 0;
}
@@ -528,11 +527,11 @@ unexec (const char *new_name, const char *a_name)
{
int new = -1, a_out = -1;
- if (a_name && (a_out = open (a_name, O_RDONLY)) < 0)
+ if (a_name && (a_out = emacs_open (a_name, O_RDONLY, 0)) < 0)
{
PERROR (a_name);
}
- if ((new = creat (new_name, 0666)) < 0)
+ if ((new = emacs_open (new_name, O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0)
{
PERROR (new_name);
}
@@ -543,13 +542,13 @@ unexec (const char *new_name, const char *a_name)
|| adjust_lnnoptrs (new, a_out, new_name) < 0
)
{
- close (new);
+ emacs_close (new);
return;
}
- close (new);
+ emacs_close (new);
if (a_out >= 0)
- close (a_out);
+ emacs_close (a_out);
mark_x (new_name);
}