1 /* Functions for memory limit warnings.
2 Copyright (C) 1990 Free Software Foundation, Inc.
4 This file is part of GNU Emacs.
6 GNU Emacs is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 1, or (at your option)
11 GNU Emacs is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Emacs; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
22 #include "mem_limits.h"
25 Level number of warnings already issued.
26 0 -- no warnings issued.
27 1 -- 75% warning already issued.
28 2 -- 85% warning already issued.
32 /* Function to call to issue a warning;
33 0 means don't issue them. */
34 static void (*warnfunction
) ();
36 extern POINTER
sbrk ();
38 /* Get more memory space, complaining if we're near the end. */
41 morecore_with_warning (size
)
46 register unsigned int siz
;
48 if (!data_space_start
)
50 data_space_start
= start_of_data ();
56 /* Find current end of memory and issue warning if getting near max */
58 siz
= cp
- data_space_start
;
64 if (siz
> (lim_data
/ 4) * 3)
67 (*warnfunction
) ("Warning: past 75% of memory limit");
72 if (siz
> (lim_data
/ 20) * 17)
75 (*warnfunction
) ("Warning: past 85% of memory limit");
80 if (siz
> (lim_data
/ 20) * 19)
83 (*warnfunction
) ("Warning: past 95% of memory limit");
88 (*warnfunction
) ("Warning: past acceptable memory limits");
92 if (EXCEEDS_ELISP_PTR (cp
))
93 (*warnfunction
) ("Warning: memory in use exceeds lisp pointer size");
96 if (result
== (POINTER
) -1)
101 /* Cause reinitialization based on job parameters;
102 also declare where the end of pure storage is. */
105 malloc_init (start
, warnfun
)
109 extern POINTER (* __morecore
) (); /* From gmalloc.c */
112 data_space_start
= start
;
115 warnfunction
= warnfun
;
116 __morecore
= &morecore_with_warning
;