Fix problem with getdate on mingw32 reported by Simon Josefsson
[gnulib.git] / lib / obstack.h
index d46b054..1bf4b2f 100644 (file)
@@ -1,25 +1,20 @@
 /* obstack.h - object stack macros
-   Copyright (C) 1988-1994,1996-1999,2003,2004 Free Software Foundation, Inc.
+   Copyright (C) 1988-1994,1996-1999,2003,2004,2005,2006
+       Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
 
-   This file is part of the GNU C Library.  Its master source is NOT part of
-   the C library, however.  The master source lives in /gd/gnu/lib.
-
-   NOTE: The canonical source of this file is maintained with the GNU C Library.
-   Bugs can be reported to bug-glibc@gnu.org.
-
-   This program is free software; you can redistribute it and/or modify
+   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 2, or (at your option)
-   any later version.
+   the Free Software Foundation; either version 3 of the License, 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,
-   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 /* Summary:
 
@@ -190,7 +185,12 @@ extern int _obstack_begin_1 (struct obstack *, int, int,
                             void (*) (void *, void *), void *);
 extern int _obstack_memory_used (struct obstack *);
 
-void obstack_free (struct obstack *obstack, void *block);
+/* The default name of the function for freeing a chunk is 'obstack_free',
+   but gnulib users can override this by defining '__obstack_free'.  */
+#ifndef __obstack_free
+# define __obstack_free obstack_free
+#endif
+extern void __obstack_free (struct obstack *obstack, void *block);
 
 \f
 /* Error handler called when `obstack_chunk_alloc' failed to allocate
@@ -287,7 +287,10 @@ __extension__                                                              \
 # define obstack_empty_p(OBSTACK)                                      \
   __extension__                                                                \
   ({ struct obstack const *__o = (OBSTACK);                            \
-     (__o->chunk->prev == 0 && __o->next_free - __o->chunk->contents == 0); })
+     (__o->chunk->prev == 0                                            \
+      && __o->next_free == __PTR_ALIGN ((char *) __o->chunk,           \
+                                       __o->chunk->contents,           \
+                                       __o->alignment_mask)); })
 
 # define obstack_grow(OBSTACK,where,length)                            \
 __extension__                                                          \
@@ -400,7 +403,7 @@ __extension__                                                               \
    void *__obj = (OBJ);                                                        \
    if (__obj > (void *)__o->chunk && __obj < (void *)__o->chunk_limit)  \
      __o->next_free = __o->object_base = (char *)__obj;                        \
-   else (obstack_free) (__o, __obj); })
+   else (__obstack_free) (__o, __obj); })
 \f
 #else /* not __GNUC__ or not __STDC__ */
 
@@ -411,7 +414,10 @@ __extension__                                                              \
  (unsigned) ((h)->chunk_limit - (h)->next_free)
 
 # define obstack_empty_p(h) \
- ((h)->chunk->prev == 0 && (h)->next_free - (h)->chunk->contents == 0)
+ ((h)->chunk->prev == 0                                                        \
+  && (h)->next_free == __PTR_ALIGN ((char *) (h)->chunk,               \
+                                   (h)->chunk->contents,               \
+                                   (h)->alignment_mask))
 
 /* Note that the call to _obstack_newchunk is enclosed in (..., 0)
    so that we can avoid having void expressions
@@ -458,7 +464,7 @@ __extension__                                                               \
   (((const void **) ((h)->next_free += sizeof (void *)))[-1] = (aptr))
 
 # define obstack_int_grow_fast(h,aint)                                 \
-  (((int *) ((h)->next_free += sizeof (int)))[-1] = (aptr))
+  (((int *) ((h)->next_free += sizeof (int)))[-1] = (aint))
 
 # define obstack_blank(h,length)                                       \
 ( (h)->temp.tempint = (length),                                                \
@@ -495,7 +501,7 @@ __extension__                                                               \
     && (h)->temp.tempint < (h)->chunk_limit - (char *) (h)->chunk))    \
    ? (int) ((h)->next_free = (h)->object_base                          \
            = (h)->temp.tempint + (char *) (h)->chunk)                  \
-   : (((obstack_free) ((h), (h)->temp.tempint + (char *) (h)->chunk), 0), 0)))
+   : (((__obstack_free) ((h), (h)->temp.tempint + (char *) (h)->chunk), 0), 0)))
 
 #endif /* not __GNUC__ or not __STDC__ */