1 /* Copyright (C) 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: gsstype.h,v 1.6 2004/08/04 19:36:12 stefan Exp $ */ 18 /* Definition of structure type descriptors and extern_st */ 19 20 #ifndef gsstype_INCLUDED 21 # define gsstype_INCLUDED 22 23 /* Define an opaque type for the garbage collector state. */ 24 typedef struct gc_state_s gc_state_t; 25 26 /* 27 * Define the structure used to return an enumerated pointer. Ordinary 28 * object pointers use only the ptr element; strings also use size. 29 */ 30 typedef struct enum_ptr_s { 31 const void *ptr; 32 uint size; 33 } enum_ptr_t; 34 35 /* 36 * The first argument of enum_ptrs procedures formerly was not const *, and 37 * EV_CONST was defined as empty. Unfortunately, changing EV_CONST to const 38 * produced many compiler warnings from places that cast this argument to a 39 * non-const non-void pointer type. 40 */ 41 #define EV_CONST const 42 43 /* Define the procedures for structure types. */ 44 45 /* Clear the marks of a structure. */ 46 47 #define struct_proc_clear_marks(proc)\ 48 void proc(const gs_memory_t *cmem, void /*obj_header_t*/ *pre, uint size,\ 49 const gs_memory_struct_type_t *pstype) 50 51 /* Enumerate the pointers in a structure. */ 52 53 #define struct_proc_enum_ptrs(proc)\ 54 gs_ptr_type_t proc(const gs_memory_t *mem, EV_CONST void /*obj_header_t*/ *ptr, uint size,\ 55 int index, enum_ptr_t *pep, const gs_memory_struct_type_t *pstype,\ 56 gc_state_t *gcst) 57 58 /* Relocate all the pointers in this structure. */ 59 60 #define struct_proc_reloc_ptrs(proc)\ 61 void proc(void /*obj_header_t*/ *ptr, uint size,\ 62 const gs_memory_struct_type_t *pstype, gc_state_t *gcst) 63 64 /* 65 * Finalize this structure just before freeing it. 66 * Finalization procedures must not allocate or resize 67 * any objects in any space managed by the allocator, 68 * and must not assume that any objects in such spaces 69 * referenced by this structure still exist. However, 70 * finalization procedures may free such objects, and 71 * may allocate, free, and reference objects allocated 72 * in other ways, such as objects allocated with malloc 73 * by libraries. 74 */ 75 76 #define struct_proc_finalize(proc)\ 77 void proc(void /*obj_header_t*/ *ptr) 78 79 /* 80 * A descriptor for an object (structure) type. 81 */ 82 typedef struct struct_shared_procs_s struct_shared_procs_t; 83 84 struct gs_memory_struct_type_s { 85 uint ssize; 86 struct_name_t sname; 87 88 /* ------ Procedures shared among many structure types. ------ */ 89 /* Note that this pointer is usually 0. */ 90 91 const struct_shared_procs_t *shared; 92 93 /* ------ Procedures specific to this structure type. ------ */ 94 95 struct_proc_clear_marks((*clear_marks)); 96 struct_proc_enum_ptrs((*enum_ptrs)); 97 struct_proc_reloc_ptrs((*reloc_ptrs)); 98 struct_proc_finalize((*finalize)); 99 100 /* A pointer to additional data for the above procedures. */ 101 102 const void *proc_data; 103 }; 104 105 /* 106 * Because of bugs in some compilers' bookkeeping for undefined structure 107 * types, any file that uses extern_st must include this file. 108 * (If it weren't for these bugs, the definition of extern_st could 109 * go in gsmemory.h.) 110 */ 111 #define extern_st(st) extern const gs_memory_struct_type_t st 112 113 #endif /* gsstype_INCLUDED */ 114