summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Blandy <jimb@redhat.com>1992-03-14 19:09:32 +0000
committerJim Blandy <jimb@redhat.com>1992-03-14 19:09:32 +0000
commit7104081a42ad7bd54c837e922f3f2d8b1d40b9ec (patch)
tree1ff6574574401267affad3a7b3fe9b4017c4dd4e /src
parentb272abc2bf36bde6ad105e191042200ee10213c6 (diff)
downloademacs-7104081a42ad7bd54c837e922f3f2d8b1d40b9ec.tar.gz
*** 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 @@
/* Record indices of function doc strings stored in a file.
- Copyright (C) 1985, 1986 Free Software Foundation, Inc.
+ Copyright (C) 1985, 1986, 1992 Free Software Foundation, Inc.
This file is part of GNU Emacs.
@@ -174,19 +174,17 @@ subcommands.)");
return Fsignal (Qinvalid_function, Fcons (fun, Qnil));
}
- if (NULL (raw))
+ if (NILP (raw))
doc = Fsubstitute_command_keys (doc);
return doc;
}
-DEFUN ("documentation-property", Fdocumentation_property,
- Sdocumentation_property, 2, 2, 0,
-
+DEFUN ("documentation-property", Fdocumentation_property, Sdocumentation_property, 2, 2, 0,
"Return the documentation string that is SYMBOL's PROP property.\n\
This is like `get', but it can refer to strings stored in the\n\
`share-lib/DOC' file; and if the value is a string, it is passed through\n\
-`substitute-command-keys'. A non-nil third argument avoids this
-translation."
+`substitute-command-keys'. A non-nil third argument avoids this\n\
+translation.")
(sym, prop, raw)
Lisp_Object sym, prop, raw;
{
@@ -195,7 +193,7 @@ translation."
tem = Fget (sym, prop);
if (XTYPE (tem) == Lisp_Int)
tem = get_doc_string (XINT (tem) > 0 ? XINT (tem) : - XINT (tem));
- if (NULL (raw) && XTYPE (tem) == Lisp_String)
+ if (NILP (raw) && XTYPE (tem) == Lisp_String)
return Fsubstitute_command_keys (tem);
return tem;
}
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 @@
/* Lisp functions pertaining to editing.
- Copyright (C) 1985, 1986, 1987, 1989 Free Software Foundation, Inc.
+ Copyright (C) 1985, 1986, 1987, 1989, 1992 Free Software Foundation, Inc.
This file is part of GNU Emacs.
@@ -21,7 +21,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "config.h"
#ifdef VMS
-#include "pwd.h"
+#include "vms-pwd.h"
#else
#include <pwd.h>
#endif
@@ -30,13 +30,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "buffer.h"
#include "window.h"
-#ifdef NEED_TIME_H
-#include <time.h>
-#else /* not NEED_TIME_H */
-#ifdef HAVE_TIMEVAL
-#include <sys/time.h>
-#endif /* HAVE_TIMEVAL */
-#endif /* not NEED_TIME_H */
+#include "systime.h"
#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))
@@ -509,10 +503,25 @@ DEFUN ("system-name", Fsystem_name, Ssystem_name, 0, 0, 0,
}
DEFUN ("current-time", Fcurrent_time, Scurrent_time, 0, 0, 0,
- "Return the current time, as an integer.")
+ "Return the current time, as the number of seconds since 12:00 AM January 1970.\n\
+The time is returned as a list of three integers. The first has the\n\
+most significant 16 bits of the seconds, while the second has the\n\
+least significant 16 bits. The third integer gives the microsecond\n\
+count.\n\
+\n\
+The microsecond count is zero on systems that do not provide\n\
+resolution finer than a second.")
()
{
- return make_number (time(0));
+ EMACS_TIME t;
+ Lisp_Object result[3];
+
+ EMACS_GET_TIME (t);
+ XSET (result[0], Lisp_Int, (EMACS_SECS (t) >> 16) & 0xffff);
+ XSET (result[1], Lisp_Int, (EMACS_SECS (t) >> 0) & 0xffff);
+ XSET (result[2], Lisp_Int, EMACS_USECS (t));
+
+ return Flist (3, result);
}
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 @@
/* Block-relocating memory allocator.
- Copyright (C) 1990 Free Software Foundation, Inc.
+ Copyright (C) 1992 Free Software Foundation, Inc.
This file is part of GNU Emacs.
@@ -24,14 +24,15 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
hole between the first bloc and the end of malloc storage. */
#include "config.h"
-#include "lisp.h" /* Needed for xterm.h */
+#include "lisp.h" /* Needed for VALBITS. */
#undef NULL
#include "mem_limits.h"
-#include "xterm.h" /* Needed for BLOCK_INPUT */
#define NIL ((POINTER) 0)
+/* Declarations for working with the malloc, ralloc, and system breaks. */
+
/* System call to set the break value. */
extern POINTER sbrk ();
@@ -52,6 +53,8 @@ static POINTER page_break_value;
#define ROUND_TO_PAGE(addr) (addr & (~(PAGE - 1)))
#define EXCEEDS_ELISP_PTR(ptr) ((unsigned int) (ptr) >> VALBITS)
+/* Managing "almost out of memory" warnings. */
+
/* Level of warnings issued. */
static int warnlevel;
@@ -100,6 +103,8 @@ check_memory_limits (address)
memory_full ();
}
+/* Functions to get and return memory from the system. */
+
/* Obtain SIZE bytes of space. If enough space is not presently available
in our process reserve, (i.e., (page_break_value - break_value)),
this means getting more page-aligned space from the system. */
@@ -112,7 +117,7 @@ obtain (size)
if (already_available < size)
{
- SIZE get = ROUNDUP (size);
+ SIZE get = ROUNDUP (size - already_available);
if (warnfunction)
check_memory_limits (page_break_value);
@@ -138,26 +143,37 @@ get_more_space (size)
}
/* Note that SIZE bytes of space have been relinquished by the process.
- If SIZE is more than a page, return the space the system. */
+ If SIZE is more than a page, return the space to the system. */
static void
relinquish (size)
SIZE size;
{
- SIZE page_part = ROUND_TO_PAGE (size);
+ POINTER new_page_break;
- if (page_part)
+ break_value -= size;
+ new_page_break = (POINTER) ROUNDUP (break_value);
+
+ if (new_page_break != page_break_value)
{
- if (((int) (sbrk (- page_part))) < 0)
+ if (((int) (sbrk ((char *) new_page_break
+ - (char *) page_break_value))) < 0)
abort ();
- page_break_value -= page_part;
+ page_break_value = new_page_break;
}
- break_value -= size;
- bzero (break_value, (size - page_part));
+ /* Zero the space from the end of the "official" break to the actual
+ break, so that bugs show up faster. */
+ bzero (break_value, ((char *) page_break_value - (char *) break_value));
}
+/* The meat - allocating, freeing, and relocating blocs. */
+
+/* These structures are allocated in the malloc arena.
+ The linked list is kept in order of increasing '.data' members.
+ The data blocks abut each other; if b->next is non-nil, then
+ b->data + b->size == b->next->data. */
typedef struct bp
{
struct bp *next;
@@ -173,10 +189,11 @@ typedef struct bp
/* Head and tail of the list of relocatable blocs. */
static bloc_ptr first_bloc, last_bloc;
-/* Declared in dispnew.c, this version dosen't fuck up if regions overlap. */
+/* Declared in dispnew.c, this version doesn't screw up if regions
+ overlap. */
extern void safe_bcopy ();
-/* Find the bloc reference by the address in PTR. Returns a pointer
+/* Find the bloc referenced by the address in PTR. Returns a pointer
to that block. */
static bloc_ptr
@@ -285,6 +302,8 @@ free_bloc (bloc)
free (bloc);
}
+/* Interface routines. */
+
static int use_relocatable_buffers;
/* Obtain SIZE bytes of storage from the free pool, or the system,
@@ -306,6 +325,9 @@ r_alloc_sbrk (size)
if (first_bloc)
{
relocate_some_blocs (first_bloc, first_bloc->data + size);
+
+ /* Zero out the space we just allocated, to help catch bugs
+ quickly. */
bzero (virtual_break_value, size);
}
}
@@ -332,11 +354,9 @@ r_alloc (ptr, size)
{
register bloc_ptr new_bloc;
- BLOCK_INPUT;
new_bloc = get_bloc (size);
new_bloc->variable = ptr;
*ptr = new_bloc->data;
- UNBLOCK_INPUT;
return *ptr;
}
@@ -349,13 +369,11 @@ r_alloc_free (ptr)
{
register bloc_ptr dead_bloc;
- BLOCK_INPUT;
dead_bloc = find_bloc (ptr);
if (dead_bloc == NIL_BLOC)
abort ();
free_bloc (dead_bloc);
- UNBLOCK_INPUT;
}
/* Given a pointer at address PTR to relocatable data, resize it
@@ -373,12 +391,12 @@ r_re_alloc (ptr, size)
{
register bloc_ptr old_bloc, new_bloc;
- BLOCK_INPUT;
old_bloc = find_bloc (ptr);
if (old_bloc == NIL_BLOC)
abort ();
if (size <= old_bloc->size)
+ /* Wouldn't it be useful to actually resize the bloc here? */
return *ptr;
new_bloc = get_bloc (size);
@@ -387,7 +405,6 @@ r_re_alloc (ptr, size)
*ptr = new_bloc->data;
free_bloc (old_bloc);
- UNBLOCK_INPUT;
return *ptr;
}
@@ -396,6 +413,15 @@ r_re_alloc (ptr, size)
from the system. */
extern POINTER (*__morecore) ();
+/* A flag to indicate whether we have initialized ralloc yet. For
+ Emacs's sake, please do not make this local to malloc_init; on some
+ machines, the dumping procedure makes all static variables
+ read-only. On these machines, the word static is #defined to be
+ the empty string, meaning that malloc_initialized becomes an
+ automatic variable, and loses its value each time Emacs is started
+ up. */
+static int malloc_initialized = 0;
+
/* Intialize various things for memory allocation. */
void
@@ -403,8 +429,6 @@ malloc_init (start, warn_func)
POINTER start;
void (*warn_func) ();
{
- static int malloc_initialized = 0;
-
if (start)
data_space_start = start;