mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-09 21:20:45 -08:00
unexmacosx.c: Sort and merge unexec regions before dumping them.
This commit is contained in:
parent
5b4ffca2d0
commit
1dd7ccf280
2 changed files with 48 additions and 1 deletions
|
|
@ -1,3 +1,9 @@
|
|||
2003-07-22 Andrew Choi <akochoi@shaw.ca>
|
||||
|
||||
* unexmacosx.c (unexec_regions_sort_compare):
|
||||
(unexec_regions_merge): New functions. Sort and merge unexec
|
||||
regions before dumping them.
|
||||
|
||||
2003-07-22 Dave Love <fx@gnu.org>
|
||||
|
||||
* xfns.c [HAVE_PNG]: Consider both png.h and libpng/png.h.
|
||||
|
|
|
|||
|
|
@ -364,7 +364,7 @@ build_region_list ()
|
|||
}
|
||||
|
||||
|
||||
#define MAX_UNEXEC_REGIONS 30
|
||||
#define MAX_UNEXEC_REGIONS 200
|
||||
|
||||
int num_unexec_regions;
|
||||
vm_range_t unexec_regions[MAX_UNEXEC_REGIONS];
|
||||
|
|
@ -403,6 +403,46 @@ find_emacs_zone_regions ()
|
|||
unexec_regions_recorder);
|
||||
}
|
||||
|
||||
static int
|
||||
unexec_regions_sort_compare (const void *a, const void *b)
|
||||
{
|
||||
vm_address_t aa = ((vm_range_t *) a)->address;
|
||||
vm_address_t bb = ((vm_range_t *) b)->address;
|
||||
|
||||
if (aa < bb)
|
||||
return -1;
|
||||
else if (aa > bb)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
unexec_regions_merge ()
|
||||
{
|
||||
int i, n;
|
||||
vm_range_t r;
|
||||
|
||||
qsort (unexec_regions, num_unexec_regions, sizeof (unexec_regions[0]),
|
||||
&unexec_regions_sort_compare);
|
||||
n = 0;
|
||||
r = unexec_regions[0];
|
||||
for (i = 1; i < num_unexec_regions; i++)
|
||||
{
|
||||
if (r.address + r.size == unexec_regions[i].address)
|
||||
{
|
||||
r.size += unexec_regions[i].size;
|
||||
}
|
||||
else
|
||||
{
|
||||
unexec_regions[n++] = r;
|
||||
r = unexec_regions[i];
|
||||
}
|
||||
}
|
||||
unexec_regions[n++] = r;
|
||||
num_unexec_regions = n;
|
||||
}
|
||||
|
||||
|
||||
/* More informational messages routines. */
|
||||
|
||||
|
|
@ -863,6 +903,7 @@ unexec (char *outfile, char *infile, void *start_data, void *start_bss,
|
|||
read_load_commands ();
|
||||
|
||||
find_emacs_zone_regions ();
|
||||
unexec_regions_merge ();
|
||||
|
||||
in_dumped_exec = 1;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue