imemory.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /* Copyright (C) 1993, 1994, 1999 Aladdin Enterprises. All rights reserved.
  2. This file is part of AFPL Ghostscript.
  3. AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author or
  4. distributor accepts any responsibility for the consequences of using it, or
  5. for whether it serves any particular purpose or works at all, unless he or
  6. she says so in writing. Refer to the Aladdin Free Public License (the
  7. "License") for full details.
  8. Every copy of AFPL Ghostscript must include a copy of the License, normally
  9. in a plain ASCII text file named PUBLIC. The License grants you the right
  10. to copy, modify and redistribute AFPL Ghostscript, but only under certain
  11. conditions described in the License. Among other things, the License
  12. requires that the copyright notice and this notice be preserved on all
  13. copies.
  14. */
  15. /*$Id: imemory.h,v 1.2 2000/09/19 19:00:44 lpd Exp $ */
  16. /* Ghostscript memory allocator extensions for interpreter level */
  17. #ifndef imemory_INCLUDED
  18. # define imemory_INCLUDED
  19. #include "ivmspace.h"
  20. /*
  21. * The interpreter level of Ghostscript defines a "subclass" extension
  22. * of the allocator interface in gsmemory.h, by adding the ability to
  23. * allocate and free arrays of refs, and by adding the distinction
  24. * between local, global, and system allocation.
  25. */
  26. #include "gsalloc.h"
  27. #ifndef gs_ref_memory_DEFINED
  28. # define gs_ref_memory_DEFINED
  29. typedef struct gs_ref_memory_s gs_ref_memory_t;
  30. #endif
  31. /* Allocate a ref array. */
  32. int gs_alloc_ref_array(P5(gs_ref_memory_t * mem, ref * paref,
  33. uint attrs, uint num_refs, client_name_t cname));
  34. /* Resize a ref array. */
  35. /* Currently this is only implemented for shrinking, */
  36. /* not growing. */
  37. int gs_resize_ref_array(P4(gs_ref_memory_t * mem, ref * paref,
  38. uint new_num_refs, client_name_t cname));
  39. /* Free a ref array. */
  40. void gs_free_ref_array(P3(gs_ref_memory_t * mem, ref * paref,
  41. client_name_t cname));
  42. /* Allocate a string ref. */
  43. int gs_alloc_string_ref(P5(gs_ref_memory_t * mem, ref * psref,
  44. uint attrs, uint nbytes, client_name_t cname));
  45. /* Register a ref root. This just calls gs_register_root. */
  46. /* Note that ref roots are a little peculiar: they assume that */
  47. /* the ref * that they point to points to a *statically* allocated ref. */
  48. int gs_register_ref_root(P4(gs_memory_t *mem, gs_gc_root_t *root,
  49. void **pp, client_name_t cname));
  50. /*
  51. * The interpreter allocator can allocate in either local or global VM,
  52. * and can switch between the two dynamically. In Level 1 configurations,
  53. * global VM is the same as local; however, this is *not* currently true in
  54. * a Level 2 system running in Level 1 mode. In addition, there is a third
  55. * VM space, system VM, that exists in both modes and is used for objects
  56. * that must not be affected by even the outermost save/restore (stack
  57. * segments and names).
  58. *
  59. * NOTE: since the interpreter's (only) instances of gs_dual_memory_t are
  60. * embedded in-line in context state structures, pointers to these
  61. * instances must not be stored anywhere that might persist across a
  62. * garbage collection.
  63. */
  64. #ifndef gs_dual_memory_DEFINED
  65. # define gs_dual_memory_DEFINED
  66. typedef struct gs_dual_memory_s gs_dual_memory_t;
  67. #endif
  68. struct gs_dual_memory_s {
  69. gs_ref_memory_t *current; /* = ...global or ...local */
  70. vm_spaces spaces; /* system, global, local */
  71. uint current_space; /* = current->space */
  72. /* Garbage collection hook */
  73. int (*reclaim) (P2(gs_dual_memory_t *, int));
  74. /* Masks for store checking, see isave.h. */
  75. uint test_mask;
  76. uint new_mask;
  77. };
  78. #define public_st_gs_dual_memory() /* in ialloc.c */\
  79. gs_public_st_simple(st_gs_dual_memory, gs_dual_memory_t, "gs_dual_memory_t")
  80. #define st_gs_dual_memory_num_ptrs 0
  81. #endif /* imemory_INCLUDED */