~ubuntu-branches/ubuntu/utopic/coreutils/utopic-proposed

« back to all changes in this revision

Viewing changes to lib/obstack.h

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2012-11-28 03:03:42 UTC
  • mfrom: (8.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20121128030342-21zanj8354gas5gr
Tags: 8.20-3ubuntu1
* Resynchronise with Debian.  Remaining changes:
  - Make 'uname -i -p' return the real processor/hardware, instead of
    unknown.
  - Build-depend on gettext:any instead of on gettext, so that apt-get can
    properly resolve build-dependencies on the tool when cross-building.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* obstack.h - object stack macros
2
 
   Copyright (C) 1988-1994, 1996-1999, 2003-2006, 2009-2011 Free Software
 
2
   Copyright (C) 1988-1994, 1996-1999, 2003-2006, 2009-2012 Free Software
3
3
   Foundation, Inc.
4
4
   This file is part of the GNU C Library.
5
5
 
32
32
stack is of mature, fixed size and fixed address objects.
33
33
 
34
34
These routines grab large chunks of memory, using a function you
35
 
supply, called `obstack_chunk_alloc'.  On occasion, they free chunks,
36
 
by calling `obstack_chunk_free'.  You must define them and declare
 
35
supply, called 'obstack_chunk_alloc'.  On occasion, they free chunks,
 
36
by calling 'obstack_chunk_free'.  You must define them and declare
37
37
them before using any obstack macros.
38
38
 
39
 
Each independent stack is represented by a `struct obstack'.
 
39
Each independent stack is represented by a 'struct obstack'.
40
40
Each of the obstack macros expects a pointer to such a structure
41
41
as the first argument.
42
42
 
93
93
        Exactly one object is growing in an obstack at any one time.
94
94
        You can run one obstack per control block.
95
95
        You may have as many control blocks as you dare.
96
 
        Because of the way we do it, you can `unwind' an obstack
 
96
        Because of the way we do it, you can "unwind" an obstack
97
97
          back to a previous state. (You may remove objects much
98
98
          as you would with a stack.)
99
99
*/
122
122
 
123
123
#define __BPTR_ALIGN(B, P, A) ((B) + (((P) - (B) + (A)) & ~(A)))
124
124
 
125
 
/* Similiar to _BPTR_ALIGN (B, P, A), except optimize the common case
 
125
/* Similar to _BPTR_ALIGN (B, P, A), except optimize the common case
126
126
   where pointers can be converted to integers, aligned as integers,
127
127
   and converted back again.  If PTR_INT_TYPE is narrower than a
128
128
   pointer (e.g., the AS/400), play it safe and compute the alignment
159
159
    void *tempptr;
160
160
  } temp;                       /* Temporary for some macros.  */
161
161
  int   alignment_mask;         /* Mask of alignment for each object. */
162
 
  /* These prototypes vary based on `use_extra_arg', and we use
 
162
  /* These prototypes vary based on 'use_extra_arg', and we use
163
163
     casts to the prototypeless function type in all assignments,
164
164
     but having prototypes here quiets -Wstrict-prototypes.  */
165
165
  struct _obstack_chunk *(*chunkfun) (void *, long);
193
193
extern void __obstack_free (struct obstack *obstack, void *block);
194
194
 
195
195
 
196
 
/* Error handler called when `obstack_chunk_alloc' failed to allocate
 
196
/* Error handler called when 'obstack_chunk_alloc' failed to allocate
197
197
   more memory.  This can be set to a user defined function which
198
198
   should either abort gracefully or use longjump - but shouldn't
199
199
   return.  The default action is to print a message and abort.  */
200
200
extern void (*obstack_alloc_failed_handler) (void);
201
201
 
202
 
/* Exit value used when `print_and_abort' is used.  */
 
202
/* Exit value used when 'print_and_abort' is used.  */
203
203
extern int obstack_exit_failure;
204
204
 
205
205
/* Pointer to beginning of object being allocated or to be allocated next.
253
253
 
254
254
#define obstack_memory_used(h) _obstack_memory_used (h)
255
255
 
256
 
#if defined __GNUC__ && defined __STDC__ && __STDC__
 
256
#if defined __GNUC__
257
257
/* NextStep 2.0 cc is really gcc 1.93 but it defines __GNUC__ = 2 and
258
258
   does not implement __extension__.  But that compiler doesn't define
259
259
   __GNUC_MINOR__.  */
264
264
/* For GNU C, if not -traditional,
265
265
   we can define these macros to compute all args only once
266
266
   without using a global variable.
267
 
   Also, we can avoid using the `temp' slot, to make faster code.  */
 
267
   Also, we can avoid using the 'temp' slot, to make faster code.  */
268
268
 
269
269
# define obstack_object_size(OBSTACK)                                   \
270
270
  __extension__                                                         \
405
405
     __o->next_free = __o->object_base = (char *)__obj;                 \
406
406
   else (__obstack_free) (__o, __obj); })
407
407
 
408
 
#else /* not __GNUC__ or not __STDC__ */
 
408
#else /* not __GNUC__ */
409
409
 
410
410
# define obstack_object_size(h) \
411
411
 (unsigned) ((h)->next_free - (h)->object_base)
503
503
            = (h)->temp.tempint + (char *) (h)->chunk)                  \
504
504
   : (((__obstack_free) ((h), (h)->temp.tempint + (char *) (h)->chunk), 0), 0)))
505
505
 
506
 
#endif /* not __GNUC__ or not __STDC__ */
 
506
#endif /* not __GNUC__ */
507
507
 
508
508
#ifdef __cplusplus
509
509
}       /* C++ */