00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114 #ifndef _OBSTACK_H
00115 #define _OBSTACK_H 1
00116
00117 #ifdef __cplusplus
00118 extern "C" {
00119 #endif
00120
00121
00122
00123
00124
00125 #ifndef __PTR_TO_INT
00126 # define __PTR_TO_INT(P) ((P) - (char *) 0)
00127 #endif
00128
00129 #ifndef __INT_TO_PTR
00130 # define __INT_TO_PTR(P) ((P) + (char *) 0)
00131 #endif
00132
00133
00134
00135
00136
00137
00138
00139 #ifdef __PTRDIFF_TYPE__
00140 # define PTR_INT_TYPE __PTRDIFF_TYPE__
00141 #else
00142 # ifdef HAVE_STDDEF_H
00143 # include <stddef.h>
00144 # define PTR_INT_TYPE ptrdiff_t
00145 # else
00146 # define PTR_INT_TYPE long
00147 # endif
00148 #endif
00149
00150 #if defined _LIBC || defined HAVE_STRING_H
00151 # include <string.h>
00152 # if defined __STDC__ && __STDC__
00153 # define _obstack_memcpy(To, From, N) memcpy ((To), (From), (N))
00154 # else
00155 # define _obstack_memcpy(To, From, N) memcpy ((To), (char *)(From), (N))
00156 # endif
00157 #else
00158 # ifdef memcpy
00159 # define _obstack_memcpy(To, From, N) memcpy ((To), (char *)(From), (N))
00160 # else
00161 # define _obstack_memcpy(To, From, N) bcopy ((char *)(From), (To), (N))
00162 # endif
00163 #endif
00164
00165 struct _obstack_chunk
00166 {
00167 char *limit;
00168 struct _obstack_chunk *prev;
00169 char contents[4];
00170 };
00171
00172 struct obstack
00173 {
00174 long chunk_size;
00175 struct _obstack_chunk *chunk;
00176 char *object_base;
00177 char *next_free;
00178 char *chunk_limit;
00179 PTR_INT_TYPE temp;
00180 int alignment_mask;
00181 #if defined __STDC__ && __STDC__
00182
00183
00184
00185 struct _obstack_chunk *(*chunkfun) (void *, long);
00186 void (*freefun) (void *, struct _obstack_chunk *);
00187 void *extra_arg;
00188 #else
00189 struct _obstack_chunk *(*chunkfun) ();
00190 void (*freefun) ();
00191 char *extra_arg;
00192 #endif
00193 unsigned use_extra_arg:1;
00194 unsigned maybe_empty_object:1;
00195
00196
00197
00198 unsigned alloc_failed:1;
00199
00200
00201 };
00202
00203
00204
00205 #if defined __STDC__ && __STDC__
00206 extern void _obstack_newchunk (struct obstack *, int);
00207 extern void _obstack_free (struct obstack *, void *);
00208 extern int _obstack_begin (struct obstack *, int, int,
00209 void *(*) (long), void (*) (void *));
00210 extern int _obstack_begin_1 (struct obstack *, int, int,
00211 void *(*) (void *, long),
00212 void (*) (void *, void *), void *);
00213 extern int _obstack_memory_used (struct obstack *);
00214 #else
00215 extern void _obstack_newchunk ();
00216 extern void _obstack_free ();
00217 extern int _obstack_begin ();
00218 extern int _obstack_begin_1 ();
00219 extern int _obstack_memory_used ();
00220 #endif
00221
00222 #if defined __STDC__ && __STDC__
00223
00224
00225
00226
00227 void obstack_init (struct obstack *obstack);
00228
00229 void * obstack_alloc (struct obstack *obstack, int size);
00230
00231 void * obstack_copy (struct obstack *obstack, void *address, int size);
00232 void * obstack_copy0 (struct obstack *obstack, void *address, int size);
00233
00234 void obstack_free (struct obstack *obstack, void *block);
00235
00236 void obstack_blank (struct obstack *obstack, int size);
00237
00238 void obstack_grow (struct obstack *obstack, void *data, int size);
00239 void obstack_grow0 (struct obstack *obstack, void *data, int size);
00240
00241 void obstack_1grow (struct obstack *obstack, int data_char);
00242 void obstack_ptr_grow (struct obstack *obstack, void *data);
00243 void obstack_int_grow (struct obstack *obstack, int data);
00244
00245 void * obstack_finish (struct obstack *obstack);
00246
00247 int obstack_object_size (struct obstack *obstack);
00248
00249 int obstack_room (struct obstack *obstack);
00250 void obstack_make_room (struct obstack *obstack, int size);
00251 void obstack_1grow_fast (struct obstack *obstack, int data_char);
00252 void obstack_ptr_grow_fast (struct obstack *obstack, void *data);
00253 void obstack_int_grow_fast (struct obstack *obstack, int data);
00254 void obstack_blank_fast (struct obstack *obstack, int size);
00255
00256 void * obstack_base (struct obstack *obstack);
00257 void * obstack_next_free (struct obstack *obstack);
00258 int obstack_alignment_mask (struct obstack *obstack);
00259 int obstack_chunk_size (struct obstack *obstack);
00260 int obstack_memory_used (struct obstack *obstack);
00261
00262 #endif
00263
00264
00265
00266
00267
00268
00269
00270 #if defined __STDC__ && __STDC__
00271 extern void (*obstack_alloc_failed_handler) (void);
00272 #else
00273 extern void (*obstack_alloc_failed_handler) ();
00274 #endif
00275
00276
00277 extern int obstack_exit_failure;
00278
00279
00280
00281
00282
00283 #define obstack_base(h) ((h)->object_base)
00284
00285
00286
00287 #define obstack_chunk_size(h) ((h)->chunk_size)
00288
00289
00290
00291 #define obstack_next_free(h) ((h)->next_free)
00292
00293
00294
00295 #define obstack_alignment_mask(h) ((h)->alignment_mask)
00296
00297
00298
00299 #if defined __STDC__ && __STDC__
00300
00301 # define obstack_init(h) \
00302 _obstack_begin ((h), 0, 0, \
00303 (void *(*) (long)) obstack_chunk_alloc, (void (*) (void *)) obstack_chunk_free)
00304
00305 # define obstack_begin(h, size) \
00306 _obstack_begin ((h), (size), 0, \
00307 (void *(*) (long)) obstack_chunk_alloc, (void (*) (void *)) obstack_chunk_free)
00308
00309 # define obstack_specify_allocation(h, size, alignment, chunkfun, freefun) \
00310 _obstack_begin ((h), (size), (alignment), \
00311 (void *(*) (long)) (chunkfun), (void (*) (void *)) (freefun))
00312
00313 # define obstack_specify_allocation_with_arg(h, size, alignment, chunkfun, freefun, arg) \
00314 _obstack_begin_1 ((h), (size), (alignment), \
00315 (void *(*) (void *, long)) (chunkfun), \
00316 (void (*) (void *, void *)) (freefun), (arg))
00317
00318 # define obstack_chunkfun(h, newchunkfun) \
00319 ((h) -> chunkfun = (struct _obstack_chunk *(*)(void *, long)) (newchunkfun))
00320
00321 # define obstack_freefun(h, newfreefun) \
00322 ((h) -> freefun = (void (*)(void *, struct _obstack_chunk *)) (newfreefun))
00323
00324 #else
00325
00326 # define obstack_init(h) \
00327 _obstack_begin ((h), 0, 0, \
00328 (void *(*) ()) obstack_chunk_alloc, (void (*) ()) obstack_chunk_free)
00329
00330 # define obstack_begin(h, size) \
00331 _obstack_begin ((h), (size), 0, \
00332 (void *(*) ()) obstack_chunk_alloc, (void (*) ()) obstack_chunk_free)
00333
00334 # define obstack_specify_allocation(h, size, alignment, chunkfun, freefun) \
00335 _obstack_begin ((h), (size), (alignment), \
00336 (void *(*) ()) (chunkfun), (void (*) ()) (freefun))
00337
00338 # define obstack_specify_allocation_with_arg(h, size, alignment, chunkfun, freefun, arg) \
00339 _obstack_begin_1 ((h), (size), (alignment), \
00340 (void *(*) ()) (chunkfun), (void (*) ()) (freefun), (arg))
00341
00342 # define obstack_chunkfun(h, newchunkfun) \
00343 ((h) -> chunkfun = (struct _obstack_chunk *(*)()) (newchunkfun))
00344
00345 # define obstack_freefun(h, newfreefun) \
00346 ((h) -> freefun = (void (*)()) (newfreefun))
00347
00348 #endif
00349
00350 #define obstack_1grow_fast(h,achar) (*((h)->next_free)++ = (achar))
00351
00352 #define obstack_blank_fast(h,n) ((h)->next_free += (n))
00353
00354 #define obstack_memory_used(h) _obstack_memory_used (h)
00355
00356 #if defined __GNUC__ && defined __STDC__ && __STDC__
00357
00358
00359
00360 # if __GNUC__ < 2 || (__NeXT__ && !__GNUC_MINOR__)
00361 # define __extension__
00362 # endif
00363
00364
00365
00366
00367
00368
00369 # define obstack_object_size(OBSTACK) \
00370 __extension__ \
00371 ({ struct obstack *__o = (OBSTACK); \
00372 (unsigned) (__o->next_free - __o->object_base); })
00373
00374 # define obstack_room(OBSTACK) \
00375 __extension__ \
00376 ({ struct obstack *__o = (OBSTACK); \
00377 (unsigned) (__o->chunk_limit - __o->next_free); })
00378
00379 # define obstack_make_room(OBSTACK,length) \
00380 __extension__ \
00381 ({ struct obstack *__o = (OBSTACK); \
00382 int __len = (length); \
00383 if (__o->chunk_limit - __o->next_free < __len) \
00384 _obstack_newchunk (__o, __len); \
00385 (void) 0; })
00386
00387 # define obstack_empty_p(OBSTACK) \
00388 __extension__ \
00389 ({ struct obstack *__o = (OBSTACK); \
00390 (__o->chunk->prev == 0 && __o->next_free - __o->chunk->contents == 0); })
00391
00392 # define obstack_grow(OBSTACK,where,length) \
00393 __extension__ \
00394 ({ struct obstack *__o = (OBSTACK); \
00395 int __len = (length); \
00396 if (__o->next_free + __len > __o->chunk_limit) \
00397 _obstack_newchunk (__o, __len); \
00398 _obstack_memcpy (__o->next_free, (where), __len); \
00399 __o->next_free += __len; \
00400 (void) 0; })
00401
00402 # define obstack_grow0(OBSTACK,where,length) \
00403 __extension__ \
00404 ({ struct obstack *__o = (OBSTACK); \
00405 int __len = (length); \
00406 if (__o->next_free + __len + 1 > __o->chunk_limit) \
00407 _obstack_newchunk (__o, __len + 1); \
00408 _obstack_memcpy (__o->next_free, (where), __len); \
00409 __o->next_free += __len; \
00410 *(__o->next_free)++ = 0; \
00411 (void) 0; })
00412
00413 # define obstack_1grow(OBSTACK,datum) \
00414 __extension__ \
00415 ({ struct obstack *__o = (OBSTACK); \
00416 if (__o->next_free + 1 > __o->chunk_limit) \
00417 _obstack_newchunk (__o, 1); \
00418 obstack_1grow_fast (__o, datum); \
00419 (void) 0; })
00420
00421
00422
00423
00424
00425 # define obstack_ptr_grow(OBSTACK,datum) \
00426 __extension__ \
00427 ({ struct obstack *__o = (OBSTACK); \
00428 if (__o->next_free + sizeof (void *) > __o->chunk_limit) \
00429 _obstack_newchunk (__o, sizeof (void *)); \
00430 obstack_ptr_grow_fast (__o, datum); })
00431
00432 # define obstack_int_grow(OBSTACK,datum) \
00433 __extension__ \
00434 ({ struct obstack *__o = (OBSTACK); \
00435 if (__o->next_free + sizeof (int) > __o->chunk_limit) \
00436 _obstack_newchunk (__o, sizeof (int)); \
00437 obstack_int_grow_fast (__o, datum); })
00438
00439 # define obstack_ptr_grow_fast(OBSTACK,aptr) \
00440 __extension__ \
00441 ({ struct obstack *__o1 = (OBSTACK); \
00442 *(const void **) __o1->next_free = (aptr); \
00443 __o1->next_free += sizeof (const void *); \
00444 (void) 0; })
00445
00446 # define obstack_int_grow_fast(OBSTACK,aint) \
00447 __extension__ \
00448 ({ struct obstack *__o1 = (OBSTACK); \
00449 *(int *) __o1->next_free = (aint); \
00450 __o1->next_free += sizeof (int); \
00451 (void) 0; })
00452
00453 # define obstack_blank(OBSTACK,length) \
00454 __extension__ \
00455 ({ struct obstack *__o = (OBSTACK); \
00456 int __len = (length); \
00457 if (__o->chunk_limit - __o->next_free < __len) \
00458 _obstack_newchunk (__o, __len); \
00459 obstack_blank_fast (__o, __len); \
00460 (void) 0; })
00461
00462 # define obstack_alloc(OBSTACK,length) \
00463 __extension__ \
00464 ({ struct obstack *__h = (OBSTACK); \
00465 obstack_blank (__h, (length)); \
00466 obstack_finish (__h); })
00467
00468 # define obstack_copy(OBSTACK,where,length) \
00469 __extension__ \
00470 ({ struct obstack *__h = (OBSTACK); \
00471 obstack_grow (__h, (where), (length)); \
00472 obstack_finish (__h); })
00473
00474 # define obstack_copy0(OBSTACK,where,length) \
00475 __extension__ \
00476 ({ struct obstack *__h = (OBSTACK); \
00477 obstack_grow0 (__h, (where), (length)); \
00478 obstack_finish (__h); })
00479
00480
00481
00482 # define obstack_finish(OBSTACK) \
00483 __extension__ \
00484 ({ struct obstack *__o1 = (OBSTACK); \
00485 void *value; \
00486 value = (void *) __o1->object_base; \
00487 if (__o1->next_free == value) \
00488 __o1->maybe_empty_object = 1; \
00489 __o1->next_free \
00490 = __INT_TO_PTR ((__PTR_TO_INT (__o1->next_free)+__o1->alignment_mask)\
00491 & ~ (__o1->alignment_mask)); \
00492 if (__o1->next_free - (char *)__o1->chunk \
00493 > __o1->chunk_limit - (char *)__o1->chunk) \
00494 __o1->next_free = __o1->chunk_limit; \
00495 __o1->object_base = __o1->next_free; \
00496 value; })
00497
00498 # define obstack_free(OBSTACK, OBJ) \
00499 __extension__ \
00500 ({ struct obstack *__o = (OBSTACK); \
00501 void *__obj = (void *) (OBJ); \
00502 if (__obj > (void *)__o->chunk && __obj < (void *)__o->chunk_limit) \
00503 __o->next_free = __o->object_base = (char *) __obj; \
00504 else (obstack_free) (__o, __obj); })
00505
00506 #else
00507
00508 # define obstack_object_size(h) \
00509 (unsigned) ((h)->next_free - (h)->object_base)
00510
00511 # define obstack_room(h) \
00512 (unsigned) ((h)->chunk_limit - (h)->next_free)
00513
00514 # define obstack_empty_p(h) \
00515 ((h)->chunk->prev == 0 && (h)->next_free - (h)->chunk->contents == 0)
00516
00517
00518
00519
00520
00521
00522
00523 # define obstack_make_room(h,length) \
00524 ( (h)->temp = (length), \
00525 (((h)->next_free + (h)->temp > (h)->chunk_limit) \
00526 ? (_obstack_newchunk ((h), (h)->temp), 0) : 0))
00527
00528 # define obstack_grow(h,where,length) \
00529 ( (h)->temp = (length), \
00530 (((h)->next_free + (h)->temp > (h)->chunk_limit) \
00531 ? (_obstack_newchunk ((h), (h)->temp), 0) : 0), \
00532 _obstack_memcpy ((h)->next_free, (where), (h)->temp), \
00533 (h)->next_free += (h)->temp)
00534
00535 # define obstack_grow0(h,where,length) \
00536 ( (h)->temp = (length), \
00537 (((h)->next_free + (h)->temp + 1 > (h)->chunk_limit) \
00538 ? (_obstack_newchunk ((h), (h)->temp + 1), 0) : 0), \
00539 _obstack_memcpy ((h)->next_free, (where), (h)->temp), \
00540 (h)->next_free += (h)->temp, \
00541 *((h)->next_free)++ = 0)
00542
00543 # define obstack_1grow(h,datum) \
00544 ( (((h)->next_free + 1 > (h)->chunk_limit) \
00545 ? (_obstack_newchunk ((h), 1), 0) : 0), \
00546 obstack_1grow_fast (h, datum))
00547
00548 # define obstack_ptr_grow(h,datum) \
00549 ( (((h)->next_free + sizeof (char *) > (h)->chunk_limit) \
00550 ? (_obstack_newchunk ((h), sizeof (char *)), 0) : 0), \
00551 obstack_ptr_grow_fast (h, datum))
00552
00553 # define obstack_int_grow(h,datum) \
00554 ( (((h)->next_free + sizeof (int) > (h)->chunk_limit) \
00555 ? (_obstack_newchunk ((h), sizeof (int)), 0) : 0), \
00556 obstack_int_grow_fast (h, datum))
00557
00558 # define obstack_ptr_grow_fast(h,aptr) \
00559 (((const void **) ((h)->next_free += sizeof (void *)))[-1] = (aptr))
00560
00561 # define obstack_int_grow_fast(h,aint) \
00562 (((int *) ((h)->next_free += sizeof (int)))[-1] = (aptr))
00563
00564 # define obstack_blank(h,length) \
00565 ( (h)->temp = (length), \
00566 (((h)->chunk_limit - (h)->next_free < (h)->temp) \
00567 ? (_obstack_newchunk ((h), (h)->temp), 0) : 0), \
00568 obstack_blank_fast (h, (h)->temp))
00569
00570 # define obstack_alloc(h,length) \
00571 (obstack_blank ((h), (length)), obstack_finish ((h)))
00572
00573 # define obstack_copy(h,where,length) \
00574 (obstack_grow ((h), (where), (length)), obstack_finish ((h)))
00575
00576 # define obstack_copy0(h,where,length) \
00577 (obstack_grow0 ((h), (where), (length)), obstack_finish ((h)))
00578
00579 # define obstack_finish(h) \
00580 ( ((h)->next_free == (h)->object_base \
00581 ? (((h)->maybe_empty_object = 1), 0) \
00582 : 0), \
00583 (h)->temp = __PTR_TO_INT ((h)->object_base), \
00584 (h)->next_free \
00585 = __INT_TO_PTR ((__PTR_TO_INT ((h)->next_free)+(h)->alignment_mask) \
00586 & ~ ((h)->alignment_mask)), \
00587 (((h)->next_free - (char *) (h)->chunk \
00588 > (h)->chunk_limit - (char *) (h)->chunk) \
00589 ? ((h)->next_free = (h)->chunk_limit) : 0), \
00590 (h)->object_base = (h)->next_free, \
00591 __INT_TO_PTR ((h)->temp))
00592
00593 # if defined __STDC__ && __STDC__
00594 # define obstack_free(h,obj) \
00595 ( (h)->temp = (char *) (obj) - (char *) (h)->chunk, \
00596 (((h)->temp > 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\
00597 ? (int) ((h)->next_free = (h)->object_base \
00598 = (h)->temp + (char *) (h)->chunk) \
00599 : (((obstack_free) ((h), (h)->temp + (char *) (h)->chunk), 0), 0)))
00600 # else
00601 # define obstack_free(h,obj) \
00602 ( (h)->temp = (char *) (obj) - (char *) (h)->chunk, \
00603 (((h)->temp > 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\
00604 ? (int) ((h)->next_free = (h)->object_base \
00605 = (h)->temp + (char *) (h)->chunk) \
00606 : (_obstack_free ((h), (h)->temp + (char *) (h)->chunk), 0)))
00607 # endif
00608
00609 #endif
00610
00611 #ifdef __cplusplus
00612 }
00613 #endif
00614
00615 #endif