aboutsummaryrefslogtreecommitdiffstats
path: root/src/ralloc.c
diff options
context:
space:
mode:
authorPaul Eggert2012-04-21 17:53:32 -0700
committerPaul Eggert2012-04-21 17:53:32 -0700
commitbbd347f5f7e99da1a559dad818b5fa8f59c0901e (patch)
tree77c1fc54c2240b08d2859109d18cac8812a8ffb1 /src/ralloc.c
parente4ecdc9c71af4199129d5dd2db1a32ff6b725fe4 (diff)
parent9ee7d8b93cb143b473e6dffb708e777bc6fe5bd0 (diff)
downloademacs-bbd347f5f7e99da1a559dad818b5fa8f59c0901e.tar.gz
emacs-bbd347f5f7e99da1a559dad818b5fa8f59c0901e.zip
Merge from trunk.
Diffstat (limited to 'src/ralloc.c')
-rw-r--r--src/ralloc.c60
1 files changed, 1 insertions, 59 deletions
diff --git a/src/ralloc.c b/src/ralloc.c
index 896ad9f3155..4bb2f240438 100644
--- a/src/ralloc.c
+++ b/src/ralloc.c
@@ -95,10 +95,8 @@ static int extra_bytes;
95/* Macros for rounding. Note that rounding to any value is possible 95/* Macros for rounding. Note that rounding to any value is possible
96 by changing the definition of PAGE. */ 96 by changing the definition of PAGE. */
97#define PAGE (getpagesize ()) 97#define PAGE (getpagesize ())
98#define ALIGNED(addr) (((unsigned long int) (addr) & (page_size - 1)) == 0)
99#define ROUNDUP(size) (((unsigned long int) (size) + page_size - 1) \ 98#define ROUNDUP(size) (((unsigned long int) (size) + page_size - 1) \
100 & ~(page_size - 1)) 99 & ~(page_size - 1))
101#define ROUND_TO_PAGE(addr) (addr & (~(page_size - 1)))
102 100
103#define MEM_ALIGN sizeof (double) 101#define MEM_ALIGN sizeof (double)
104#define MEM_ROUNDUP(addr) (((unsigned long int)(addr) + MEM_ALIGN - 1) \ 102#define MEM_ROUNDUP(addr) (((unsigned long int)(addr) + MEM_ALIGN - 1) \
@@ -151,7 +149,6 @@ typedef struct heap
151} *heap_ptr; 149} *heap_ptr;
152 150
153#define NIL_HEAP ((heap_ptr) 0) 151#define NIL_HEAP ((heap_ptr) 0)
154#define HEAP_PTR_SIZE (sizeof (struct heap))
155 152
156/* This is the first heap object. 153/* This is the first heap object.
157 If we need additional heap objects, each one resides at the beginning of 154 If we need additional heap objects, each one resides at the beginning of
@@ -366,15 +363,6 @@ relinquish (void)
366 } 363 }
367 } 364 }
368} 365}
369
370/* Return the total size in use by relocating allocator,
371 above where malloc gets space. */
372
373long
374r_alloc_size_in_use (void)
375{
376 return (char *) break_value - (char *) virtual_break_value;
377}
378 366
379/* The meat - allocating, freeing, and relocating blocs. */ 367/* The meat - allocating, freeing, and relocating blocs. */
380 368
@@ -748,7 +736,7 @@ free_bloc (bloc_ptr bloc)
748 __morecore hook values - in particular, __default_morecore in the 736 __morecore hook values - in particular, __default_morecore in the
749 GNU malloc package. */ 737 GNU malloc package. */
750 738
751POINTER 739static POINTER
752r_alloc_sbrk (long int size) 740r_alloc_sbrk (long int size)
753{ 741{
754 register bloc_ptr b; 742 register bloc_ptr b;
@@ -1014,52 +1002,6 @@ r_re_alloc (POINTER *ptr, SIZE size)
1014 return *ptr; 1002 return *ptr;
1015} 1003}
1016 1004
1017/* Disable relocations, after making room for at least SIZE bytes
1018 of non-relocatable heap if possible. The relocatable blocs are
1019 guaranteed to hold still until thawed, even if this means that
1020 malloc must return a null pointer. */
1021
1022void
1023r_alloc_freeze (long int size)
1024{
1025 if (! r_alloc_initialized)
1026 r_alloc_init ();
1027
1028 /* If already frozen, we can't make any more room, so don't try. */
1029 if (r_alloc_freeze_level > 0)
1030 size = 0;
1031 /* If we can't get the amount requested, half is better than nothing. */
1032 while (size > 0 && r_alloc_sbrk (size) == 0)
1033 size /= 2;
1034 ++r_alloc_freeze_level;
1035 if (size > 0)
1036 r_alloc_sbrk (-size);
1037}
1038
1039void
1040r_alloc_thaw (void)
1041{
1042
1043 if (! r_alloc_initialized)
1044 r_alloc_init ();
1045
1046 if (--r_alloc_freeze_level < 0)
1047 abort ();
1048
1049 /* This frees all unused blocs. It is not too inefficient, as the resize
1050 and memcpy is done only once. Afterwards, all unreferenced blocs are
1051 already shrunk to zero size. */
1052 if (!r_alloc_freeze_level)
1053 {
1054 bloc_ptr *b = &first_bloc;
1055 while (*b)
1056 if (!(*b)->variable)
1057 free_bloc (*b);
1058 else
1059 b = &(*b)->next;
1060 }
1061}
1062
1063 1005
1064#if defined (emacs) && defined (DOUG_LEA_MALLOC) 1006#if defined (emacs) && defined (DOUG_LEA_MALLOC)
1065 1007