1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677
|
/* Copyright (C) 1993, 1996, 1997 Aladdin Enterprises. All rights reserved.
This file is part of GNU Ghostscript.
GNU Ghostscript is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY. No author or distributor accepts responsibility to
anyone for the consequences of using it or for whether it serves any
particular purpose or works at all, unless he says so in writing. Refer to
the GNU General Public License for full details.
Everyone is granted permission to copy, modify and redistribute GNU
Ghostscript, but only under the conditions described in the GNU General
Public License. A copy of this license is supposed to have been given to
you along with GNU Ghostscript so you can know your rights and
responsibilities. It should be in a file named COPYING. Among other
things, the copyright notice and this notice must be preserved on all
copies.
Aladdin Enterprises is not affiliated with the Free Software Foundation or
the GNU Project. GNU Ghostscript, as distributed by Aladdin Enterprises,
does not depend on any other GNU software.
*/
/* gsstruct.h */
/* Definitions for Ghostscript modules that define allocatable structures */
/* Requires gstypes.h */
#ifndef gsstruct_INCLUDED
# define gsstruct_INCLUDED
/*
* Ghostscript structures are defined with names of the form (gs_)xxx_s,
* with a corresponding typedef of the form (gs_)xxx or (gs_)xxx_t.
* By extension, the structure descriptor is named st_[gs_]xxx.
* (Note that the descriptor name may omit the gs_ even if the type has it.)
* Structure descriptors are always allocated statically and are
* always const; they may be either public or private.
*
* In order to ensure that there is a descriptor for each structure type,
* we require, by convention, that the following always appear together
* if the structure is defined in a .h file:
* - The definition of the structure xxx_s;
* - If the descriptor is public, an extern_st(st_xxx);
* - The definition of a macro public_st_xxx() or private_st_xxx()
* that creates the actual descriptor.
* This convention makes the descriptor visible (if public) to any module
* that can see the structure definition. This is more liberal than
* we would like, but it is a reasonable compromise between restricting
* visibility and keeping all the definitional elements of a structure
* together. We require that there be no other externs for (public)
* structure descriptors; if the definer of a structure wants to make
* available the ability to create an instance but does not want to
* expose the structure definition, it must export a creator procedure.
*
* Because of bugs in some compilers' bookkeeping for undefined structure
* types, any file that uses extern_st must include gsstruct.h.
* (If it weren't for these bugs, the definition of extern_st could
* go in gsmemory.h.)
*/
#define extern_st(st) extern const gs_memory_struct_type_t st
/*
* If the structure is defined in a .c file, we require that the following
* appear together:
* - The definition of the structure xxx_s;
* - The gs_private_st_xxx macro that creates the descriptor.
* Note that we only allow this if the structure is completely private
* to a single file. Again, the file must export a creator procedure
* if it wants external clients to be able to create instances.
*
* Some structures are embedded inside others. In order to be able to
* construct the composite pointer enumeration procedures, for such
* structures we must define not only the st_xxx descriptor, but also
* a st_xxx_max_ptrs constant that gives the maximum number of pointers
* the enumeration procedure will return. This is an unfortunate consequence
* of the method we have chosen for implementing pointer enumeration.
*
* Some structures may exist as elements of homogenous arrays.
* In order to be able to enumerate and relocate such arrays, we adopt
* the convention that the structure representing an element must be
* distinguished from the structure per se, and the name of the element
* structure always ends with "_element". Element structures cannot be
* embedded in other structures.
*
* Note that the definition of the xxx_s structure may be separate from
* the typedef for the type xxx(_t). This still allows us to have full
* structure type abstraction.
*
* Descriptor definitions are not required for structures to which
* no traceable pointers from garbage-collectable space will ever exist.
* For example, the struct that defines structure types themselves does not
* require a descriptor.
*/
/* An opaque type for an object header. */
#ifndef obj_header_DEFINED
# define obj_header_DEFINED
typedef struct obj_header_s obj_header_t;
#endif
/*
* A descriptor for an object (structure) type.
*/
typedef struct struct_shared_procs_s struct_shared_procs_t;
struct gs_memory_struct_type_s {
uint ssize;
struct_name_t sname;
/* ------ Procedures shared among many structure types. ------ */
/* Note that this pointer is usually 0. */
const struct_shared_procs_t _ds *shared;
/* ------ Procedures specific to this structure type. ------ */
/* Note that these procedures may be 0. */
/* Clear the marks of a structure. */
#define struct_proc_clear_marks(proc)\
void proc(P2(void /*obj_header_t*/ *pre, uint size))
struct_proc_clear_marks((*clear_marks));
/* Enumerate the pointers in a structure. */
#define struct_proc_enum_ptrs(proc)\
gs_ptr_type_t proc(P4(void /*obj_header_t*/ *ptr, uint size, uint index,\
const void **pep))
struct_proc_enum_ptrs((*enum_ptrs));
/* Relocate all the pointers in this structure. */
#define struct_proc_reloc_ptrs(proc)\
void proc(P3(void /*obj_header_t*/ *ptr, uint size, gc_state_t *gcst))
struct_proc_reloc_ptrs((*reloc_ptrs));
/*
* Finalize this structure just before freeing it.
* Finalization procedures must not allocate or resize
* any objects in any space managed by the allocator,
* and must not assume that any objects in such spaces
* referenced by this structure still exist. However,
* finalization procedures may free such objects, and
* may allocate, free, and reference objects allocated
* in other ways, such as objects allocated with malloc
* by libraries.
*/
#define struct_proc_finalize(proc)\
void proc(P1(void /*obj_header_t*/ *ptr))
struct_proc_finalize((*finalize));
};
#define struct_type_name_string(pstype) ((const char *)((pstype)->sname))
/* Default pointer processing */
struct_proc_enum_ptrs(gs_no_struct_enum_ptrs);
struct_proc_reloc_ptrs(gs_no_struct_reloc_ptrs);
/* Standard relocation procedures */
ptr_proc_reloc(gs_reloc_struct_ptr, void /*obj_header_t*/);
void gs_reloc_string(P2(gs_string *, gc_state_t *));
void gs_reloc_const_string(P2(gs_const_string *, gc_state_t *));
/* Define a 'type' descriptor for free blocks. */
extern_st(st_free);
/* Define a type descriptor for byte objects. */
extern_st(st_bytes);
/* Define type descriptors for elements and arrays of const strings. */
#define private_st_const_string()\
gs_private_st_composite(st_const_string, gs_const_string, "gs_const_string",\
const_string_enum_ptrs, const_string_reloc_ptrs)
extern_st(st_const_string_element);
#define public_st_const_string_element()\
gs_public_st_element(st_const_string_element, gs_const_string,\
"gs_const_string[]", const_string_elt_enum_ptrs,\
const_string_elt_reloc_ptrs, st_const_string)
/* ================ Macros for defining structure types ================ */
#define public_st public const gs_memory_struct_type_t
#define private_st private const gs_memory_struct_type_t
/* -------------- Simple structures (no internal pointers). -------------- */
#define gs__st_simple(scope_st, stname, stype, sname)\
scope_st stname = { sizeof(stype), sname, 0, 0, 0, 0, 0 }
#define gs_public_st_simple(stname, stype, sname)\
gs__st_simple(public_st, stname, stype, sname)
#define gs_private_st_simple(stname, stype, sname)\
gs__st_simple(private_st, stname, stype, sname)
/* ---------------- Structures with explicit procedures. ---------------- */
/* Complex structures with their own clear_marks, */
/* enum, reloc, and finalize procedures. */
#define gs__st_complex_only(scope_st, stname, stype, sname, pclear, penum, preloc, pfinal)\
scope_st stname = { sizeof(stype), sname, 0, pclear, penum, preloc, pfinal }
#define gs_public_st_complex_only(stname, stype, sname, pclear, penum, preloc, pfinal)\
gs__st_complex_only(public_st, stname, stype, sname, pclear, penum, preloc, pfinal)
#define gs_private_st_complex_only(stname, stype, sname, pclear, penum, preloc, pfinal)\
gs__st_complex_only(private_st, stname, stype, sname, pclear, penum, preloc, pfinal)
#define gs__st_complex(scope_st, stname, stype, sname, pclear, penum, preloc, pfinal)\
private struct_proc_clear_marks(pclear);\
private struct_proc_enum_ptrs(penum);\
private struct_proc_reloc_ptrs(preloc);\
private struct_proc_finalize(pfinal);\
gs__st_complex_only(scope_st, stname, stype, sname, pclear, penum, preloc, pfinal)
#define gs_public_st_complex(stname, stype, sname, pclear, penum, preloc, pfinal)\
gs__st_complex(public_st, stname, stype, sname, pclear, penum, preloc, pfinal)
#define gs_private_st_complex(stname, stype, sname, pclear, penum, preloc, pfinal)\
gs__st_complex(private_st, stname, stype, sname, pclear, penum, preloc, pfinal)
/* Composite structures with their own enum and reloc procedures. */
#define gs__st_composite(scope_st, stname, stype, sname, penum, preloc)\
private struct_proc_enum_ptrs(penum);\
private struct_proc_reloc_ptrs(preloc);\
gs__st_complex_only(scope_st, stname, stype, sname, 0, penum, preloc, 0)
#define gs_public_st_composite(stname, stype, sname, penum, preloc)\
gs__st_composite(public_st, stname, stype, sname, penum, preloc)
#define gs_private_st_composite(stname, stype, sname, penum, preloc)\
gs__st_composite(private_st, stname, stype, sname, penum, preloc)
/* Composite structures with finalization. */
#define gs__st_composite_final(scope_st, stname, stype, sname, penum, preloc, pfinal)\
private struct_proc_enum_ptrs(penum);\
private struct_proc_reloc_ptrs(preloc);\
private struct_proc_finalize(pfinal);\
gs__st_complex_only(scope_st, stname, stype, sname, 0, penum, preloc, pfinal)
#define gs_public_st_composite_final(stname, stype, sname, penum, preloc, pfinal)\
gs__st_composite_final(public_st, stname, stype, sname, penum, preloc, pfinal)
#define gs_private_st_composite_final(stname, stype, sname, penum, preloc, pfinal)\
gs__st_composite_final(private_st, stname, stype, sname, penum, preloc, pfinal)
/* Composite structures with enum and reloc procedures */
/* already declared. */
#define gs__st_composite_only(scope_st, stname, stype, sname, penum, preloc)\
gs__st_complex_only(scope_st, stname, stype, sname, 0, penum, preloc, 0)
#define gs_public_st_composite_only(stname, stype, sname, penum, preloc)\
gs__st_composite_only(public_st, stname, stype, sname, penum, preloc)
#define gs_private_st_composite_only(stname, stype, sname, penum, preloc)\
gs__st_composite_only(private_st, stname, stype, sname, penum, preloc)
/* ---------------- Special kinds of structures ---------------- */
/* Element structures, for use in arrays of structures. */
/* Note that these require that the underlying structure's */
/* enum_ptrs procedure always return the same number of pointers. */
#define gs__st_element(scope_st, stname, stype, sname, penum, preloc, basest)\
private ENUM_PTRS_BEGIN_PROC(penum) {\
uint count = size / (uint)sizeof(stype);\
if ( count == 0 ) return 0;\
return (*basest.enum_ptrs)((char *)vptr + (index % count) * sizeof(stype),\
sizeof(stype), index / count, pep);\
} ENUM_PTRS_END_PROC\
private RELOC_PTRS_BEGIN(preloc) {\
uint count = size / (uint)sizeof(stype);\
for ( ; count; count--, vptr = (char *)vptr + sizeof(stype) )\
(*basest.reloc_ptrs)(vptr, sizeof(stype), gcst);\
} RELOC_PTRS_END\
gs__st_composite_only(scope_st, stname, stype, sname, penum, preloc)
#define gs_public_st_element(stname, stype, sname, penum, preloc, basest)\
gs__st_element(public_st, stname, stype, sname, penum, preloc, basest)
#define gs_private_st_element(stname, stype, sname, penum, preloc, basest)\
gs__st_element(private_st, stname, stype, sname, penum, preloc, basest)
/* A "structure" just consisting of a pointer. */
/* Note that in this case only, stype is a pointer type. */
#define gs__st_ptr(scope_st, stname, stype, sname, penum, preloc)\
private ENUM_PTRS_BEGIN(penum) return 0;\
case 0: *pep = (const void *)*(stype *)vptr; return ptr_struct_type;\
ENUM_PTRS_END\
private RELOC_PTRS_BEGIN(preloc) ;\
*(stype *)vptr = gs_reloc_struct_ptr((const void *)*(stype *)vptr, gcst);\
RELOC_PTRS_END\
gs__st_composite_only(scope_st, stname, stype, sname, penum, preloc)
#define gs_public_st_ptr(stname, stype, sname, penum, preloc)\
gs__st_ptr(public_st, stname, stype, sname, penum, preloc)
#define gs_private_st_ptr(stname, stype, sname, penum, preloc)\
gs__st_ptr(private_st, stname, stype, sname, penum, preloc)
/* ---------------- Ordinary structures ---------------- */
/*
* The simplest kind of composite structure is one with a fixed set of
* pointers, each of which points to a struct. We provide macros for
* defining this kind of structure conveniently, either all at once in
* the structure definition macro, or using the following template:
ENUM_PTRS_BEGIN(xxx_enum_ptrs) return 0;
... ENUM_PTR(i, xxx, elt); ...
ENUM_PTRS_END
RELOC_PTRS_BEGIN(xxx_reloc_ptrs) ;
... RELOC_PTR(xxx, elt) ...
RELOC_PTRS_END
*/
/*
* We have to pull the 'private' outside the ENUM_PTRS_BEGIN and
* RELOC_PTRS_BEGIN macros because of a bug in the Borland C++ preprocessor.
* We also have to make sure there is more on the line after these
* macros, so as not to confuse ansi2knr.
*/
#ifdef __PROTOTYPES__
# define ENUM_PTRS_BEGIN_PROC(proc)\
gs_ptr_type_t proc(void *vptr, uint size, uint index, const void **pep)
#else
# define ENUM_PTRS_BEGIN_PROC(proc)\
gs_ptr_type_t proc(vptr, size, index, pep) void *vptr; uint size; uint index; const void **pep;
#endif
#define ENUM_PTRS_BEGIN(proc)\
ENUM_PTRS_BEGIN_PROC(proc) { switch ( index ) { default:
#define ENUM_PTR(i, typ, elt)\
case i: ENUM_RETURN_PTR(typ, elt)
#define ENUM_RETURN_PTR(typ, elt)\
ENUM_RETURN(((typ *)vptr)->elt)
#define ENUM_RETURN(ptr)\
do { *pep = (const void *)(ptr); return ptr_struct_type; } while (0)
#define ENUM_STRING_PTR(i, typ, elt)\
case i: ENUM_RETURN_STRING_PTR(typ, elt)
#define ENUM_RETURN_STRING_PTR(typ, elt)\
do { *pep = (const void *)&((typ *)vptr)->elt; return ptr_string_type; } while (0)
#define ENUM_CONST_STRING_PTR(i, typ, elt)\
case i: ENUM_RETURN_CONST_STRING_PTR(typ, elt)
#define ENUM_RETURN_CONST_STRING_PTR(typ, elt)\
do { *pep = (const void *)&((typ *)vptr)->elt; return ptr_const_string_type; } while (0)
#define ENUM_PTRS_END\
} /* mustn't fall through! */ ENUM_PTRS_END_PROC }
#define ENUM_PTRS_END_PROC /* */
#ifdef __PROTOTYPES__
# define RELOC_PTRS_BEGIN(proc)\
void proc(void *vptr, uint size, gc_state_t *gcst) {
#else
# define RELOC_PTRS_BEGIN(proc)\
void proc(vptr, size, gcst) void *vptr; uint size; gc_state_t *gcst; {
#endif
#define RELOC_PTR(typ, elt)\
((typ *)vptr)->elt =\
gs_reloc_struct_ptr((const void *)((const typ *)vptr)->elt, gcst)
/* Relocate a pointer that points to a known offset within an object. */
/* OFFSET is for byte offsets, TYPED_OFFSET is for element offsets. */
#define RELOC_OFFSET_PTR(typ, elt, offset)\
((typ *)vptr)->elt = (void *)\
((char *)gs_reloc_struct_ptr((char *)((typ *)vptr)->elt - (offset), gcst) +\
(offset))
#define RELOC_TYPED_OFFSET_PTR(typ, elt, offset)\
(((typ *)vptr)->elt = (void *)\
gs_reloc_struct_ptr(((typ *)vptr)->elt - (offset), gcst),\
((typ *)vptr)->elt += (offset))
#define RELOC_STRING_PTR(typ, elt)\
gs_reloc_string(&((typ *)vptr)->elt, gcst)
#define RELOC_CONST_STRING_PTR(typ, elt)\
gs_reloc_const_string(&((typ *)vptr)->elt, gcst)
#define RELOC_PTRS_END\
}
/*
* Boilerplate for clear_marks procedures.
*/
#ifdef __PROTOTYPES__
# define CLEAR_MARKS_PROC(proc)\
void proc(void *vptr, uint size)
#else
# define CLEAR_MARKS_PROC(proc)\
void proc(vptr, size) void *vptr; uint size;
#endif
/* ---------------- Structures with a fixed set of pointers ---------------- */
/* Structures with 1 pointer. */
#define gs__st_ptrs1(scope_st, stname, stype, sname, penum, preloc, e1)\
private ENUM_PTRS_BEGIN(penum) return 0;\
ENUM_PTR(0,stype,e1);\
ENUM_PTRS_END\
private RELOC_PTRS_BEGIN(preloc) ;\
RELOC_PTR(stype,e1);\
RELOC_PTRS_END\
gs__st_composite_only(scope_st, stname, stype, sname, penum, preloc)
#define gs_public_st_ptrs1(stname, stype, sname, penum, preloc, e1)\
gs__st_ptrs1(public_st, stname, stype, sname, penum, preloc, e1)
#define gs_private_st_ptrs1(stname, stype, sname, penum, preloc, e1)\
gs__st_ptrs1(private_st, stname, stype, sname, penum, preloc, e1)
/* Structures with 1 pointer and 1 string. */
#define gs__st_ptrs1_strings1(scope_st, stname, stype, sname, penum, preloc, e1, e2)\
private ENUM_PTRS_BEGIN(penum) return 0;\
ENUM_PTR(0,stype,e1); ENUM_STRING_PTR(1,stype,e2);\
ENUM_PTRS_END\
private RELOC_PTRS_BEGIN(preloc) ;\
RELOC_PTR(stype,e1); RELOC_STRING_PTR(stype,e2);\
RELOC_PTRS_END\
gs__st_composite_only(scope_st, stname, stype, sname, penum, preloc)
#define gs_public_st_ptrs1_strings1(stname, stype, sname, penum, preloc, e1, e2)\
gs__st_ptrs1_strings1(public_st, stname, stype, sname, penum, preloc, e1, e2)
#define gs_private_st_ptrs1_strings1(stname, stype, sname, penum, preloc, e1, e2)\
gs__st_ptrs1_strings1(private_st, stname, stype, sname, penum, preloc, e1, e2)
/* Structures with 2 pointers. */
#define gs__st_ptrs2(scope_st, stname, stype, sname, penum, preloc, e1, e2)\
private ENUM_PTRS_BEGIN(penum) return 0;\
ENUM_PTR(0,stype,e1); ENUM_PTR(1,stype,e2);\
ENUM_PTRS_END\
private RELOC_PTRS_BEGIN(preloc) ;\
RELOC_PTR(stype,e1); RELOC_PTR(stype,e2);\
RELOC_PTRS_END\
gs__st_composite_only(scope_st, stname, stype, sname, penum, preloc)
#define gs_public_st_ptrs2(stname, stype, sname, penum, preloc, e1, e2)\
gs__st_ptrs2(public_st, stname, stype, sname, penum, preloc, e1, e2)
#define gs_private_st_ptrs2(stname, stype, sname, penum, preloc, e1, e2)\
gs__st_ptrs2(private_st, stname, stype, sname, penum, preloc, e1, e2)
/* Structures with 3 pointers. */
#define gs__st_ptrs3(scope_st, stname, stype, sname, penum, preloc, e1, e2, e3)\
private ENUM_PTRS_BEGIN(penum) return 0;\
ENUM_PTR(0,stype,e1); ENUM_PTR(1,stype,e2); ENUM_PTR(2,stype,e3);\
ENUM_PTRS_END\
private RELOC_PTRS_BEGIN(preloc) ;\
RELOC_PTR(stype,e1); RELOC_PTR(stype,e2); RELOC_PTR(stype,e3);\
RELOC_PTRS_END\
gs__st_composite_only(scope_st, stname, stype, sname, penum, preloc)
#define gs_public_st_ptrs3(stname, stype, sname, penum, preloc, e1, e2, e3)\
gs__st_ptrs3(public_st, stname, stype, sname, penum, preloc, e1, e2, e3)
#define gs_private_st_ptrs3(stname, stype, sname, penum, preloc, e1, e2, e3)\
gs__st_ptrs3(private_st, stname, stype, sname, penum, preloc, e1, e2, e3)
/* Structures with 4 pointers. */
#define gs__st_ptrs4(scope_st, stname, stype, sname, penum, preloc, e1, e2, e3, e4)\
private ENUM_PTRS_BEGIN(penum) return 0;\
ENUM_PTR(0,stype,e1); ENUM_PTR(1,stype,e2); ENUM_PTR(2,stype,e3);\
ENUM_PTR(3,stype,e4);\
ENUM_PTRS_END\
private RELOC_PTRS_BEGIN(preloc) ;\
RELOC_PTR(stype,e1); RELOC_PTR(stype,e2); RELOC_PTR(stype,e3);\
RELOC_PTR(stype,e4);\
RELOC_PTRS_END\
gs__st_composite_only(scope_st, stname, stype, sname, penum, preloc)
#define gs_public_st_ptrs4(stname, stype, sname, penum, preloc, e1, e2, e3, e4)\
gs__st_ptrs4(public_st, stname, stype, sname, penum, preloc, e1, e2, e3, e4)
#define gs_private_st_ptrs4(stname, stype, sname, penum, preloc, e1, e2, e3, e4)\
gs__st_ptrs4(private_st, stname, stype, sname, penum, preloc, e1, e2, e3, e4)
/* Structures with 5 pointers. */
#define gs__st_ptrs5(scope_st, stname, stype, sname, penum, preloc, e1, e2, e3, e4, e5)\
private ENUM_PTRS_BEGIN(penum) return 0;\
ENUM_PTR(0,stype,e1); ENUM_PTR(1,stype,e2); ENUM_PTR(2,stype,e3);\
ENUM_PTR(3,stype,e4); ENUM_PTR(4,stype,e5);\
ENUM_PTRS_END\
private RELOC_PTRS_BEGIN(preloc) ;\
RELOC_PTR(stype,e1); RELOC_PTR(stype,e2); RELOC_PTR(stype,e3);\
RELOC_PTR(stype,e4); RELOC_PTR(stype,e5);\
RELOC_PTRS_END\
gs__st_composite_only(scope_st, stname, stype, sname, penum, preloc)
#define gs_public_st_ptrs5(stname, stype, sname, penum, preloc, e1, e2, e3, e4, e5)\
gs__st_ptrs5(public_st, stname, stype, sname, penum, preloc, e1, e2, e3, e4, e5)
#define gs_private_st_ptrs5(stname, stype, sname, penum, preloc, e1, e2, e3, e4, e5)\
gs__st_ptrs5(private_st, stname, stype, sname, penum, preloc, e1, e2, e3, e4, e5)
/* ---------------- Suffix subclasses ---------------- */
/*
* Boilerplate for suffix subclasses. Special subclasses constructed
* 'by hand' may use this also.
*/
#define ENUM_PREFIX(supst, n)\
return (*supst.enum_ptrs)(vptr,size,index-(n),pep)
#define RELOC_PREFIX(supst)\
(*supst.reloc_ptrs)(vptr,size,gcst)
/* Suffix subclasses with no additional pointers. */
#define gs__st_suffix_add0(scope_st, stname, stype, sname, penum, preloc, supstname)\
private ENUM_PTRS_BEGIN_PROC(penum) {\
return (*supstname.enum_ptrs)(vptr, size, index, pep);\
} ENUM_PTRS_END_PROC\
private RELOC_PTRS_BEGIN(preloc) {\
(*supstname.reloc_ptrs)(vptr, size, gcst);\
} RELOC_PTRS_END\
gs__st_composite_only(scope_st, stname, stype, sname, penum, preloc)
#define gs_public_st_suffix_add0(stname, stype, sname, penum, preloc, supstname)\
gs__st_suffix_add0(public_st, stname, stype, sname, penum, preloc, supstname)
#define gs_private_st_suffix_add0(stname, stype, sname, penum, preloc, supstname)\
gs__st_suffix_add0(private_st, stname, stype, sname, penum, preloc, supstname)
/* Suffix subclasses with no additional pointers and finalization. */
/* This is a hack -- subclasses should inherit finalization, */
/* but that would require a superclass pointer in the descriptor, */
/* which would perturb things too much right now. */
#define gs__st_suffix_add0_final(scope_st, stname, stype, sname, penum, preloc, pfinal, supstname)\
private ENUM_PTRS_BEGIN_PROC(penum) {\
return (*supstname.enum_ptrs)(vptr, size, index, pep);\
} ENUM_PTRS_END_PROC\
private RELOC_PTRS_BEGIN(preloc) {\
(*supstname.reloc_ptrs)(vptr, size, gcst);\
} RELOC_PTRS_END\
gs__st_complex_only(scope_st, stname, stype, sname, 0, penum, preloc, pfinal)
#define gs_public_st_suffix_add0_final(stname, stype, sname, penum, preloc, pfinal, supstname)\
gs__st_suffix_add0_final(public_st, stname, stype, sname, penum, preloc, pfinal, supstname)
#define gs_private_st_suffix_add0_final(stname, stype, sname, penum, preloc, pfinal, supstname)\
gs__st_suffix_add0_final(private_st, stname, stype, sname, penum, preloc, pfinal, supstname)
/* Suffix subclasses with 1 additional pointer. */
#define gs__st_suffix_add1(scope_st, stname, stype, sname, penum, preloc, supstname, e1)\
private ENUM_PTRS_BEGIN(penum) ENUM_PREFIX(supstname,1);\
ENUM_PTR(0,stype,e1);\
ENUM_PTRS_END\
private RELOC_PTRS_BEGIN(preloc) RELOC_PREFIX(supstname);\
RELOC_PTR(stype,e1);\
RELOC_PTRS_END\
gs__st_composite_only(scope_st, stname, stype, sname, penum, preloc)
#define gs_public_st_suffix_add1(stname, stype, sname, penum, preloc, supstname, e1)\
gs__st_suffix_add1(public_st, stname, stype, sname, penum, preloc, supstname, e1)
#define gs_private_st_suffix_add1(stname, stype, sname, penum, preloc, supstname, e1)\
gs__st_suffix_add1(private_st, stname, stype, sname, penum, preloc, supstname, e1)
/* Suffix subclasses with 1 additional pointer and finalization. */
/* See above regarding finalization and subclasses. */
#define gs__st_suffix_add1_final(scope_st, stname, stype, sname, penum, preloc, pfinal, supstname, e1)\
private ENUM_PTRS_BEGIN(penum) ENUM_PREFIX(supstname,1);\
ENUM_PTR(0,stype,e1);\
ENUM_PTRS_END\
private RELOC_PTRS_BEGIN(preloc) RELOC_PREFIX(supstname);\
RELOC_PTR(stype,e1);\
RELOC_PTRS_END\
gs__st_complex_only(scope_st, stname, stype, sname, 0, penum, preloc, pfinal)
#define gs_public_st_suffix_add1_final(stname, stype, sname, penum, preloc, pfinal, supstname, e1)\
gs__st_suffix_add1_final(public_st, stname, stype, sname, penum, preloc, pfinal, supstname, e1)
#define gs_private_st_suffix_add1_final(stname, stype, sname, penum, preloc, pfinal, supstname, e1)\
gs__st_suffix_add1_final(private_st, stname, stype, sname, penum, preloc, pfinal, supstname, e1)
/* Suffix subclasses with 2 additional pointers. */
#define gs__st_suffix_add2(scope_st, stname, stype, sname, penum, preloc, supstname, e1, e2)\
private ENUM_PTRS_BEGIN(penum) ENUM_PREFIX(supstname,2);\
ENUM_PTR(0,stype,e1); ENUM_PTR(1,stype,e2);\
ENUM_PTRS_END\
private RELOC_PTRS_BEGIN(preloc) RELOC_PREFIX(supstname);\
RELOC_PTR(stype,e1); RELOC_PTR(stype,e2);\
RELOC_PTRS_END\
gs__st_composite_only(scope_st, stname, stype, sname, penum, preloc)
#define gs_public_st_suffix_add2(stname, stype, sname, penum, preloc, supstname, e1, e2)\
gs__st_suffix_add2(public_st, stname, stype, sname, penum, preloc, supstname, e1, e2)
#define gs_private_st_suffix_add2(stname, stype, sname, penum, preloc, supstname, e1, e2)\
gs__st_suffix_add2(private_st, stname, stype, sname, penum, preloc, supstname, e1, e2)
/* Suffix subclasses with 2 additional pointers and finalization. */
/* See above regarding finalization and subclasses. */
#define gs__st_suffix_add2_final(scope_st, stname, stype, sname, penum, preloc, pfinal, supstname, e1, e2)\
private ENUM_PTRS_BEGIN(penum) ENUM_PREFIX(supstname,2);\
ENUM_PTR(0,stype,e1); ENUM_PTR(1,stype,e2);\
ENUM_PTRS_END\
private RELOC_PTRS_BEGIN(preloc) RELOC_PREFIX(supstname);\
RELOC_PTR(stype,e1); RELOC_PTR(stype,e2);\
RELOC_PTRS_END\
gs__st_complex_only(scope_st, stname, stype, sname, 0, penum, preloc, pfinal)
#define gs_public_st_suffix_add2_final(stname, stype, sname, penum, preloc, pfinal, supstname, e1, e2)\
gs__st_suffix_add2_final(public_st, stname, stype, sname, penum, preloc, pfinal, supstname, e1, e2)
#define gs_private_st_suffix_add2_final(stname, stype, sname, penum, preloc, pfinal, supstname, e1, e2)\
gs__st_suffix_add2_final(private_st, stname, stype, sname, penum, preloc, pfinal, supstname, e1, e2)
/* Suffix subclasses with 3 additional pointers. */
#define gs__st_suffix_add3(scope_st, stname, stype, sname, penum, preloc, supstname, e1, e2, e3)\
private ENUM_PTRS_BEGIN(penum) ENUM_PREFIX(supstname,3);\
ENUM_PTR(0,stype,e1); ENUM_PTR(1,stype,e2); ENUM_PTR(2,stype,e3);\
ENUM_PTRS_END\
private RELOC_PTRS_BEGIN(preloc) RELOC_PREFIX(supstname);\
RELOC_PTR(stype,e1); RELOC_PTR(stype,e2); RELOC_PTR(stype,e3);\
RELOC_PTRS_END\
gs__st_composite_only(scope_st, stname, stype, sname, penum, preloc)
#define gs_public_st_suffix_add3(stname, stype, sname, penum, preloc, supstname, e1, e2, e3)\
gs__st_suffix_add3(public_st, stname, stype, sname, penum, preloc, supstname, e1, e2, e3)
#define gs_private_st_suffix_add3(stname, stype, sname, penum, preloc, supstname, e1, e2, e3)\
gs__st_suffix_add3(private_st, stname, stype, sname, penum, preloc, supstname, e1, e2, e3)
/* Suffix subclasses with 3 additional pointers and finalization. */
/* See above regarding finalization and subclasses. */
#define gs__st_suffix_add3_final(scope_st, stname, stype, sname, penum, preloc, pfinal, supstname, e1, e2, e3)\
private ENUM_PTRS_BEGIN(penum) ENUM_PREFIX(supstname,3);\
ENUM_PTR(0,stype,e1); ENUM_PTR(1,stype,e2); ENUM_PTR(2,stype,e3);\
ENUM_PTRS_END\
private RELOC_PTRS_BEGIN(preloc) RELOC_PREFIX(supstname);\
RELOC_PTR(stype,e1); RELOC_PTR(stype,e2); RELOC_PTR(stype,e3);\
RELOC_PTRS_END\
gs__st_complex_only(scope_st, stname, stype, sname, 0, penum, preloc, pfinal)
#define gs_public_st_suffix_add3_final(stname, stype, sname, penum, preloc, pfinal, supstname, e1, e2, e3)\
gs__st_suffix_add3_final(public_st, stname, stype, sname, penum, preloc, pfinal, supstname, e1, e2, e3)
#define gs_private_st_suffix_add3_final(stname, stype, sname, penum, preloc, pfinal, supstname, e1, e2, e3)\
gs__st_suffix_add3_final(private_st, stname, stype, sname, penum, preloc, pfinal, supstname, e1, e2, e3)
/* Suffix subclasses with 4 additional pointers. */
#define gs__st_suffix_add4(scope_st, stname, stype, sname, penum, preloc, supstname, e1, e2, e3, e4)\
private ENUM_PTRS_BEGIN(penum) ENUM_PREFIX(supstname,4);\
ENUM_PTR(0,stype,e1); ENUM_PTR(1,stype,e2); ENUM_PTR(2,stype,e3);\
ENUM_PTR(3,stype,e4);\
ENUM_PTRS_END\
private RELOC_PTRS_BEGIN(preloc) RELOC_PREFIX(supstname);\
RELOC_PTR(stype,e1); RELOC_PTR(stype,e2); RELOC_PTR(stype,e3);\
RELOC_PTR(stype,e4);\
RELOC_PTRS_END\
gs__st_composite_only(scope_st, stname, stype, sname, penum, preloc)
#define gs_public_st_suffix_add4(stname, stype, sname, penum, preloc, supstname, e1, e2, e3, e4)\
gs__st_suffix_add4(public_st, stname, stype, sname, penum, preloc, supstname, e1, e2, e3, e4)
#define gs_private_st_suffix_add4(stname, stype, sname, penum, preloc, supstname, e1, e2, e3, e4)\
gs__st_suffix_add4(private_st, stname, stype, sname, penum, preloc, supstname, e1, e2, e3, e4)
/* ---------------- General subclasses ---------------- */
/*
* Boilerplate for general subclasses.
*/
#define ENUM_SUPER(stype, supst, member, n)\
return (*supst.enum_ptrs)(&((stype *)vptr)->member, sizeof(((stype *)vptr)->member),\
index-(n), pep)
#define RELOC_SUPER(stype, supst, member)\
(*supst.reloc_ptrs)(&((stype *)vptr)->member, sizeof(((stype *)vptr)->member), gcst)
/* General subclasses with no additional pointers. */
#define gs__st_ptrs_add0(scope_st, stname, stype, sname, penum, preloc, supstname, member)\
private ENUM_PTRS_BEGIN(penum) ENUM_SUPER(stype,supstname,member,0);\
ENUM_PTRS_END\
private RELOC_PTRS_BEGIN(preloc) RELOC_SUPER(stype,supstname,member);\
RELOC_PTRS_END\
gs__st_composite_only(scope_st, stname, stype, sname, penum, preloc)
#define gs_public_st_ptrs_add0(stname, stype, sname, penum, preloc, supstname, member)\
gs__st_ptrs_add0(public_st, stname, stype, sname, penum, preloc, supstname, member)
#define gs_private_st_ptrs_add0(stname, stype, sname, penum, preloc, supstname, member)\
gs__st_ptrs_add0(private_st, stname, stype, sname, penum, preloc, supstname, member)
/* General subclasses with 1 additional pointer. */
#define gs__st_ptrs_add1(scope_st, stname, stype, sname, penum, preloc, supstname, member, e1)\
private ENUM_PTRS_BEGIN(penum) ENUM_SUPER(stype,supstname,member,1);\
ENUM_PTR(0,stype,e1);\
ENUM_PTRS_END\
private RELOC_PTRS_BEGIN(preloc) RELOC_SUPER(stype,supstname,member);\
RELOC_PTR(stype,e1);\
RELOC_PTRS_END\
gs__st_composite_only(scope_st, stname, stype, sname, penum, preloc)
#define gs_public_st_ptrs_add1(stname, stype, sname, penum, preloc, supstname, member, e1)\
gs__st_ptrs_add1(public_st, stname, stype, sname, penum, preloc, supstname, member, e1)
#define gs_private_st_ptrs_add1(stname, stype, sname, penum, preloc, supstname, member, e1)\
gs__st_ptrs_add1(private_st, stname, stype, sname, penum, preloc, supstname, member, e1)
/* General subclasses with 2 additional pointers. */
#define gs__st_ptrs_add2(scope_st, stname, stype, sname, penum, preloc, supstname, member, e1, e2)\
private ENUM_PTRS_BEGIN(penum) ENUM_SUPER(stype,supstname,member,2);\
ENUM_PTR(0,stype,e1); ENUM_PTR(1,stype,e2);\
ENUM_PTRS_END\
private RELOC_PTRS_BEGIN(preloc) RELOC_SUPER(stype,supstname,member);\
RELOC_PTR(stype,e1); RELOC_PTR(stype,e2);\
RELOC_PTRS_END\
gs__st_composite_only(scope_st, stname, stype, sname, penum, preloc)
#define gs_public_st_ptrs_add2(stname, stype, sname, penum, preloc, supstname, member, e1, e2)\
gs__st_ptrs_add2(public_st, stname, stype, sname, penum, preloc, supstname, member, e1, e2)
#define gs_private_st_ptrs_add2(stname, stype, sname, penum, preloc, supstname, member, e1, e2)\
gs__st_ptrs_add2(private_st, stname, stype, sname, penum, preloc, supstname, member, e1, e2)
#endif /* gsstruct_INCLUDED */
|