* xcoffexec.c (exec_ops): child_attach and child_create_inferior
[deliverable/binutils-gdb.git] / gdb / obstack.h
old mode 100644 (file)
new mode 100755 (executable)
index f80f2b1..2e80c9c
 /* obstack.h - object stack macros
    Copyright (C) 1988 Free Software Foundation, Inc.
 
-                      NO WARRANTY
-
-  BECAUSE THIS PROGRAM IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY
-NO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW.  EXCEPT
-WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC,
-RICHARD M. STALLMAN AND/OR OTHER PARTIES PROVIDE THIS PROGRAM "AS IS"
-WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
-BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY
-AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE PROGRAM PROVE
-DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
-CORRECTION.
-
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M.
-STALLMAN, THE FREE SOFTWARE FOUNDATION, INC., AND/OR ANY OTHER PARTY
-WHO MAY MODIFY AND REDISTRIBUTE THIS PROGRAM AS PERMITTED BELOW, BE
-LIABLE TO YOU FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR
-OTHER SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
-USE OR INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR
-DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR
-A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) THIS
-PROGRAM, EVEN IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY.
-
-               GENERAL PUBLIC LICENSE TO COPY
-
-  1. You may copy and distribute verbatim copies of this source file
-as you receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy a valid copyright notice "Copyright
- (C) 1988 Free Software Foundation, Inc."; and include following the
-copyright notice a verbatim copy of the above disclaimer of warranty
-and of this License.  You may charge a distribution fee for the
-physical act of transferring a copy.
-
-  2. You may modify your copy or copies of this source file or
-any portion of it, and copy and distribute such modifications under
-the terms of Paragraph 1 above, provided that you also do the following:
-
-    a) cause the modified files to carry prominent notices stating
-    that you changed the files and the date of any change; and
-
-    b) cause the whole of any work that you distribute or publish,
-    that in whole or in part contains or is a derivative of this
-    program or any part thereof, to be licensed at no charge to all
-    third parties on terms identical to those contained in this
-    License Agreement (except that you may choose to grant more extensive
-    warranty protection to some or all third parties, at your option).
-
-    c) You may charge a distribution fee for the physical act of
-    transferring a copy, and you may at your option offer warranty
-    protection in exchange for a fee.
-
-Mere aggregation of another unrelated program with this program (or its
-derivative) on a volume of a storage or distribution medium does not bring
-the other program under the scope of these terms.
-
-  3. You may copy and distribute this program or any portion of it in
-compiled, executable or object code form under the terms of Paragraphs
-1 and 2 above provided that you do the following:
-
-    a) accompany it with the complete corresponding machine-readable
-    source code, which must be distributed under the terms of
-    Paragraphs 1 and 2 above; or,
-
-    b) accompany it with a written offer, valid for at least three
-    years, to give any third party free (except for a nominal
-    shipping charge) a complete machine-readable copy of the
-    corresponding source code, to be distributed under the terms of
-    Paragraphs 1 and 2 above; or,
-
-    c) accompany it with the information you received as to where the
-    corresponding source code may be obtained.  (This alternative is
-    allowed only for noncommercial distribution and only if you
-    received the program in object code or executable form alone.)
-
-For an executable file, complete source code means all the source code for
-all modules it contains; but, as a special exception, it need not include
-source code for modules which are standard libraries that accompany the
-operating system on which the executable file runs.
-
-  4. You may not copy, sublicense, distribute or transfer this program
-except as expressly provided under this License Agreement.  Any attempt
-otherwise to copy, sublicense, distribute or transfer this program is void and
-your rights to use the program under this License agreement shall be
-automatically terminated.  However, parties who have received computer
-software programs from you with this License Agreement will not have
-their licenses terminated so long as such parties remain in full compliance.
-
-  5. If you wish to incorporate parts of this program into other free
-programs whose distribution conditions are different, write to the Free
-Software Foundation at 675 Mass Ave, Cambridge, MA 02139.  We have not yet
-worked out a simple rule that can be stated here, but we will often permit
-this.  We will be guided by the two goals of preserving the free status of
-all derivatives our free software and of promoting the sharing and reuse of
-software.
-
-
-In other words, you are welcome to use, share and improve this program.
-You are forbidden to forbid anyone else to use, share and improve
-what you give them.   Help stamp out software-hoarding!  */
+This program is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 1, or (at your option) any
+later version.
 
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
 /* Summary:
 
@@ -128,7 +40,7 @@ Each of the obstack macros expects a pointer to such a structure
 as the first argument.
 
 One motivation for this package is the problem of growing char strings
-in symbol tables.  Unless you are "facist pig with a read-only mind"
+in symbol tables.  Unless you are "fascist pig with a read-only mind"
 [Gosper's immortal quote from HAKMEM item 154, out of context] you
 would not like to put any arbitrary upper limit on the length of your
 symbols.
@@ -147,7 +59,7 @@ When the name is complete, finalize it.  Then, if the symbol exists already,
 free the newly read name.
 
 The way we do this is to take a large chunk, allocating memory from
-low addresses.  When you want to build a aymbol in the chunk you just
+low addresses.  When you want to build a symbol in the chunk you just
 add chars above the current "high water mark" in the chunk.  When you
 have finished adding chars, because you got to the end of the symbol,
 you know how long the chars are, and you can create a new object.
@@ -164,8 +76,8 @@ change its address during its lifetime.
 
 When the chars burst over a chunk boundary, we allocate a larger
 chunk, and then copy the partly formed object from the end of the old
-chunk to the beggining of the new larger chunk.  We then carry on
-accreting characters to the end of the object as we normaly would.
+chunk to the beginning of the new larger chunk.  We then carry on
+accreting characters to the end of the object as we normally would.
 
 A special macro is provided to add a single char at a time to a
 growing object.  This allows the use of register variables, which
@@ -219,7 +131,11 @@ struct obstack             /* control current object in current chunk */
   char *chunk_limit;           /* address of char after current chunk */
   int  temp;                   /* Temporary for some macros.  */
   int   alignment_mask;                /* Mask of alignment for each object. */
-  struct _obstack_chunk *(*chunkfun) (); /* User's fcn to allocate a chunk.  */
+#ifdef __STDC__
+  void  *(*chunkfun) ();       /* User's fcn to allocate a chunk.  */
+#else
+  char  *(*chunkfun) ();       /* User's fcn to allocate a chunk.  */
+#endif
   void (*freefun) ();          /* User's function to free a chunk.  */
 };
 \f
@@ -243,6 +159,8 @@ void obstack_grow (struct obstack *obstack, void *data, int size);
 void obstack_grow0 (struct obstack *obstack, void *data, int size);
 
 void obstack_1grow (struct obstack *obstack, int data_char);
+void obstack_ptr_grow (struct obstack *obstack, void *data);
+void obstack_int_grow (struct obstack *obstack, int data);
 
 void * obstack_finish (struct obstack *obstack);
 
@@ -250,6 +168,8 @@ int obstack_object_size (struct obstack *obstack);
 
 int obstack_room (struct obstack *obstack);
 void obstack_1grow_fast (struct obstack *obstack, int data_char);
+void obstack_ptr_grow_fast (struct obstack *obstack, void *data);
+void obstack_int_grow_fast (struct obstack *obstack, int data);
 void obstack_blank_fast (struct obstack *obstack, int size);
 
 void * obstack_base (struct obstack *obstack);
@@ -290,9 +210,10 @@ int obstack_chunk_size (struct obstack *obstack);
 
 #define obstack_blank_fast(h,n) ((h)->next_free += (n))
 \f
-#ifdef __GNUC__
+#if defined (__GNUC__) && defined (__STDC__)
 
-/* For GNU C we can define these macros to compute all args only once
+/* For GNU C, if not -traditional,
+   we can define these macros to compute all args only once
    without using a global variable.
    Also, we can avoid using the `temp' slot, to make faster code.  */
 
@@ -330,10 +251,31 @@ int obstack_chunk_size (struct obstack *obstack);
    *(__o->next_free)++ = (datum);                                      \
    (void) 0; })
 
+/* These assume that the obstack alignment is good enough for pointers or ints,
+   and that the data added so far to the current object
+   shares that much alignment.  */
+   
+#define obstack_ptr_grow(OBSTACK,datum)                                        \
+({ struct obstack *__o = (OBSTACK);                                    \
+   ((__o->next_free + sizeof (void *) > __o->chunk_limit)              \
+    ? _obstack_newchunk (__o, sizeof (void *)) : 0),                   \
+   *(*(void ***)&__o->next_free)++ = ((void *)datum);                  \
+   (void) 0; })
+
+#define obstack_int_grow(OBSTACK,datum)                                        \
+({ struct obstack *__o = (OBSTACK);                                    \
+   ((__o->next_free + sizeof (int) > __o->chunk_limit)                 \
+    ? _obstack_newchunk (__o, sizeof (int)) : 0),                      \
+   *(*(int **)&__o->next_free)++ = ((int)datum);                               \
+   (void) 0; })
+
+#define obstack_ptr_grow_fast(h,aptr) (*(*(void ***)&(h)->next_free)++ = (void *)aptr)
+#define obstack_int_grow_fast(h,aint) (*(*(int **)&(h)->next_free)++ = (int)aint)
+
 #define obstack_blank(OBSTACK,length)                                  \
 ({ struct obstack *__o = (OBSTACK);                                    \
    int __len = (length);                                               \
-   ((__o->next_free + __len > __o->chunk_limit)                                \
+   ((__o->chunk_limit - __o->next_free < __len)                                \
     ? _obstack_newchunk (__o, __len) : 0);                             \
    __o->next_free += __len;                                            \
    (void) 0; })
@@ -368,22 +310,17 @@ int obstack_chunk_size (struct obstack *obstack);
 #define obstack_free(OBSTACK, OBJ)                                     \
 ({ struct obstack *__o = (OBSTACK);                                    \
    void *__obj = (OBJ);                                                        \
-   if (__obj >= (void *)__o->chunk && __obj < (void *)__o->chunk_limit) \
+   if (__obj > (void *)__o->chunk && __obj < (void *)__o->chunk_limit)  \
      __o->next_free = __o->object_base = __obj;                                \
    else (obstack_free) (__o, __obj); })
 \f
-#else /* not __GNUC__ */
-
-/* The non-GNU macros copy the obstack-pointer into this global variable
-   to avoid multiple evaluation.  */
-
-extern struct obstack *_obstack;
+#else /* not __GNUC__ or not __STDC__ */
 
 #define obstack_object_size(h) \
- (unsigned) (_obstack = (h), (h)->next_free - (h)->object_base)
+ (unsigned) ((h)->next_free - (h)->object_base)
 
 #define obstack_room(h)                \
- (unsigned) (_obstack = (h), (h)->chunk_limit - (h)->next_free)
+ (unsigned) ((h)->chunk_limit - (h)->next_free)
 
 #define obstack_grow(h,where,length)                                   \
 ( (h)->temp = (length),                                                        \
@@ -395,7 +332,7 @@ extern struct obstack *_obstack;
 #define obstack_grow0(h,where,length)                                  \
 ( (h)->temp = (length),                                                        \
   (((h)->next_free + (h)->temp + 1 > (h)->chunk_limit)                 \
-   ? _obstack_newchunk ((h), (h)->temp + 1) : 0),                              \
+   ? _obstack_newchunk ((h), (h)->temp + 1) : 0),                      \
   bcopy (where, (h)->next_free, (h)->temp),                            \
   (h)->next_free += (h)->temp,                                         \
   *((h)->next_free)++ = 0)
@@ -405,9 +342,22 @@ extern struct obstack *_obstack;
    ? _obstack_newchunk ((h), 1) : 0),                                  \
   *((h)->next_free)++ = (datum))
 
+#define obstack_ptr_grow(h,datum)                                      \
+( (((h)->next_free + sizeof (char *) > (h)->chunk_limit)               \
+   ? _obstack_newchunk ((h), sizeof (char *)) : 0),                    \
+  *(*(char ***)&(h)->next_free)++ = ((char *)datum))
+
+#define obstack_int_grow(h,datum)                                      \
+( (((h)->next_free + sizeof (int) > (h)->chunk_limit)                  \
+   ? _obstack_newchunk ((h), sizeof (int)) : 0),                       \
+  *(*(int **)&(h)->next_free)++ = ((int)datum))
+
+#define obstack_ptr_grow_fast(h,aptr) (*(*(char ***)&(h)->next_free)++ = (char *)aptr)
+#define obstack_int_grow_fast(h,aint) (*(*(int **)&(h)->next_free)++ = (int)aint)
+
 #define obstack_blank(h,length)                                                \
 ( (h)->temp = (length),                                                        \
-  (((h)->next_free + (h)->temp > (h)->chunk_limit)                     \
+  (((h)->chunk_limit - (h)->next_free < (h)->temp)                     \
    ? _obstack_newchunk ((h), (h)->temp) : 0),                          \
   (h)->next_free += (h)->temp)
 
@@ -447,7 +397,20 @@ extern struct obstack *_obstack;
    : (int) _obstack_free ((h), (h)->temp + (char *) (h)->chunk)))
 #endif
 
-#endif /* not __GNUC__ */
+#endif /* not __GNUC__ or not __STDC__ */
+
+/* Declare the external functions we use; they are in obstack.c.  */
+
+#ifdef __STDC__
+  extern int _obstack_newchunk (struct obstack *h, int length);
+  extern int _obstack_free (struct obstack *h, void *obj);
+  extern void _obstack_begin (struct obstack *h, int size, int alignment,
+                             void *(*chunkfun) (), void (*freefun) ());
+#else
+  extern int _obstack_newchunk ();
+  extern int _obstack_free ();
+  extern void _obstack_begin ();
+#endif
 
 #endif /* not __OBSTACKS__ */
 
This page took 0.026269 seconds and 4 git commands to generate.