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