Mercurial > hg > xemacs-beta
diff 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 |
line wrap: on
line diff
--- a/src/alloc.c Mon Aug 13 09:15:13 2007 +0200 +++ b/src/alloc.c Mon Aug 13 09:15:49 2007 +0200 @@ -2595,24 +2595,46 @@ +static void +PURESIZE_h(long int puresize) +{ + int fd; + char *PURESIZE_h_file = "PURESIZE.h"; + char *WARNING = "/* This file is generated by XEmacs, DO NOT MODIFY!!! */\n"; + char define_PURESIZE[256]; + + if ((fd = open(PURESIZE_h_file, O_WRONLY|O_CREAT)) < 0) { + report_file_error("Can't write PURESIZE", + Fcons(build_ext_string(PURESIZE_h_file, FORMAT_FILENAME), + Qnil)); + } + + write(fd, WARNING, strlen(WARNING)); + sprintf(define_PURESIZE, "# define PURESIZE %ld\n", puresize); + write(fd, define_PURESIZE, strlen(define_PURESIZE)); + close(fd); +} + void report_pure_usage (int report_impurities, int die_if_pure_storage_exceeded) { + int rc = 0; + if (pure_lossage) { CONST long report_round = 5000; message ("\n****\tPure Lisp storage exhausted!\n" - "\tCheck whether you are loading .el files when .elc files were intended.\n" - "\tOtherwise, increase PURESIZE in puresize.h and relink.\n\n" - "\tPURESIZE is presently %ld.\n" "\tAn additional %ld bytes will guarantee enough pure space;\n" "\ta smaller increment may work (due to structure-sharing).\n" "****", - (long) PURESIZE, (((pure_lossage + report_round - 1) / report_round) * report_round)); + if (die_if_pure_storage_exceeded) { + PURESIZE_h(PURESIZE + pure_lossage); + rc = -1; + } } else { @@ -2622,8 +2644,14 @@ sprintf (buf, "Purespace usage: %ld of %ld (%d%%", pureptr, (long) PURESIZE, (int) (pureptr / (PURESIZE / 100.0) + 0.5)); - if (lost > 2) + if (lost > 2) { sprintf (buf + strlen (buf), " -- %dk wasted", lost); + if (die_if_pure_storage_exceeded) { + PURESIZE_h(pureptr + 16); + rc = -1; + } + } + strcat (buf, ")."); message ("%s", buf); } @@ -2706,8 +2734,11 @@ } clear_message (); - if (pure_lossage && die_if_pure_storage_exceeded) + if (rc < 0) { + fatal ("Pure size adjusted, please type `make' again"); + } else if (pure_lossage && die_if_pure_storage_exceeded) { fatal ("Pure storage exhausted"); + } }