add warning
[gnulib.git] / lib / obstack.h
index 0e7eb09..3edd3f4 100644 (file)
@@ -1,23 +1,25 @@
 /* obstack.h - object stack macros
    Copyright (C) 1988,89,90,91,92,93,94,96,97 Free Software Foundation, Inc.
 
-   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.
 
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Library General Public License as
-   published by the Free Software Foundation; either version 2 of the
-   License, or (at your option) any later version.
+   NOTE: The canonical source of this file is maintained with the GNU C Library.
+   Bugs can be reported to bug-glibc@prep.ai.mit.edu.
 
-   The GNU C Library is distributed in the hope that it will be useful,
+   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.
+
+   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
-   Library General Public License for more details.
+   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 Library General Public
-   License along with the GNU C Library; see the file COPYING.LIB.  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, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+   USA.  */
 
 /* Summary:
 
@@ -104,8 +106,12 @@ Summary:
 
 /* Don't do the contents of this file more than once.  */
 
-#ifndef __OBSTACK_H__
-#define __OBSTACK_H__
+#ifndef _OBSTACK_H
+#define _OBSTACK_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 \f
 /* We use subtraction of (char *) 0 instead of casting to int
    because on word-addressable machines a simple cast to int
@@ -303,13 +309,14 @@ extern int obstack_exit_failure;
 
 #define obstack_specify_allocation_with_arg(h, size, alignment, chunkfun, freefun, arg) \
   _obstack_begin_1 ((h), (size), (alignment), \
-                   (void *(*) (long)) (chunkfun), (void (*) (void *)) (freefun), (arg))
+                   (void *(*) (void *, long)) (chunkfun), \
+                   (void (*) (void *, void *)) (freefun), (arg))
 
 #define obstack_chunkfun(h, newchunkfun) \
-  ((h) -> chunkfun = (struct _obstack_chunk *(*)(long)) (newchunkfun))
+  ((h) -> chunkfun = (struct _obstack_chunk *(*)(void *, long)) (newchunkfun))
 
 #define obstack_freefun(h, newfreefun) \
-  ((h) -> freefun = (void (*)(void *)) (newfreefun))
+  ((h) -> freefun = (void (*)(void *, struct _obstack_chunk *)) (newfreefun))
 
 #else
 
@@ -374,6 +381,11 @@ __extension__                                                              \
      _obstack_newchunk (__o, __len);                                   \
    (void) 0; })
 
+#define obstack_empty_p(OBSTACK)                                       \
+  __extension__                                                                \
+  ({ struct obstack *__o = (OBSTACK);                                  \
+     (__o->chunk->prev == 0 && __o->next_free - __o->chunk->contents == 0); })
+
 #define obstack_grow(OBSTACK,where,length)                             \
 __extension__                                                          \
 ({ struct obstack *__o = (OBSTACK);                                    \
@@ -487,6 +499,9 @@ __extension__                                                               \
 #define obstack_room(h)                \
  (unsigned) ((h)->chunk_limit - (h)->next_free)
 
+#define obstack_empty_p(h) \
+ ((h)->chunk->prev == 0 && (h)->next_free - (h)->chunk->contents == 0)
+
 /* Note that the call to _obstack_newchunk is enclosed in (..., 0)
    so that we can avoid having void expressions
    in the arms of the conditional expression.
@@ -578,4 +593,8 @@ __extension__                                                               \
 
 #endif /* not __GNUC__ or not __STDC__ */
 
-#endif /* not __OBSTACK_H__ */
+#ifdef __cplusplus
+}      /* C++ */
+#endif
+
+#endif /* obstack.h */