Skip to content

Commit b8f0e99

Browse files
committed
Add a patch to fix build error on emacs 25.3
1 parent 36b0e2e commit b8f0e99

File tree

1 file changed

+108
-0
lines changed

1 file changed

+108
-0
lines changed

fix-emacs25.3-unexmacosx.c.patch

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
diff --git a/src/unexmacosx.c b/src/unexmacosx.c
2+
index 53a30e3627..59cbe3c18b 100644
3+
--- a/src/unexmacosx.c
4+
+++ b/src/unexmacosx.c
5+
@@ -1,5 +1,5 @@
6+
/* Dump Emacs in Mach-O format for use on macOS.
7+
- Copyright (C) 2001-2017 Free Software Foundation, Inc.
8+
+ Copyright (C) 2001-2020 Free Software Foundation, Inc.
9+
10+
This file is part of GNU Emacs.
11+
12+
@@ -97,9 +97,9 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
13+
14+
#include "unexec.h"
15+
#include "lisp.h"
16+
+#include "sysstdio.h"
17+
18+
#include <errno.h>
19+
-#include <stdio.h>
20+
#include <fcntl.h>
21+
#include <stdarg.h>
22+
#include <stdint.h>
23+
@@ -303,9 +303,9 @@ unexec_error (const char *format, ...)
24+
va_list ap;
25+
26+
va_start (ap, format);
27+
- fprintf (stderr, "unexec: ");
28+
+ fputs ("unexec: ", stderr);
29+
vfprintf (stderr, format, ap);
30+
- fprintf (stderr, "\n");
31+
+ putc ('\n', stderr);
32+
va_end (ap);
33+
exit (1);
34+
}
35+
@@ -447,7 +447,7 @@ unexec_regions_recorder (task_t task, void *rr, unsigned type,
36+
37+
while (num && num_unexec_regions < MAX_UNEXEC_REGIONS)
38+
{
39+
- /* Subtract the size of trailing null bytes from filesize. It
40+
+ /* Subtract the size of trailing NUL bytes from filesize. It
41+
can be smaller than vmsize in segment commands. In such a
42+
case, trailing bytes are initialized with zeros. */
43+
for (p = ranges->address + ranges->size; p > ranges->address; p--)
44+
@@ -503,22 +503,34 @@ unexec_regions_sort_compare (const void *a, const void *b)
45+
static void
46+
unexec_regions_merge (void)
47+
{
48+
- int i, n;
49+
- unexec_region_info r;
50+
- vm_size_t padsize;
51+
-
52+
qsort (unexec_regions, num_unexec_regions, sizeof (unexec_regions[0]),
53+
&unexec_regions_sort_compare);
54+
- n = 0;
55+
- r = unexec_regions[0];
56+
- padsize = r.range.address & (pagesize - 1);
57+
- if (padsize)
58+
+
59+
+ /* Align each region start address to a page boundary. */
60+
+ for (unexec_region_info *cur = unexec_regions;
61+
+ cur < unexec_regions + num_unexec_regions; cur++)
62+
{
63+
- r.range.address -= padsize;
64+
- r.range.size += padsize;
65+
- r.filesize += padsize;
66+
+ vm_size_t padsize = cur->range.address & (pagesize - 1);
67+
+ if (padsize)
68+
+ {
69+
+ cur->range.address -= padsize;
70+
+ cur->range.size += padsize;
71+
+ cur->filesize += padsize;
72+
+
73+
+ unexec_region_info *prev = cur == unexec_regions ? NULL : cur - 1;
74+
+ if (prev
75+
+ && prev->range.address + prev->range.size > cur->range.address)
76+
+ {
77+
+ prev->range.size = cur->range.address - prev->range.address;
78+
+ if (prev->filesize > prev->range.size)
79+
+ prev->filesize = prev->range.size;
80+
+ }
81+
+ }
82+
}
83+
- for (i = 1; i < num_unexec_regions; i++)
84+
+
85+
+ int n = 0;
86+
+ unexec_region_info r = unexec_regions[0];
87+
+ for (int i = 1; i < num_unexec_regions; i++)
88+
{
89+
if (r.range.address + r.range.size == unexec_regions[i].range.address
90+
&& r.range.size - r.filesize < 2 * pagesize)
91+
@@ -530,17 +542,6 @@ unexec_regions_merge (void)
92+
{
93+
unexec_regions[n++] = r;
94+
r = unexec_regions[i];
95+
- padsize = r.range.address & (pagesize - 1);
96+
- if (padsize)
97+
- {
98+
- if ((unexec_regions[n-1].range.address
99+
- + unexec_regions[n-1].range.size) == r.range.address)
100+
- unexec_regions[n-1].range.size -= padsize;
101+
-
102+
- r.range.address -= padsize;
103+
- r.range.size += padsize;
104+
- r.filesize += padsize;
105+
- }
106+
}
107+
}
108+
unexec_regions[n++] = r;

0 commit comments

Comments
 (0)