aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrew Choi2003-07-22 17:54:50 +0000
committerAndrew Choi2003-07-22 17:54:50 +0000
commit1dd7ccf2804ea436ffca8d92b9617b21d623e7f5 (patch)
tree423707659881db00842fec112cef9061cb635f63 /src
parent5b4ffca2d08d9ca126ccb24b31fe810df22e70bb (diff)
downloademacs-1dd7ccf2804ea436ffca8d92b9617b21d623e7f5.tar.gz
emacs-1dd7ccf2804ea436ffca8d92b9617b21d623e7f5.zip
unexmacosx.c: Sort and merge unexec regions before dumping them.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog6
-rw-r--r--src/unexmacosx.c43
2 files changed, 48 insertions, 1 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index b99d5b4a2ba..e9ddaf38aa8 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
12003-07-22 Andrew Choi <akochoi@shaw.ca>
2
3 * unexmacosx.c (unexec_regions_sort_compare):
4 (unexec_regions_merge): New functions. Sort and merge unexec
5 regions before dumping them.
6
12003-07-22 Dave Love <fx@gnu.org> 72003-07-22 Dave Love <fx@gnu.org>
2 8
3 * xfns.c [HAVE_PNG]: Consider both png.h and libpng/png.h. 9 * xfns.c [HAVE_PNG]: Consider both png.h and libpng/png.h.
diff --git a/src/unexmacosx.c b/src/unexmacosx.c
index ac87f9e6c63..c84e5c95d03 100644
--- a/src/unexmacosx.c
+++ b/src/unexmacosx.c
@@ -364,7 +364,7 @@ build_region_list ()
364} 364}
365 365
366 366
367#define MAX_UNEXEC_REGIONS 30 367#define MAX_UNEXEC_REGIONS 200
368 368
369int num_unexec_regions; 369int num_unexec_regions;
370vm_range_t unexec_regions[MAX_UNEXEC_REGIONS]; 370vm_range_t unexec_regions[MAX_UNEXEC_REGIONS];
@@ -403,6 +403,46 @@ find_emacs_zone_regions ()
403 unexec_regions_recorder); 403 unexec_regions_recorder);
404} 404}
405 405
406static int
407unexec_regions_sort_compare (const void *a, const void *b)
408{
409 vm_address_t aa = ((vm_range_t *) a)->address;
410 vm_address_t bb = ((vm_range_t *) b)->address;
411
412 if (aa < bb)
413 return -1;
414 else if (aa > bb)
415 return 1;
416 else
417 return 0;
418}
419
420static void
421unexec_regions_merge ()
422{
423 int i, n;
424 vm_range_t r;
425
426 qsort (unexec_regions, num_unexec_regions, sizeof (unexec_regions[0]),
427 &unexec_regions_sort_compare);
428 n = 0;
429 r = unexec_regions[0];
430 for (i = 1; i < num_unexec_regions; i++)
431 {
432 if (r.address + r.size == unexec_regions[i].address)
433 {
434 r.size += unexec_regions[i].size;
435 }
436 else
437 {
438 unexec_regions[n++] = r;
439 r = unexec_regions[i];
440 }
441 }
442 unexec_regions[n++] = r;
443 num_unexec_regions = n;
444}
445
406 446
407/* More informational messages routines. */ 447/* More informational messages routines. */
408 448
@@ -863,6 +903,7 @@ unexec (char *outfile, char *infile, void *start_data, void *start_bss,
863 read_load_commands (); 903 read_load_commands ();
864 904
865 find_emacs_zone_regions (); 905 find_emacs_zone_regions ();
906 unexec_regions_merge ();
866 907
867 in_dumped_exec = 1; 908 in_dumped_exec = 1;
868 909