]> Savannah Git Hosting - gnulib.git/commitdiff
obstack: do not assume system-supplied obstack is size_t safe
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 4 Nov 2014 00:36:27 +0000 (16:36 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 4 Nov 2014 08:33:35 +0000 (00:33 -0800)
* m4/obstack.m4: New file.
* modules/obstack (Files): Add it.

ChangeLog
m4/obstack.m4 [new file with mode: 0644]
modules/obstack

index 274b7948ee29ca40188f535788552dbdf40ba5dd..23accbec53c7419992ba3222e795dfc9787d65fb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2014-11-03  Paul Eggert  <eggert@cs.ucla.edu>
 
+       obstack: do not assume system-supplied obstack is size_t safe
+       * m4/obstack.m4: New file.
+       * modules/obstack (Files): Add it.
+
        obstack: port to platforms that #define __alignof__
        * lib/obstack.c: Include <alignof.h> if !defined __alignof__,
        not if !_LIBC.  We don't know of any platforms that #define
diff --git a/m4/obstack.m4 b/m4/obstack.m4
new file mode 100644 (file)
index 0000000..bc5b4a4
--- /dev/null
@@ -0,0 +1,35 @@
+# See if we need to provide obstacks.
+
+dnl Copyright 1996-2014 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl This replaces Autoconf's AC_FUNC_OBSTACK.
+dnl The Autoconf version should be marked obsolete at some point.
+
+AC_DEFUN([AC_FUNC_OBSTACK],
+  [AC_LIBSOURCES([obstack.h, obstack.c])dnl
+   AC_CACHE_CHECK([for obstacks that work with any size object],
+     [ac_cv_func_obstack],
+     [AC_LINK_IFELSE(
+        [AC_LANG_PROGRAM(
+           [[#include "obstack.h"
+             void *obstack_chunk_alloc (size_t n) { return 0; }
+             void obstack_chunk_free (void *p) { }
+             /* Check that an internal function returns size_t, not int.  */
+             size_t _obstack_memory_used (struct obstack *);
+            ]],
+           [[struct obstack mem;
+             obstack_init (&mem);
+             obstack_free (&mem, 0);
+           ]])],
+        [ac_cv_func_obstack=yes],
+        [ac_cv_func_obstack=no])])
+   if test "$ac_cv_func_obstack" = yes; then
+     AC_DEFINE([HAVE_OBSTACK], 1,
+       [Define to 1 if the system has obstacks that work with any size object.])
+   else
+     AC_LIBOBJ([obstack])
+   fi
+])
index 36dc44453722fa7769e289e3fb2c584fd01806d1..e0b528e418811e94ce9d7ee0d22720f186eb386e 100644 (file)
@@ -4,6 +4,7 @@ Memory allocation, optimized for stack-like allocation patterns.
 Files:
 lib/obstack.h
 lib/obstack.c
+m4/obstack.m4
 
 Depends-on:
 alignof