Subversion Repositories planix.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
/* Copyright (C) 1992, 1995, 1997, 1998, 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: isdata.h,v 1.4 2002/02/21 22:24:53 giles Exp $ */
18
/* Structure for expandable stacks of refs */
19
/* Requires iref.h */
20
 
21
#ifndef isdata_INCLUDED
22
#  define isdata_INCLUDED
23
 
24
/*
25
 * In order to detect under- and overflow with minimum overhead, we put
26
 * guard elements at the top and bottom of each stack block (see idsdata.h,
27
 * iesdata.h, and iosdata.h for details of the individual stacks).  Note that
28
 * the 'current' and 'next' arrays include the guard elements.  See
29
 * istack.h for the details of stack blocks.
30
 */
31
 
32
/*
33
 * The garbage collector requires that the entire contents of every block
34
 * be 'clean', i.e., contain legitimate refs; we also need to ensure that
35
 * at GC time, pointers in unused areas of a block will not be followed
36
 * (since they may be dangling).  We ensure this as follows:
37
 *      - When allocating a new block, we set the entire body to nulls.
38
 *      This is necessary because the block may be freed before the next GC,
39
 *      and the GC must be able to scan (parse) refs even if they are free.
40
 *      - When adding a new block to the top of the stack, we set to nulls
41
 *      the unused area of the new next-to-top blocks.
42
 *      - At the beginning of garbage collection, we set to nulls the unused
43
 *      elements of the top block.
44
 */
45
 
46
/*
47
 * Define pointers into stacks.  Formerly, these were short (unsegmented)
48
 * pointers, but this distinction is no longer needed.
49
 */
50
typedef ref *s_ptr;
51
typedef const ref *const_s_ptr;
52
 
53
/* Define an opaque allocator type. */
54
#ifndef gs_ref_memory_DEFINED
55
#  define gs_ref_memory_DEFINED
56
typedef struct gs_ref_memory_s gs_ref_memory_t;
57
#endif
58
 
59
/*
60
 * Define the state of a stack, other than the data it holds.
61
 * Note that the total size of a stack cannot exceed max_uint,
62
 * because it has to be possible to copy a stack to a PostScript array.
63
 */
64
#ifndef ref_stack_DEFINED
65
typedef struct ref_stack_s ref_stack_t;	/* also defined in idebug.h */
66
#  define ref_stack_DEFINED
67
#endif
68
/*
69
 * We divide the stack structure into two parts: ref_stack_params_t, which
70
 * is set when the stack is created and (almost) never changed after that,
71
 * and ref_stack_t, which changes dynamically.
72
 */
73
typedef struct ref_stack_params_s ref_stack_params_t;
74
struct ref_stack_s {
75
    /* Following are updated dynamically. */
76
    s_ptr p;			/* current top element */
77
    /* Following are updated when adding or deleting blocks. */
78
    s_ptr bot;			/* bottommost valid element */
79
    s_ptr top;			/* topmost valid element = */
80
				/* bot + data_size */
81
    ref current;		/* t_array for current top block */
82
    uint extension_size;	/* total sizes of extn. blocks */
83
    uint extension_used;	/* total used sizes of extn. blocks */
84
    /* Following are updated rarely. */
85
    ref max_stack;		/* t_integer, Max...Stack user param */
86
    uint requested;		/* amount of last failing */
87
				/* push or pop request */
88
    uint margin;		/* # of slots to leave between limit */
89
				/* and top */
90
    uint body_size;		/* data_size - margin */
91
    /* Following are set only at initialization. */
92
    ref_stack_params_t *params;
93
    gs_ref_memory_t *memory;	/* allocator for params and blocks */
94
};
95
#define public_st_ref_stack()	/* in istack.c */\
96
  gs_public_st_complex_only(st_ref_stack, ref_stack_t, "ref_stack_t",\
97
    ref_stack_clear_marks, ref_stack_enum_ptrs, ref_stack_reloc_ptrs, 0)
98
#define st_ref_stack_num_ptrs 2	/* current, params */
99
 
100
#endif /* isdata_INCLUDED */