source: trunk/gcc/boehm-gc/stubborn.c@ 2700

Last change on this file since 2700 was 2, checked in by bird, 23 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 8.8 KB
Line 
1/*
2 * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
3 * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
4 *
5 * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
6 * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
7 *
8 * Permission is hereby granted to use or copy this program
9 * for any purpose, provided the above notices are retained on all copies.
10 * Permission to modify the code and to distribute modified code is granted,
11 * provided the above notices are retained, and a notice that the code was
12 * modified is included with the above copyright notice.
13 */
14/* Boehm, July 31, 1995 5:02 pm PDT */
15
16
17#include "private/gc_priv.h"
18
19# ifdef STUBBORN_ALLOC
20/* Stubborn object (hard to change, nearly immutable) allocation. */
21
22extern ptr_t GC_clear_stack(); /* in misc.c, behaves like identity */
23
24#define GENERAL_MALLOC(lb,k) \
25 (GC_PTR)GC_clear_stack(GC_generic_malloc((word)lb, k))
26
27/* Data structure representing immutable objects that */
28/* are still being initialized. */
29/* This is a bit baroque in order to avoid acquiring */
30/* the lock twice for a typical allocation. */
31
32GC_PTR * GC_changing_list_start;
33
34void GC_push_stubborn_structures GC_PROTO((void))
35{
36 GC_push_all((ptr_t)(&GC_changing_list_start),
37 (ptr_t)(&GC_changing_list_start) + sizeof(GC_PTR *));
38}
39
40# ifdef THREADS
41 VOLATILE GC_PTR * VOLATILE GC_changing_list_current;
42# else
43 GC_PTR * GC_changing_list_current;
44# endif
45 /* Points at last added element. Also (ab)used for */
46 /* synchronization. Updates and reads are assumed atomic. */
47
48GC_PTR * GC_changing_list_limit;
49 /* Points at the last word of the buffer, which is always 0 */
50 /* All entries in (GC_changing_list_current, */
51 /* GC_changing_list_limit] are 0 */
52
53
54void GC_stubborn_init()
55{
56# define INIT_SIZE 10
57
58 GC_changing_list_start = (GC_PTR *)
59 GC_INTERNAL_MALLOC(
60 (word)(INIT_SIZE * sizeof(GC_PTR)),
61 PTRFREE);
62 BZERO(GC_changing_list_start,
63 INIT_SIZE * sizeof(GC_PTR));
64 if (GC_changing_list_start == 0) {
65 GC_err_printf0("Insufficient space to start up\n");
66 ABORT("GC_stubborn_init: put of space");
67 }
68 GC_changing_list_current = GC_changing_list_start;
69 GC_changing_list_limit = GC_changing_list_start + INIT_SIZE - 1;
70 * GC_changing_list_limit = 0;
71}