aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJim Blandy1992-03-14 19:09:32 +0000
committerJim Blandy1992-03-14 19:09:32 +0000
commit956ace37a8ec4df40a07940c08d5aa6d10e8b073 (patch)
tree47a79680bb2980f34271e67401a3c0f545045a51 /src
parentfb955dfadd6fd6031b50561e184610c56f04a2cc (diff)
downloademacs-956ace37a8ec4df40a07940c08d5aa6d10e8b073.tar.gz
emacs-956ace37a8ec4df40a07940c08d5aa6d10e8b073.zip
*** empty log message ***
Diffstat (limited to 'src')
-rw-r--r--src/doc.c14
-rw-r--r--src/editfns.c31
-rw-r--r--src/ralloc.c66
3 files changed, 71 insertions, 40 deletions
diff --git a/src/doc.c b/src/doc.c
index ee6c87d5231..a907118c9ea 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -1,5 +1,5 @@
1/* Record indices of function doc strings stored in a file. 1/* Record indices of function doc strings stored in a file.
2 Copyright (C) 1985, 1986 Free Software Foundation, Inc. 2 Copyright (C) 1985, 1986, 1992 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
@@ -174,19 +174,17 @@ subcommands.)");
174 return Fsignal (Qinvalid_function, Fcons (fun, Qnil)); 174 return Fsignal (Qinvalid_function, Fcons (fun, Qnil));
175 } 175 }
176 176
177 if (NULL (raw)) 177 if (NILP (raw))
178 doc = Fsubstitute_command_keys (doc); 178 doc = Fsubstitute_command_keys (doc);
179 return doc; 179 return doc;
180} 180}
181 181
182DEFUN ("documentation-property", Fdocumentation_property, 182DEFUN ("documentation-property", Fdocumentation_property, Sdocumentation_property, 2, 2, 0,
183 Sdocumentation_property, 2, 2, 0,
184
185 "Return the documentation string that is SYMBOL's PROP property.\n\ 183 "Return the documentation string that is SYMBOL's PROP property.\n\
186This is like `get', but it can refer to strings stored in the\n\ 184This is like `get', but it can refer to strings stored in the\n\
187`share-lib/DOC' file; and if the value is a string, it is passed through\n\ 185`share-lib/DOC' file; and if the value is a string, it is passed through\n\
188`substitute-command-keys'. A non-nil third argument avoids this 186`substitute-command-keys'. A non-nil third argument avoids this\n\
189translation." 187translation.")
190 (sym, prop, raw) 188 (sym, prop, raw)
191 Lisp_Object sym, prop, raw; 189 Lisp_Object sym, prop, raw;
192{ 190{
@@ -195,7 +193,7 @@ translation."
195 tem = Fget (sym, prop); 193 tem = Fget (sym, prop);
196 if (XTYPE (tem) == Lisp_Int) 194 if (XTYPE (tem) == Lisp_Int)
197 tem = get_doc_string (XINT (tem) > 0 ? XINT (tem) : - XINT (tem)); 195 tem = get_doc_string (XINT (tem) > 0 ? XINT (tem) : - XINT (tem));
198 if (NULL (raw) && XTYPE (tem) == Lisp_String) 196 if (NILP (raw) && XTYPE (tem) == Lisp_String)
199 return Fsubstitute_command_keys (tem); 197 return Fsubstitute_command_keys (tem);
200 return tem; 198 return tem;
201} 199}
diff --git a/src/editfns.c b/src/editfns.c
index 2d75d105a44..d0db0837591 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -1,5 +1,5 @@
1/* Lisp functions pertaining to editing. 1/* Lisp functions pertaining to editing.
2 Copyright (C) 1985, 1986, 1987, 1989 Free Software Foundation, Inc. 2 Copyright (C) 1985, 1986, 1987, 1989, 1992 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
@@ -21,7 +21,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
21#include "config.h" 21#include "config.h"
22 22
23#ifdef VMS 23#ifdef VMS
24#include "pwd.h" 24#include "vms-pwd.h"
25#else 25#else
26#include <pwd.h> 26#include <pwd.h>
27#endif 27#endif
@@ -30,13 +30,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
30#include "buffer.h" 30#include "buffer.h"
31#include "window.h" 31#include "window.h"
32 32
33#ifdef NEED_TIME_H 33#include "systime.h"
34#include <time.h>
35#else /* not NEED_TIME_H */
36#ifdef HAVE_TIMEVAL
37#include <sys/time.h>
38#endif /* HAVE_TIMEVAL */
39#endif /* not NEED_TIME_H */
40 34
41#define min(a, b) ((a) < (b) ? (a) : (b)) 35#define min(a, b) ((a) < (b) ? (a) : (b))
42#define max(a, b) ((a) > (b) ? (a) : (b)) 36#define max(a, b) ((a) > (b) ? (a) : (b))
@@ -509,10 +503,25 @@ DEFUN ("system-name", Fsystem_name, Ssystem_name, 0, 0, 0,
509} 503}
510 504
511DEFUN ("current-time", Fcurrent_time, Scurrent_time, 0, 0, 0, 505DEFUN ("current-time", Fcurrent_time, Scurrent_time, 0, 0, 0,
512 "Return the current time, as an integer.") 506 "Return the current time, as the number of seconds since 12:00 AM January 1970.\n\
507The time is returned as a list of three integers. The first has the\n\
508most significant 16 bits of the seconds, while the second has the\n\
509least significant 16 bits. The third integer gives the microsecond\n\
510count.\n\
511\n\
512The microsecond count is zero on systems that do not provide\n\
513resolution finer than a second.")
513 () 514 ()
514{ 515{
515 return make_number (time(0)); 516 EMACS_TIME t;
517 Lisp_Object result[3];
518
519 EMACS_GET_TIME (t);
520 XSET (result[0], Lisp_Int, (EMACS_SECS (t) >> 16) & 0xffff);
521 XSET (result[1], Lisp_Int, (EMACS_SECS (t) >> 0) & 0xffff);
522 XSET (result[2], Lisp_Int, EMACS_USECS (t));
523
524 return Flist (3, result);
516} 525}
517 526
518 527
diff --git a/src/ralloc.c b/src/ralloc.c
index d2dae3637a0..fe22ae4ffe1 100644
--- a/src/ralloc.c
+++ b/src/ralloc.c
@@ -1,5 +1,5 @@
1/* Block-relocating memory allocator. 1/* Block-relocating memory allocator.
2 Copyright (C) 1990 Free Software Foundation, Inc. 2 Copyright (C) 1992 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
@@ -24,14 +24,15 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
24 hole between the first bloc and the end of malloc storage. */ 24 hole between the first bloc and the end of malloc storage. */
25 25
26#include "config.h" 26#include "config.h"
27#include "lisp.h" /* Needed for xterm.h */ 27#include "lisp.h" /* Needed for VALBITS. */
28#undef NULL 28#undef NULL
29#include "mem_limits.h" 29#include "mem_limits.h"
30#include "xterm.h" /* Needed for BLOCK_INPUT */
31 30
32#define NIL ((POINTER) 0) 31#define NIL ((POINTER) 0)
33 32
34 33
34/* Declarations for working with the malloc, ralloc, and system breaks. */
35
35/* System call to set the break value. */ 36/* System call to set the break value. */
36extern POINTER sbrk (); 37extern POINTER sbrk ();
37 38
@@ -52,6 +53,8 @@ static POINTER page_break_value;
52#define ROUND_TO_PAGE(addr) (addr & (~(PAGE - 1))) 53#define ROUND_TO_PAGE(addr) (addr & (~(PAGE - 1)))
53#define EXCEEDS_ELISP_PTR(ptr) ((unsigned int) (ptr) >> VALBITS) 54#define EXCEEDS_ELISP_PTR(ptr) ((unsigned int) (ptr) >> VALBITS)
54 55
56/* Managing "almost out of memory" warnings. */
57
55/* Level of warnings issued. */ 58/* Level of warnings issued. */
56static int warnlevel; 59static int warnlevel;
57 60
@@ -100,6 +103,8 @@ check_memory_limits (address)
100 memory_full (); 103 memory_full ();
101} 104}
102 105
106/* Functions to get and return memory from the system. */
107
103/* Obtain SIZE bytes of space. If enough space is not presently available 108/* Obtain SIZE bytes of space. If enough space is not presently available
104 in our process reserve, (i.e., (page_break_value - break_value)), 109 in our process reserve, (i.e., (page_break_value - break_value)),
105 this means getting more page-aligned space from the system. */ 110 this means getting more page-aligned space from the system. */
@@ -112,7 +117,7 @@ obtain (size)
112 117
113 if (already_available < size) 118 if (already_available < size)
114 { 119 {
115 SIZE get = ROUNDUP (size); 120 SIZE get = ROUNDUP (size - already_available);
116 121
117 if (warnfunction) 122 if (warnfunction)
118 check_memory_limits (page_break_value); 123 check_memory_limits (page_break_value);
@@ -138,26 +143,37 @@ get_more_space (size)
138} 143}
139 144
140/* Note that SIZE bytes of space have been relinquished by the process. 145/* Note that SIZE bytes of space have been relinquished by the process.
141 If SIZE is more than a page, return the space the system. */ 146 If SIZE is more than a page, return the space to the system. */
142 147
143static void 148static void
144relinquish (size) 149relinquish (size)
145 SIZE size; 150 SIZE size;
146{ 151{
147 SIZE page_part = ROUND_TO_PAGE (size); 152 POINTER new_page_break;
148 153
149 if (page_part) 154 break_value -= size;
155 new_page_break = (POINTER) ROUNDUP (break_value);
156
157 if (new_page_break != page_break_value)
150 { 158 {
151 if (((int) (sbrk (- page_part))) < 0) 159 if (((int) (sbrk ((char *) new_page_break
160 - (char *) page_break_value))) < 0)
152 abort (); 161 abort ();
153 162
154 page_break_value -= page_part; 163 page_break_value = new_page_break;
155 } 164 }
156 165
157 break_value -= size; 166 /* Zero the space from the end of the "official" break to the actual
158 bzero (break_value, (size - page_part)); 167 break, so that bugs show up faster. */
168 bzero (break_value, ((char *) page_break_value - (char *) break_value));
159} 169}
160 170
171/* The meat - allocating, freeing, and relocating blocs. */
172
173/* These structures are allocated in the malloc arena.
174 The linked list is kept in order of increasing '.data' members.
175 The data blocks abut each other; if b->next is non-nil, then
176 b->data + b->size == b->next->data. */
161typedef struct bp 177typedef struct bp
162{ 178{
163 struct bp *next; 179 struct bp *next;
@@ -173,10 +189,11 @@ typedef struct bp
173/* Head and tail of the list of relocatable blocs. */ 189/* Head and tail of the list of relocatable blocs. */
174static bloc_ptr first_bloc, last_bloc; 190static bloc_ptr first_bloc, last_bloc;
175 191
176/* Declared in dispnew.c, this version dosen't fuck up if regions overlap. */ 192/* Declared in dispnew.c, this version doesn't screw up if regions
193 overlap. */
177extern void safe_bcopy (); 194extern void safe_bcopy ();
178 195
179/* Find the bloc reference by the address in PTR. Returns a pointer 196/* Find the bloc referenced by the address in PTR. Returns a pointer
180 to that block. */ 197 to that block. */
181 198
182static bloc_ptr 199static bloc_ptr
@@ -285,6 +302,8 @@ free_bloc (bloc)
285 free (bloc); 302 free (bloc);
286} 303}
287 304
305/* Interface routines. */
306
288static int use_relocatable_buffers; 307static int use_relocatable_buffers;
289 308
290/* Obtain SIZE bytes of storage from the free pool, or the system, 309/* Obtain SIZE bytes of storage from the free pool, or the system,
@@ -306,6 +325,9 @@ r_alloc_sbrk (size)
306 if (first_bloc) 325 if (first_bloc)
307 { 326 {
308 relocate_some_blocs (first_bloc, first_bloc->data + size); 327 relocate_some_blocs (first_bloc, first_bloc->data + size);
328
329 /* Zero out the space we just allocated, to help catch bugs
330 quickly. */
309 bzero (virtual_break_value, size); 331 bzero (virtual_break_value, size);
310 } 332 }
311 } 333 }
@@ -332,11 +354,9 @@ r_alloc (ptr, size)
332{ 354{
333 register bloc_ptr new_bloc; 355 register bloc_ptr new_bloc;
334 356
335 BLOCK_INPUT;
336 new_bloc = get_bloc (size); 357 new_bloc = get_bloc (size);
337 new_bloc->variable = ptr; 358 new_bloc->variable = ptr;
338 *ptr = new_bloc->data; 359 *ptr = new_bloc->data;
339 UNBLOCK_INPUT;
340 360
341 return *ptr; 361 return *ptr;
342} 362}
@@ -349,13 +369,11 @@ r_alloc_free (ptr)
349{ 369{
350 register bloc_ptr dead_bloc; 370 register bloc_ptr dead_bloc;
351 371
352 BLOCK_INPUT;
353 dead_bloc = find_bloc (ptr); 372 dead_bloc = find_bloc (ptr);
354 if (dead_bloc == NIL_BLOC) 373 if (dead_bloc == NIL_BLOC)
355 abort (); 374 abort ();
356 375
357 free_bloc (dead_bloc); 376 free_bloc (dead_bloc);
358 UNBLOCK_INPUT;
359} 377}
360 378
361/* Given a pointer at address PTR to relocatable data, resize it 379/* Given a pointer at address PTR to relocatable data, resize it
@@ -373,12 +391,12 @@ r_re_alloc (ptr, size)
373{ 391{
374 register bloc_ptr old_bloc, new_bloc; 392 register bloc_ptr old_bloc, new_bloc;
375 393
376 BLOCK_INPUT;
377 old_bloc = find_bloc (ptr); 394 old_bloc = find_bloc (ptr);
378 if (old_bloc == NIL_BLOC) 395 if (old_bloc == NIL_BLOC)
379 abort (); 396 abort ();
380 397
381 if (size <= old_bloc->size) 398 if (size <= old_bloc->size)
399 /* Wouldn't it be useful to actually resize the bloc here? */
382 return *ptr; 400 return *ptr;
383 401
384 new_bloc = get_bloc (size); 402 new_bloc = get_bloc (size);
@@ -387,7 +405,6 @@ r_re_alloc (ptr, size)
387 *ptr = new_bloc->data; 405 *ptr = new_bloc->data;
388 406
389 free_bloc (old_bloc); 407 free_bloc (old_bloc);
390 UNBLOCK_INPUT;
391 408
392 return *ptr; 409 return *ptr;
393} 410}
@@ -396,6 +413,15 @@ r_re_alloc (ptr, size)
396 from the system. */ 413 from the system. */
397extern POINTER (*__morecore) (); 414extern POINTER (*__morecore) ();
398 415
416/* A flag to indicate whether we have initialized ralloc yet. For
417 Emacs's sake, please do not make this local to malloc_init; on some
418 machines, the dumping procedure makes all static variables
419 read-only. On these machines, the word static is #defined to be
420 the empty string, meaning that malloc_initialized becomes an
421 automatic variable, and loses its value each time Emacs is started
422 up. */
423static int malloc_initialized = 0;
424
399/* Intialize various things for memory allocation. */ 425/* Intialize various things for memory allocation. */
400 426
401void 427void
@@ -403,8 +429,6 @@ malloc_init (start, warn_func)
403 POINTER start; 429 POINTER start;
404 void (*warn_func) (); 430 void (*warn_func) ();
405{ 431{
406 static int malloc_initialized = 0;
407
408 if (start) 432 if (start)
409 data_space_start = start; 433 data_space_start = start;
410 434