2 |
- |
1 |
/* Copyright (C) 1993, 1994, 1999 Aladdin Enterprises. All rights reserved.
|
|
|
2 |
|
|
|
3 |
This software is provided AS-IS with no warranty, either express or
|
|
|
4 |
implied.
|
|
|
5 |
|
|
|
6 |
This software is distributed under license and may not be copied,
|
|
|
7 |
modified or distributed except as expressly authorized under the terms
|
|
|
8 |
of the license contained in the file LICENSE in this distribution.
|
|
|
9 |
|
|
|
10 |
For more information about licensing, please refer to
|
|
|
11 |
http://www.ghostscript.com/licensing/. For information on
|
|
|
12 |
commercial licensing, go to http://www.artifex.com/licensing/ or
|
|
|
13 |
contact Artifex Software, Inc., 101 Lucas Valley Road #110,
|
|
|
14 |
San Rafael, CA 94903, U.S.A., +1(415)492-9861.
|
|
|
15 |
*/
|
|
|
16 |
|
|
|
17 |
/* $Id: imemory.h,v 1.5 2002/06/16 04:47:10 lpd Exp $ */
|
|
|
18 |
/* Ghostscript memory allocator extensions for interpreter level */
|
|
|
19 |
|
|
|
20 |
#ifndef imemory_INCLUDED
|
|
|
21 |
# define imemory_INCLUDED
|
|
|
22 |
|
|
|
23 |
#include "ivmspace.h"
|
|
|
24 |
|
|
|
25 |
/*
|
|
|
26 |
* The interpreter level of Ghostscript defines a "subclass" extension
|
|
|
27 |
* of the allocator interface in gsmemory.h, by adding the ability to
|
|
|
28 |
* allocate and free arrays of refs, and by adding the distinction
|
|
|
29 |
* between local, global, and system allocation.
|
|
|
30 |
*/
|
|
|
31 |
|
|
|
32 |
#include "gsalloc.h"
|
|
|
33 |
|
|
|
34 |
#ifndef gs_ref_memory_DEFINED
|
|
|
35 |
# define gs_ref_memory_DEFINED
|
|
|
36 |
typedef struct gs_ref_memory_s gs_ref_memory_t;
|
|
|
37 |
#endif
|
|
|
38 |
|
|
|
39 |
/* Allocate a ref array. */
|
|
|
40 |
|
|
|
41 |
int gs_alloc_ref_array(gs_ref_memory_t * mem, ref * paref,
|
|
|
42 |
uint attrs, uint num_refs, client_name_t cname);
|
|
|
43 |
|
|
|
44 |
/* Resize a ref array. */
|
|
|
45 |
/* Currently this is only implemented for shrinking, */
|
|
|
46 |
/* not growing. */
|
|
|
47 |
|
|
|
48 |
int gs_resize_ref_array(gs_ref_memory_t * mem, ref * paref,
|
|
|
49 |
uint new_num_refs, client_name_t cname);
|
|
|
50 |
|
|
|
51 |
/* Free a ref array. */
|
|
|
52 |
|
|
|
53 |
void gs_free_ref_array(gs_ref_memory_t * mem, ref * paref,
|
|
|
54 |
client_name_t cname);
|
|
|
55 |
|
|
|
56 |
/* Allocate a string ref. */
|
|
|
57 |
|
|
|
58 |
int gs_alloc_string_ref(gs_ref_memory_t * mem, ref * psref,
|
|
|
59 |
uint attrs, uint nbytes, client_name_t cname);
|
|
|
60 |
|
|
|
61 |
/* Register a ref root. This just calls gs_register_root. */
|
|
|
62 |
/* Note that ref roots are a little peculiar: they assume that */
|
|
|
63 |
/* the ref * that they point to points to a *statically* allocated ref. */
|
|
|
64 |
int gs_register_ref_root(gs_memory_t *mem, gs_gc_root_t *root,
|
|
|
65 |
void **pp, client_name_t cname);
|
|
|
66 |
|
|
|
67 |
|
|
|
68 |
/*
|
|
|
69 |
* The interpreter allocator can allocate in either local or global VM,
|
|
|
70 |
* and can switch between the two dynamically. In Level 1 configurations,
|
|
|
71 |
* global VM is the same as local; however, this is *not* currently true in
|
|
|
72 |
* a Level 2 system running in Level 1 mode. In addition, there is a third
|
|
|
73 |
* VM space, system VM, that exists in both modes and is used for objects
|
|
|
74 |
* that must not be affected by even the outermost save/restore (stack
|
|
|
75 |
* segments and names).
|
|
|
76 |
*
|
|
|
77 |
* NOTE: since the interpreter's (only) instances of gs_dual_memory_t are
|
|
|
78 |
* embedded in-line in context state structures, pointers to these
|
|
|
79 |
* instances must not be stored anywhere that might persist across a
|
|
|
80 |
* garbage collection.
|
|
|
81 |
*/
|
|
|
82 |
#ifndef gs_dual_memory_DEFINED
|
|
|
83 |
# define gs_dual_memory_DEFINED
|
|
|
84 |
typedef struct gs_dual_memory_s gs_dual_memory_t;
|
|
|
85 |
#endif
|
|
|
86 |
struct gs_dual_memory_s {
|
|
|
87 |
gs_ref_memory_t *current; /* = ...global or ...local */
|
|
|
88 |
vm_spaces spaces; /* system, global, local */
|
|
|
89 |
uint current_space; /* = current->space */
|
|
|
90 |
/* Garbage collection hook */
|
|
|
91 |
int (*reclaim) (gs_dual_memory_t *, int);
|
|
|
92 |
/* Masks for store checking, see isave.h. */
|
|
|
93 |
uint test_mask;
|
|
|
94 |
uint new_mask;
|
|
|
95 |
};
|
|
|
96 |
|
|
|
97 |
#define public_st_gs_dual_memory() /* in ialloc.c */\
|
|
|
98 |
gs_public_st_simple(st_gs_dual_memory, gs_dual_memory_t, "gs_dual_memory_t")
|
|
|
99 |
#define st_gs_dual_memory_num_ptrs 0
|
|
|
100 |
|
|
|
101 |
#endif /* imemory_INCLUDED */
|