Mercurial > hg > xemacs-beta
comparison src/alloc.c @ 102:a145efe76779 r20-1b3
Import from CVS: tag r20-1b3
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:15:49 +0200 |
parents | 4be1180a9e89 |
children | cf808b4c4290 |
comparison
equal
deleted
inserted
replaced
101:a0ec055d74dd | 102:a145efe76779 |
---|---|
2593 return (obj); | 2593 return (obj); |
2594 } | 2594 } |
2595 | 2595 |
2596 | 2596 |
2597 | 2597 |
2598 static void | |
2599 PURESIZE_h(long int puresize) | |
2600 { | |
2601 int fd; | |
2602 char *PURESIZE_h_file = "PURESIZE.h"; | |
2603 char *WARNING = "/* This file is generated by XEmacs, DO NOT MODIFY!!! */\n"; | |
2604 char define_PURESIZE[256]; | |
2605 | |
2606 if ((fd = open(PURESIZE_h_file, O_WRONLY|O_CREAT)) < 0) { | |
2607 report_file_error("Can't write PURESIZE", | |
2608 Fcons(build_ext_string(PURESIZE_h_file, FORMAT_FILENAME), | |
2609 Qnil)); | |
2610 } | |
2611 | |
2612 write(fd, WARNING, strlen(WARNING)); | |
2613 sprintf(define_PURESIZE, "# define PURESIZE %ld\n", puresize); | |
2614 write(fd, define_PURESIZE, strlen(define_PURESIZE)); | |
2615 close(fd); | |
2616 } | |
2617 | |
2598 void | 2618 void |
2599 report_pure_usage (int report_impurities, | 2619 report_pure_usage (int report_impurities, |
2600 int die_if_pure_storage_exceeded) | 2620 int die_if_pure_storage_exceeded) |
2601 { | 2621 { |
2622 int rc = 0; | |
2623 | |
2602 if (pure_lossage) | 2624 if (pure_lossage) |
2603 { | 2625 { |
2604 CONST long report_round = 5000; | 2626 CONST long report_round = 5000; |
2605 | 2627 |
2606 message ("\n****\tPure Lisp storage exhausted!\n" | 2628 message ("\n****\tPure Lisp storage exhausted!\n" |
2607 "\tCheck whether you are loading .el files when .elc files were intended.\n" | |
2608 "\tOtherwise, increase PURESIZE in puresize.h and relink.\n\n" | |
2609 "\tPURESIZE is presently %ld.\n" | |
2610 "\tAn additional %ld bytes will guarantee enough pure space;\n" | 2629 "\tAn additional %ld bytes will guarantee enough pure space;\n" |
2611 "\ta smaller increment may work (due to structure-sharing).\n" | 2630 "\ta smaller increment may work (due to structure-sharing).\n" |
2612 "****", | 2631 "****", |
2613 (long) PURESIZE, | |
2614 (((pure_lossage + report_round - 1) | 2632 (((pure_lossage + report_round - 1) |
2615 / report_round) * report_round)); | 2633 / report_round) * report_round)); |
2634 if (die_if_pure_storage_exceeded) { | |
2635 PURESIZE_h(PURESIZE + pure_lossage); | |
2636 rc = -1; | |
2637 } | |
2616 } | 2638 } |
2617 else | 2639 else |
2618 { | 2640 { |
2619 int lost = (PURESIZE - pureptr) / 1024; | 2641 int lost = (PURESIZE - pureptr) / 1024; |
2620 char buf[200]; | 2642 char buf[200]; |
2621 | 2643 |
2622 sprintf (buf, "Purespace usage: %ld of %ld (%d%%", | 2644 sprintf (buf, "Purespace usage: %ld of %ld (%d%%", |
2623 pureptr, (long) PURESIZE, | 2645 pureptr, (long) PURESIZE, |
2624 (int) (pureptr / (PURESIZE / 100.0) + 0.5)); | 2646 (int) (pureptr / (PURESIZE / 100.0) + 0.5)); |
2625 if (lost > 2) | 2647 if (lost > 2) { |
2626 sprintf (buf + strlen (buf), " -- %dk wasted", lost); | 2648 sprintf (buf + strlen (buf), " -- %dk wasted", lost); |
2649 if (die_if_pure_storage_exceeded) { | |
2650 PURESIZE_h(pureptr + 16); | |
2651 rc = -1; | |
2652 } | |
2653 } | |
2654 | |
2627 strcat (buf, ")."); | 2655 strcat (buf, ")."); |
2628 message ("%s", buf); | 2656 message ("%s", buf); |
2629 } | 2657 } |
2630 | 2658 |
2631 #ifdef PURESTAT | 2659 #ifdef PURESTAT |
2704 UNGCPRO; | 2732 UNGCPRO; |
2705 garbage_collect_1 (); /* GC garbage_collect's garbage */ | 2733 garbage_collect_1 (); /* GC garbage_collect's garbage */ |
2706 } | 2734 } |
2707 clear_message (); | 2735 clear_message (); |
2708 | 2736 |
2709 if (pure_lossage && die_if_pure_storage_exceeded) | 2737 if (rc < 0) { |
2738 fatal ("Pure size adjusted, please type `make' again"); | |
2739 } else if (pure_lossage && die_if_pure_storage_exceeded) { | |
2710 fatal ("Pure storage exhausted"); | 2740 fatal ("Pure storage exhausted"); |
2741 } | |
2711 } | 2742 } |
2712 | 2743 |
2713 | 2744 |
2714 /**********************************************************************/ | 2745 /**********************************************************************/ |
2715 /* staticpro */ | 2746 /* staticpro */ |